Add public IPv4 and IPv6 addresses to a Dedicated Server (Rocky Linux 8 and AlmaLinux 8)
Please use the “Print” function at the bottom of the page to create a PDF.
For Dedicated Servers which are managed in the Cloud Panel
This article explains how to add additional public IPv4 and IPv6 addresses to a Dedicated Server with Rocky Linux 8 or AlmaLinux 8 installed.
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 and IPv6 addresses in Rocky Linux 8 and AlmaLinux 8:
Requirements
- You have assigned one or more additional public IPv4 and/or IPv6 addresses to your server in the Cloud Panel.
- You have logged in to the server as an administrator.
- You have noted the IPv4 addresses and IPv6 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@7969D9F ~]# 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 mq state UP group default qlen 1000
link/ether a8:a1:59:c0:87:4c brd ff:ff:ff:ff:ff:ff:ff
altname enp35s0
inet 217.160.44.181/32 scope global dynamic noprefixroute eth0
valid_lft 39587sec preferred_lft 39587sec
inet6 2001:8d8:1800:832d::1/128 scope global dynamic noprefixroute
valid_lft 3449sec preferred_lft 3449sec
inet6 fe80::4ae7:2b6c:61da:4c5a/64 scope link noprefixroute
valid_lft forever preferred_lft forever
3: eth1: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc mq state DOWN group default qlen 1000
link/ether a8:a1:59:c0:87:4d brd ff:ff:ff:ff:ff:ff:ff
altname enp36s0
4: usb0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UNKNOWN group default qlen 1000
link/ether 6a:79:e7:f6:66:64 brd ff:ff:ff:ff:ff:ff:ff
altname enp3s0f0u14u3c2
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.
Display gateway for IPv4 and IPv6
To display the default gateway of the active interface, enter the following commands:
IPv4:
[root@localhost ~]# ip route show | grep 'default'
IPv6:
[root@localhost ~]# ip -6 route show | grep 'default'
or
[root@localhost ~]# ip -6 route show default
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
IPADDR=PRIMARY-IPV4-ADDRESS
PREFIX=32
GATEWAY=10.255.255.1
DNS1=DNS-SERVER 1
DNS2=DNS-SERVER 2
IPV6INIT=yes
IPV6_AUTOCONF=no
DHCPV6C=no
IPV6ADDR=PRIMARY-IPV6-ADDRESS/64
IPV6_DEFAULTGW=fe80::1%NAME_OF_NETWORK_INTERFACE- Replace the placeholder NAME_OF_NETWORK_INTERFACE in all places with 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.
- Replace the placeholder in the IPV6ADDR line with the main IPv6 address.
- Enter the IPv6 gateway in IPV6_DEFAULTGW and replace the placeholder NAME_OF_NETWORK_INTERFACE with the determined network interface.
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=32- Replace the ADDITIONAL_IPV4_ADDRESS part with the desired additional IPv4 address.
To configure additional IPv6 addresses, add the following entry:
IPV6ADDR_SECONDARIES=ADDITIONAL_IPV6-ADDRESS/64
- Replace the ADDITIONAL_IPV6_ADDRESS part with the desired additional IPv6 address. To configure several additional IPv6 addresses, enter them one after the other. Use a space to separate the IPv6 addresses.
The following example shows a complete entry that is used to configure the main IPv4 and the main IPv6 address as well as an additional IPv4 and an additional IPv6 address.
NAME=Public_eth0
TYPE=Ethernet
DEVICE=eth0
ONBOOT=yes
BOOTPROTO=none
IPADDR=217.160.44.181
PREFIX=32
IPADDR1=217.160.45.196
PREFIX1=32
GATEWAY=10.255.255.1
DNS1=212.227.123.16
DNS2=212.227.123.17
IPV6INIT=yes
IPV6_AUTOCONF=no
DHCPV6C=no
IPV6ADDR=2001:8d8:1800:832d::1/64
IPV6ADDR_SECONDARIES=2001:8d8:1800:832d::2/64
IPV6_DEFAULTGW=fe80::1%eth0To 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 and IPv6 addresses have been configured correctly, enter the command ip addr show:
[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 using the Rescue System and correct the configuration.