Set Static IP in RHEL 8 OVH VPS

On OVH VPS running AlmaLinux 8, IPv4 IP address gets dropped. I have to connect to the server using KVM feature available in OVH control panel.

OVH Cloud VPS KVM

I checked IP of the server with the command

ip a

It did hot show any IPv4 IP address. I checked the network configuration file

vi /etc/sysconfig/network-scripts/ifcfg-eth0

That had the following content

BOOTPROTO=dhcp
DEFROUTE=yes
DEVICE=eth0
DHCLIENT_SET_DEFAULT_ROUTE=yes
HWADDR=fa:16:3e:6b:a6:1a
IPV6ADDR=2607:5300:201:3100::952/56
IPV6INIT=yes
IPV6_AUTOCONF=no
IPV6_DEFAULTGW=2607:5300:201:3100::1
IPV6_FORCE_ACCEPT_RA=no
MTU=1500
ONBOOT=yes
TYPE=Ethernet
USERCTL=no

To make the IP static, I made the following changes.

Find

BOOTPROTO=dhcp

Replace with

BOOTPROTO=static

Also added following 2 entry

IPADDR=144.217.13.76
GATEWAY=144.217.12.1

144.217.13.76 is the IP address of the VPS.

144.217.12.1 is the gateway used on the VPS, found using “ip route” or “route -n” command.

[root@vps-eb960963 network-scripts]# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         144.217.12.1    0.0.0.0         UG    0      0        0 eth0
144.217.12.1    0.0.0.0         255.255.255.255 UH    0      0        0 eth0
[root@vps-eb960963 network-scripts]#

Create a static route file

vi /etc/sysconfig/network-scripts/route-eth0

Add

144.217.12.1 dev eth0
default via 144.217.12.1 dev eth0

Here 144.217.12.1 is the gateway IP address found in the above step.

See IP

Need help with Linux Server or WordPress? We can help!

Leave a Reply

Your email address will not be published. Required fields are marked *