Adding public IPv4 and IPv6 addresses to a VPS or migrated Cloud Server (Rocky Linux 8 and AlmaLinux 8)
Please use the “Print” function at the bottom of the page to create a PDF.
For Linux VPS and migrated Cloud Servers with AlmaLinux 8 or Rocky Linux 8, which are managed in the Cloud Panel
This article explains how to add additional public IPv4 addresses to a VPS or a migrated Cloud Server with AlmaLinux 8 or RockyLinux 8 installed.
If you assign an additional public IPv4 address to a VPS or a migrated Cloud Server, you must adjust the network configuration manually. If you assign one or more IPv6 addresses to a VPS or a migrated Cloud Server, these will be configured automatically after the server is restarted.
Note
Instructions on how to establish an encrypted connection to your server are listed in the following articles:
Establishing an SSH connection to your Linux server on a computer with Microsoft Windows
Establishing an SSH connection to your Linux server on a Linux computer
How to configure additional public IPv4 addresses in Rocky Linux 8 and AlmaLinux 8:
Requirements
- You have assigned one or more additional, public IPv4 addresses to your server at Cloud Panel.
- You have logged in to the server as an administrator.
- You have noted the IPv4 addresses of the server.
Determine network interface
Determine the file name of the network interface. To do this, enter the following command:
[root@localhost ~]# ip addr
In the following example, the network interface eth0 is used:
[root@localhost ~]# ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether 02:01:ef:af:de:4f brd ff:ff:ff:ff:ff:ff:ff
altname enp0s6
altname ens6
inet 82.165.34.29/32 scope global dynamic noprefixroute eth0
valid_lft 582sec preferred_lft 582sec
inet6 2a02:247a:21f:9c00::1/128 scope global dynamic noprefixroute
valid_lft 3685sec preferred_lft 2685sec
inet6 fe80::1:efff:feaf:de4f/64 scope link noprefixroute
valid_lft forever preferred_lft forever
Show DNS server
To display the DNS servers used, enter the following command:
[root@localhost ~]# cat /etc/resolv.conf
The DNS servers used are then displayed in the nameserver entry. Example:
[root@localhost ~]# cat /etc/resolv.conf
# Generated by NetworkManager
nameserver 212.227.123.16
nameserver 212.227.123.17- Make a note of the DNS servers.
Show gateway for IPv4
To display the default gateway of the active interface, enter the following command:
IPv4:
[root@localhost ~]# ip route show default
This command displays the routing table. The default gateway is listed in the line beginning with default. Example:
[root@localhost ~]# default via 82.165.34.1 dev eth0 proto dhcp src 82.165.34.32 metric 100
Add IPv4 and IPv6 addresses
Open the file /etc/sysconfig/network-scripts/ifcfg-eth0 with the vi editor.
[root@localhost ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth0
Notes
- The vi editor has an insert mode and a command mode. You can call up insert mode with the [i] key. In this mode, the characters entered are immediately inserted into the text. To call up command mode, press [ESC]. If you use command mode, your keyboard input is interpreted as a command.
- To exit vi and save the file, enter the command :wq and then press Enter.
Replace the existing entries with the following information:
NAME=Public_NAME_OF_NETWORK_INTERFACE
TYPE=Ethernet
DEVICE=NAME_OF_NETWORK_INTERFACE
ONBOOT=yes
BOOTPROTO=none
BOOTPROTOv6="dhcp"
IPADDR=MAIN_IPV4_ADDRESS
PREFIX=32
GATEWAY=IPV4_GATEWAY
DNS1=DNS_SERVER_1
DNS2=DNS_SERVER_2
IPV6INIT=yes
IPV6_FAILURE_FATAL=no
IPV6_AUTOCONF=yes
DHCPV6C=yes- Replace the placeholder NAME_OF_NETWORK_INTERFACE in all places with the name of the network interface you have determined.
- Replace the placeholder in the IPADDR line with the main IPv4 address.
- For DNS1 and DNS2, enter the DNS servers that you have noted.
To configure the additional IPv4 address(es), add the following entry(s):
IPADDR1=ADDITIONAL_IPV4_ADDRESS
PREFIX1=32
IPADDR2=ADDITIONAL_IPV4_ADDRESS
PREFIX2=32
IPADDRN=ADDITIONAL_IPV4_ADDRESS
PREFIXN=32Replace the ADDITIONAL_IPV4_ADDRESS part with the desired additional IPv4 address.
The following example shows a complete entry that is used to configure the main IPv4 address and an additional IPv4 address.
NAME=Public_eth0
TYPE=Ethernet
DEVICE=eth0
ONBOOT=yes
BOOTPROTO=none
BOOTPROTOv6="dhcp"
IPADDR=82.165.34.29
PREFIX=32
IPADDR1=85.215.75.125
PREFIX1=32
GATEWAY=82.165.34.1
DNS1=212.227.123.16
DNS2=212.227.123.17
IPV6INIT=yes
IPV6_FAILURE_FATAL=no
IPV6_AUTOCONF=yes
DHCPV6C=yesTo exit vi and save the file, enter the following command and then press Enter:
:wq
To restart the server, enter the following command:
[root@localhost ~]# systemctl reboot
- Log in to the server again.
To check whether the desired IPv4 addresses have been configured correctly, enter the following command:
[root@localhost ~]# ip addr show
Note
If the server is no longer accessible due to a configuration error, you can log in to the server via the remote console and correct the configuration.