For Cloud Servers and migrated Cloud Servers with Debian 11 without Netplan, which are managed in the Cloud Panel

This article explains how to add additional, public IPv4 addresses on a Cloud Server or on a migrated Cloud Server on which Debian 11 is installed.

Note

How you can establish an encrypted network connection to your server using Secure Shell (SSH) is explained 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 Ubuntu 18.04, Ubuntu 20.04, Debian 10, 11 or Debian 12:

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.

Determine network interface

To determine the file name of the network interface, enter the following command:

[root@localhost ~]# ip addr

Example:

[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: ens192: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether 00:50:56:2b:2c:68 brd ff:ff:ff:ff:ff:ff:ff
inet 212.227.209.26/32 brd 212.227.209.26 scope global dynamic ens192
valid_lft 33737sec preferred_lft 33737sec
inet6 fe80::250:56ff:fe2b:2c68/64 scope link
valid_lft forever preferred_lft forever

In this example, the name of the network interface is ens192.

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'

  • Note the IP addresses of the gateways. These are listed directly after the default via part. Examples:

    IPv4 Gateway

    [root@localhost ~]# /etc/netplan# ip route show | grep 'default'
    default via 10.255.255.1 dev ens192 proto dhcp src 82.165.247.234 metric 100


    IPv6 gateway

    Cloud Server

    [root@localhost ~]# /etc/netplan# ip -6 route show | grep 'default'

    Example:

    [root@localhost ~]# /etc/netplan# ip -6 route show | grep 'default'
    default via fe80::1 dev ens192 proto ra metric 100 expires 4sec pref high

    In this example, fe80::1 is the IPv6 gateway.

    Migrated Cloud Server:

    root@debian:~# ip -6 route show

    Example:

    root@debian:~# ip -6 route show
    ::1 dev lo proto kernel metric 256 pref medium
    fe80::/64 dev ens6 proto kernel metric 256 pref medium

Show default DNS server (migrated Cloud Server)

If the DNS servers used are not displayed after entering the command, enter the following command:

[root@localhost ~]# cat /var/lib/dhcp/dhclient.NAME_OF_NETWORK_INTERFACE.leases

Example:

cat /var/lib/dhcp/dhclient.ens6.leases

The DNS servers used are then displayed. Example:

lease {
interface "ens6";
fixed-address 74.208.61.32;
option subnet-mask 255.255.255.255;
option routers 74.208.61.1;
option dhcp-lease-time 600;
option dhcp-message-type 5;
option domain-name-servers 212.227.123.16,212.227.123.17;
option dhcp-server-identifier 169.254.0.2;
option host-name "my-server-1";
renew 5 2024/11/15 12:14:51;
rebind 5 2024/11/15 12:19:10;
expire 5 2024/11/15 12:20:25;

Add IPv4 and IPv6 addresses

  • Create a .network file for your network interface using the vi editor. Example:

    [root@localhost ~]# vi /etc/systemd/network/10-ens6.network

  • Insert the following information and replace the placeholders:

    [Match]
    Name=NETWORK_INTERFACE

    [Network]
    Address=MAIN_IPV4_ADDRESS/24
    Gateway=IPV4-GATEWAY
    DNS=IP_ADDRESS_OF_NAMESERVER_1

    # Additional IPv4 address
    Address=ADDITIONAL_IPV4_ADDRESS/24

    # IPv6 configuration
    Address=MAIN_IPV6_ADDRESS/64
    Gateway=IPV6_GATEWAY

    # Additional IPv6 address
    Address=ADDITIONAL_IPV6_ADDRESS/64

    Example:

    [Match] 
    Name=ens6

    [Network]
    Address=74.208.61.32/24
    Gateway=74.208.61.1
    DNS=212.227.123.16,212.227.123.1

    # Additional IPv4 address
    Address=74.208.98.26/24

    # IPv6 configuration
    Address=2001:db8::c0a8:1/64
    Gateway=fe80::1

    # Additional IPv6 address
    Address=2001:db8::c0a8:2/64

Edit hosts file

  • To determine the correct hostname, enter the following command:

    [root@localhost ~]# hostname

  • Open the hosts file with the vi editor. To do this, enter the following command:

    [root@localhost ~]# vi /etc/hosts

  • Insert the following line with the correct hostname:

    127.0.1.1 HOSTNAME

    Example:

    127.0.1.1 debian

  • Press the [ESC] key.
  • To save the change, enter the command :wq.

Restart server and check configuration

  • To restart systemd-networkd, enter the following command:

    [root@localhost ~]# sudo systemctl restart systemd-networkd

  • To check whether the desired IPv4 and IPv6 addresses have been configured correctly, enter the command ip addr show:

    [root@localhost ~]# ip addr

Note

If the server is no longer accessible due to a configuration error, you can log in to the server using the KVM console and correct the configuration. You can find instructions on how to do this in the following article:

Using the KVM console for server access