Add public IPv4 and IPv6 addresses to a Dedicated Server (Rocky Linux 9 and AlmaLinux 9)
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 9 or AlmaLinux 9 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 9 or AlmaLinux 9:
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.
- You have noted the IPv4 addresses and IPv6 addresses of the server.
Create a backup copy of the existing profile
- Log in to the server as an administrator.
Open the directory /etc/NetworkManager/system-connections by entering the following command:
[root@localhost ~]# cd /etc/NetworkManager/system-connections
To display the files located in the directory, enter the following command:
[root@localhost ~]# ls
To create a backup copy of the network profile, adapt the following command. Replace the placeholders and then enter the command:
sudo cp /etc/NetworkManager/system-connections/CONNECTION_NAME.nmconnection /etc/NetworkManager/system-connections/CONNECTION_NAME.backup
Example:sudo cp /etc/NetworkManager/system-connections/eth0.nmconnection /etc/NetworkManager/system-connections/eth0.nmconnection.backup
Display 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@5B9B34D ~]# 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 3c:ec:ef:88:fe:ee brd ff:ff:ff:ff:ff:ff:ff
altname eno1np0
altname enp198s0f0np0
inet 82.165.19.97/32 scope global dynamic noprefixroute eth0
valid_lft 13527sec preferred_lft 13527sec
inet6 fe80::3eec:efff:fe88:feee/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 3c:ec:ef:88:fe:ef brd ff:ff:ff:ff:ff:ff:ff
altname eno2np1
altname enp198s0f1np1
Determine connection name
To display detailed information on the network interface, enter the following command:
nmcli device show NETWORK_INTERFACE_NAME
Example:
nmcli device show eth0
- Make a note of the connection name. This is listed in the GENERAL.CONNECTION: entry.
- To exit the display, press the q button.
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@5B9B34D ~]# cat /etc/resolv.conf # Generated by NetworkManager
search online-server.cloud
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
To specify the main IPv4 address, replace the placeholders in the following command. Then enter the command:
[root@localhost ~]# nmcli connection modify "CONNECTION_NAME" ipv4.addresses PRIMARY_IPV4_ADDRESS/32
Example:
[root@localhost ~]# nmcli connection modify "eth0" ipv4.addresses 217.160.11.143/32
To specify the main IPv6 address, replace the placeholders in the following command and then enter it:
[root@localhost ~]# nmcli connection modify "CONNECTION_NAME" ipv6.addresses PRIMARY_IPV6_ADDRESS/64
Example:
[root@localhost ~]# nmcli connection modify "eth0" ipv6.addresses 2001:8d8:1801:83bd::1/64
To specify the IPv4 gateway, replace the placeholder IPv4-GATEWAY_ADDRESS in the following command with the IPv4 gateway that you have determined. In addition, replace the placeholder CONNECTION_NAME and then enter the command:
[root@localhost ~]# nmcli connection modify "CONNECTION_NAME" ipv4.gateway IPv4-GATEWAY_ADDRESS
Example:
[root@localhost ~]# nmcli connection modify "eth0" ipv4.gateway 10.255.255.1
To specify the IPv6 gateway, replace the placeholder IPv6-GATEWAY_ADDRESS in the following command with the IPv6 gateway that you have determined. In addition, replace the placeholder CONNECTION_NAME and then enter the command:
[root@localhost ~]# nmcli connection modify "CONNECTION_NAME" ipv6.gateway IPv6-GATEWAY_ADDRESS
Example:
[root@localhost ~]# nmcli connection modify "eth0" ipv6.gateway fe80::250:56ff:fea8:4cef
To specify the DNS servers, replace the DNS_SERVER placeholder in the following command with the DNS servers determined. Separate them with a space and add inverted commas at the beginning and end. In addition, replace the placeholder CONNECTION_NAME and then enter the command:
[root@localhost ~]# nmcli connection modify "CONNECTION_NAME" ipv4.dns DNS_SERVER
Examples:
[root@localhost ~]# nmcli connection modify "eth0" ipv4.dns 212.227.123.16
[root@localhost ~]# nmcli connection modify "eth0" ipv4.dns "212.227.123.16 212.227.123.17"
To change the assignment of IPv4 addresses from automatic (DHCP) to manual, replace the placeholder CONNECTION_NAME in the following command. Then enter the command:
[root@localhost ~]# nmcli connection modify "CONNECTION_NAME" ipv4.method manual
Example:
[root@localhost ~]# nmcli connection modify "eth0" ipv4.method manual
To change the assignment of IPv6 addresses from automatic (DHCP) to manual, replace the placeholder CONNECTION_NAME in the following command. Then enter the command:
[root@localhost ~]# nmcli connection modify "CONNECTION_NAME" ipv6.method manual
Example:
[root@localhost ~]# nmcli connection modify "eth0" ipv6.method manual
To add the additional IPv4 address to the network configuration, replace the placeholders CONNECTION_NAME and ADDITIONAL_IPV4_ADDRESS in the following command. Then enter the command:
[root@localhost ~]# nmcli con mod "CONNECTION_NAME" +ipv4.addresses "ADDITIONAL_IPV4_ADDRESS/32"
Example
[root@localhost ~]# nmcli con mod "eth0" +ipv4.addresses "82.165.236.99/32"
To add the additional IPv6 address to the network configuration, replace the placeholders CONNECTION_NAME and ADDITIONAL_IPV6_ADDRESS in the following command. Then enter the command:
[root@localhost ~]# nmcli con mod "CONNECTION_NAME" +ipv6.addresses "ADDITIONAL_IPV6_ADDRESS/64"
Example:
[root@localhost ~]# nmcli con mod "eth0" +ipv6.addresses "2001:8d8:1801:83bd::2/64"
To restart the network interface, customise the following command and enter it:
[root@localhost ~]# nmcli connection down "CONNECTION_NAME"; nmcli connection up "CONNECTION_NAME"
Example:
[root@localhost ~]# nmcli connection down "eth0"; nmcli connection up "eth0"
To check the new settings, enter the following command:
[root@localhost ~]# ip address 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.