For migrated Cloud Servers

This article shows you how to configure the private network settings for migrated Cloud Servers with Debian 11.

In a private network, the servers communicate via local IPs that are not routed on the Internet. To be able to use a server in a private network, you must first assign the server in the Cloud Panel to the desired private network. As soon as the server has been assigned to the desired private network, an additional, unconfigured network interface is available on it. You must configure this network interface on the server. To do this, you must create the relevant configuration files under /etc/systemd/network/. To do this, proceed as follows:

Requirements
  • You have created a private network.
  • You have assigned the desired server to the private network in the Cloud Panel.
  • You have logged in to the server as an administrator.
  • You have noted the IPv4 and IPv6 addresses of the server.
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

Determine network interface

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

root@debian:~# ip addr

Example:

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:11:b9:2b:31 brd ff:ff:ff:ff:ff:ff:ff
altname enp0s6
inet 212.227.52.44/32 brd 212.227.52.44 scope global dynamic ens6
valid_lft 497sec preferred_lft 497sec
inet6 fe80::1:11ff:feb9:2b31/64 scope link
valid_lft forever preferred_lft forever
3: ens7: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 02:01:35:8c:9f:38 brd ff:ff:ff:ff:ff:ff:ff
altname enp0s7
inet 10.7.226.13/24 brd 10.7.226.255 scope global dynamic ens7
valid_lft 362sec preferred_lft 362sec
inet6 fe80::1:35ff:fe8c:9f38/64 scope link
valid_lft forever preferred_lft forever
root@debian:~#

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

Edit hosts file

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

    root@debian:~# hostname

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

    root@debian:~# 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 exit the input mode.
  • To exit vi and save the file, enter the command :wq and then press Enter.
  • Restart the hostname service. To do this, enter the following command:

    root@debian:~# sudo systemctl restart systemd-hostnamed

Check whether systemd-networkd and systemd-resolved are activated

To ensure that systemd-networkd and systemd-resolved are enabled, enter the following commands:

root@debian:~# systemctl enable systemd-networkd
root@debian:~# systemctl start systemd-networkd
root@debian:~# systemctl enable systemd-resolved
root@debian:~# systemctl start systemd-resolved

Check linking of /etc/resolv.conf

To set a symbolic link from /etc/resolv.conf to the stub resolver configuration file generated by systemd-resolved, enter the following command:

root@debian:~# ln -sf /run/systemd/resolve/stub-resolv.conf /etc/resolv.conf

Display gateway for IPv4 and IPv6

  • To display the default gateway of the active interface, enter the following commands:

    IPv4:

    root@debian:~# ip route show | grep 'default'

    IPv6:

    root@debian:~# ip -6 route show

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

    IPv4 gateway

    root@debian:~# ip route show | grep 'default' default via 10.255.255.1 dev ens192 proto dhcp src 82.165.247.234 metric 100

    IPv6 Gateway

    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

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

root@debian:~# cat /var/lib/dhcp/dhclient.NAME_OF_NETWORK_INTERFACE.leases

Example:

root@debian:~# cat /var/lib/dhcp/dhclient.ens6.leases

The DNS servers used are then displayed. Example:

root@debian:~# cat /var/lib/dhcp/dhclient.ens6.leases
default-duid "\000\001\000\001/-\016r\002\001\021\271+1";
lease {
interface "ens6";
fixed-address 212.227.52.44;
option subnet-mask 255.255.255.255;
option routers 212.227.52.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 4 2025/01/30 13:31:51;
rebind 4 2025/01/30 13:31:51;
expire 4 2025/01/30 13:31:51;
}

Configure public network for IPv4 and IPv6 addresses

  • Create a .network file with the file name 10-public.network using the vi editor. Enter the following command:

    root@debian:~# vi /etc/systemd/network/10-public.network

  • Insert the following information after replacing 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=212.227.52.44/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

  • Press the [ESC] key to exit input mode.
  • To exit vi and save the file, enter the command :wq and then press Enter.

Configure private network

  • Create a .network file with the file name 20-private.network using the vi editor. Enter the following command:

    root@debian:~# vi /etc/systemd/network/20-private.network

  • Insert the following information after replacing the placeholders:

    [Match]
    Name=NETWORK_INTERFACE

    [Network]
    Address=IPV4_ADDRESS_OF_PRIVATE_NETWORK/24

    Example:

    [Match]
    Name=ens7

    [Network]
    Address=192.168.1.2/24

  • Press the [ESC] key to exit input mode.
  • To exit vi and save the file, enter the command :wq and then press Enter.

Restart systemd-networkd services

After the configuration files have been created, the systemd-networkd services must be restarted in order to apply the new configurations. To do this, enter the following commands:

root@debian:~# systemctl restart systemd-networkd
root@debian:~# systemctl restart systemd-resolved

Check network configuration

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

    root@debian:~# ip addr show

  • To check whether the network interface for the private network has been configured correctly, send a ping to the IP address of another server that is assigned to the private network. Example:

    root@localhost:~# ping -c 1 192.168.1.3
    PING 192.168.2.1 (192.168.2.2) 56(84) bytes of data.
    64 bytes from 192.168.2.2: icmp_seq=1 ttl=64 time=0.176 ms
    64 bytes from 192.168.2.2: icmp_seq=2 ttl=64 time=0.151 ms
    64 bytes from 192.168.2.2: icmp_seq=3 ttl=64 time=0.170 ms

    --- 192.168.1.3 ping statistics ---
    3 packets transmitted, 3 received, 0% packet loss, time 2050ms
    rtt min/avg/max/mdev = 0.151/0.165/0.176/0.018 ms

If the data packets are received by the server, the network interface has been properly configured for the private network.

Note

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

Using the remote console for server access