Adding a public IPv4 addresses to a VPS (Debian 10)
Please use the “Print” function at the bottom of the page to create a PDF.
For VPS managed in the Cloud Panel
This article explains how to add additional, public IPv4 addresses on a VPS that has Debian 10 installed.
Attention
These instructions are only valid for the VPS.
These instructions are valid only for the VPS. How to add IPv4 addresses on a VPS running Debian 12 is described in the following article:
Adding Public IPv4 Addresses on a VPS (Ubuntu 20.04, 22.04, and Debian 12)
How to add IPv4 addresses and IPv6 addresses on a Dedicated Server is described in the following articles:
Adding a Public IPv4 Address on a Dedicated Server (Ubuntu 18.04 and Debian 9)
Adding a Public IPv4 Address on a Dedicated Server (Debian 10)
Adding a Public IPv6 Address on a Dedicated Server (Ubuntu 18.04 and Debian 9)
Adding a Public IPv6 Address on a Dedicated Server (Debian 10)
How to configure additional, public IPv4 addresses in Debian 10:
Requirements
You assigned an additional, public IPv4 address to your server in the Cloud Panel.
You logged in to the server.
You made a note of the IPv4 addresses of the server.
Displaying the network interface
To determine the filename of the network interface, enter the following command:
root@debian:~# ip addr
In this example, the name of the network interface is ens6:
root@debian:~# 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: ens6: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 02:01:16:8b:79:11 brd ff:ff:ff:ff:ff:ff
inet 82.165.34.29/32 brd 82.165.34.29 scope global dynamic ens6
valid_lft 517sec preferred_lft 517sec
inet6 fe80::1:16ff:fe8b:7911/64 scope link
valid_lft forever preferred_lft forever
Make a note of the name of the network interface and the network mask. This is listed on the line that contains the main IP address. The network mask is specified in the CIDR notation. The notation 195.20.234.94/32 corresponds to the address 195.20.234.94 with the network mask 255.255.255.255.
For more information about CIDR notation, see the following article:
Displaying the gateway for IPv4
To display the default gateway of the active interface, enter the following command:
root@debian:~# ip route show | grep 'default'
Note the IP addresses of the gateways. These are listed directly after the default via part. Example:
IPv4 gatewayroot@debian:~# ip route show | grep 'default'
default via 82.165.34.1 dev ens6
Adding an IPv4 address
Create the configuration file /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg. To do this, enter the following command:
root@debian:~# vi /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg
Add the following entry:
network: {config: disabled}
Please 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.
To exit vi and save the file, type the command :wq and then press Enter.
Open the /etc/network/interfaces file with the vi editor. Type the following command:
[root@localhost ~]# vi /etc/network/interfaces
Replace the existing entries with the following information:
auto lo INTERFACE_DEVICE
iface lo inet loopback
allow-hotplug INTERFACE_DEVICE
iface INTERFACE_DEVICE inet static
address MAIN IPv4 ADDRESS/32
netmask NETWORK MASK
gateway STANDARD GATEWAY OF ACTIVE INTERFACE
auto INTERFACE_DEVICE:0
allow-hotplug INTERFACE_DEVICE:0
iface INTERFACE_DEVICE:0 inet static
address ADDITIONAL-IPv4-ADRESS/32Example:
auto lo ens6
iface lo inet loopback
allow-hotplug ens6
iface ens6 inet static
address 82.165.34.29/32
netmask 255.255.255.255
gateway 82.165.34.1
auto ens6:0
allow-hotplug ens6:0
iface ens6:0 inet static
address 195.20.236.17/32To exit vi and save the file, type the command :wq and then press Enter.
Perform a reboot of the server.
To verify that the additional IP address is configured correctly, type the following command:
root@debian:~# ip addr
The additional public IPv4 address is then displayed. Example:
root@A34C022:~# 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 ac:1f:6b:9b:22:44 brd ff:ff:ff:ff:ff:ff
inet 217.160.244.147/32 scope global dynamic eth0
valid_lft 42230sec preferred_lft 42230sec
inet 82.165.248.54/32 brd 82.165.248.255 scope global eth0:0
valid_lft forever preferred_lft forever
inet6 2001:8d8:1800:1a1::1/128 scope global
valid_lft forever preferred_lft forever
inet6 fe80::ae1f:6bff:fe9b:2244/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 ac:1f:6b:9b:22:45 brd ff:ff:ff:ff:ff:ff
Please Note
If the server becomes unreachable due to a configuration error, you can log in to the server using the remote console and correct the configuration.