How to setup static IP on AlmaLinux 8
To set up static IP configuration on your VPS, you have to login into Fleio.
After connecting to Fleio you can use the console to run commands
-
Login to SSH or console.
-
Make sure you are sudo
-
Edit file
/etc/cloud/cloud.cfg.d/90-almalinux-networking.cfg
and put in the following line.
network: {config:disabled}
-
Replace the content of
/etc/sysconfig/network-scripts/ifcfg-eth0
with the following lines:
BOOTPROTO=none DEVICE=eth0 ONBOOT=yes TYPE=Ethernet IPADDR=<your IPv4 address> PREFIX=<your IPv4 address prefix> GATEWAY=<your IPv4 gateway> IPV6ADDR=<your IPv6 address>/64 IPV6_DEFAULTGW=<your IPv6 gateway>
In order to get the Prefix, you can use ip a
and will receive an output like the following, where the prefix is 24:
inet 185.125.109.114/24 brd 185.125.109.255 scope global noprefixroute eth0
valid_lft forever preferred_lft forever
In order to get the Gateway, you can use ip r
and will receive an output like the following, where the gateway is 185.125.109.1:
default via 185.125.109.1 dev eth0 proto static metric 100
185.125.109.0/24 dev eth0 proto kernel scope link src 185.125.109.114 metric 100
-
Restart network using the commands or reboot
You can also runsystemctl disable dhclient6.service ifdown eth0 ifup eth0
systemctl restart NetworkManager
-
To verify your network configuration, use the following command:
ip a
Configuration for more IPs in your instance.
If you want to configure multiple IPs in your instance, we need to create another cfg file.
In default configuration we have ifcfg-eth0 and we have to create file with a different name like ifcfg-eth0:1 using the following command:
vim /etc/sysconfig/network-scripts/ifcfg-eth0:1
Note We can choose eth0:1, eth0:2, eth0:3, and so on, depending on how many IPs we want to configure.
BOOTPROTO=none
DEFROUTE=yes
DEVICE=eth0:1
GATEWAY=<your IPv4 gateway>
IPADDR=<your IPv4 address>
PREFIX=<Your IPv4 prefix>
IPV6ADDR=<your IPv6 address/64>
IPV6INIT=yes
IPV6_DEFAULTGW=<your IPv6 gateway>
ONBOOT=yes
STARTMODE=auto
TYPE=Ethernet
USERCTL=no
In order to get the Prefix, you can use ip a
and will receive an output like the following, where the prefix is 24:
inet 185.125.109.114/24 brd 185.125.109.255 scope global noprefixroute eth0
valid_lft forever preferred_lft forever
In order to get the Gateway, you can use ip r
and will receive an output like the following, where the gateway is 185.125.109.1:
default via 185.125.109.1 dev eth0 proto static metric 100
185.125.109.0/24 dev eth0 proto kernel scope link src 185.125.109.114 metric 100
After the configuration is done, you have to restart network:
ifdown [file configuration] (ifdown eth0:1)
ifup [file configuration] (ifup eth0:1)
You can also run
systemctl restart NetworkManager
To verify your network configuration, use the following command:
ip a