Adding Public IPv4 and IPv6 Addresses on a Dedicated Server (Ubuntu 20.04/22.04 or Debian 11/12)
Please use the “Print” function at the bottom of the page to create a PDF.
This article explains how to add additional public IPv4 and IPv6 addresses on a Dedicated Server running Ubuntu 20.04, 22.04, Debian 11 and 12.
Attention
These instructions are valid only for the Dedicated Server. How to add IPv4 addresses and IPv6 addresses on a Cloud Server is described in the following article:
Configuring Public IPv4 and IPv6 Addresses on a Cloud Server or vServer with netplan (Ubuntu 22.04)
How to configure an additional public IPv4 address in Ubuntu 20.04, 22.04, Debian 11 and 12:
Requirements
You have assigned an additional, public IPv4 address to your server in the Cloud Panel.
You have logged in to the server as an administrator.
Determine the file name of the network interface. To do this, enter the following command:
[root@localhost ~]# ip addr
Make a note of the network interface name.
Open the /etc/network/interfaces file with the vi editor.
[root@localhost ~]# vi /etc/network/interfaces
Note
The vi editor has an insert mode and a command mode. You can enter the insert mode by pressing the [i] key. In this mode, the entered characters are immediately inserted into the text. To enter the command mode, press [ESC] afterwards. When you use the command mode, your keyboard inputs are interpreted as a command.
Replace the existing entries with the information below:
source /etc/network/interfaces.d/*
# The loopback network interface
auto lo
iface lo inet loopback
allow-hotplug NETWORKINTERFACE
iface NETWORKINTERFACE inet static
address MAIN-IPv4-ADDRESS/32
netmask 255.255.255.255
gateway 10.255.255.1
auto NETWORKINTERFACE:0
allow-hotplug NETWORKINTERFACE:0
iface NETWORKINTERFACE:0 inet static
address ADDITIONAL-IPv4-ADDRESS/32
iface NETWORKINTERFACE inet6 manual
iface NETWORKINTERFACE inet6 static
address MAIN-IPv6-ADDRESS
netmask 64
iface NETWORKINTERFACE inet6 static
address ADDITIONAL-IPv6-ADDRESS
netmask 64Example:
source /etc/network/interfaces.d/*
# The loopback network interface
auto lo
iface lo inet loopback
allow-hotplug eth0
iface eth0 inet static
address 85.215.105.86/32
netmask 255.255.255.255
gateway 10.255.255.1
auto eth0:0
allow-hotplug eth0:0
iface eth0:0 inet static
address 85.215.109.181/32
iface eth0 inet6 manual
iface eth0 inet6 static
address 2a01:239:0:805d::1
netmask 64
iface eth0 inet6 static
address 2a01:239:0:805d::2
netmask 64Replace the wildcards and, if necessary, the network interface if it differs.
To exit vi and save the file, type the command :wq and then press Enter.
To reboot the server, type the following command:
[root@localhost ~]# systemctl reboot
To verify that the additional IPv4 and IPv6 addresses have been added, type the following command:
[root@localhost ~]# ip addr
The additional public IPv4 and IPv6 addresses are then displayed. Example:
root@FC01C67:~# 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:91:f6:04 brd ff:ff:ff:ff:ff:ff
altname eno1np0
altname enp198s0f0np0
inet 85.215.105.86/32 brd 85.215.105.86 scope global eth0
valid_lft forever preferred_lft forever
inet 85.215.109.181/32 brd 85.215.109.181 scope global eth0:0
valid_lft forever preferred_lft forever
inet6 2a01:239:0:805d::3/64 scope global
valid_lft forever preferred_lft forever
inet6 2a01:239:0:805d::2/64 scope global
valid_lft forever preferred_lft forever
inet6 2a01:239:0:805d::1/64 scope global
valid_lft forever preferred_lft forever
inet6 fe80::3eec:efff:fe91:f604/64 scope link
valid_lft forever preferred_lft forever
3: eth1: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
link/ether 3c:ec:ef:91:f6:05 brd ff:ff:ff:ff:ff:ff
altname eno2np1
altname enp198s0f1np1