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.
I checked IP of the server with the command
1 |
ip a |
It did hot show any IPv4 IP address. I checked the network configuration file
1 |
vi /etc/sysconfig/network-scripts/ifcfg-eth0 |
That had the following content
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
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
1 |
BOOTPROTO=dhcp |
Replace with
1 |
BOOTPROTO=static |
Also added following 2 entry
1 2 |
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.
1 2 3 4 5 6 |
[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
1 |
vi /etc/sysconfig/network-scripts/route-eth0 |
Add
1 2 |
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