Valid for VPS+ and migrated Cloud Servers.

This article explains how to configure network settings in Ubuntu 24.04, Ubuntu 26.04, Debian 12 with Netplan, and Debian 13 to use a VPS+ or a migrated Cloud Server within a private network.

In a private network, servers communicate via local IP addresses that are not routed on the internet. To use a server within a private network, the first step is to assign the server in the Cloud Panel to the desired private network. Once the server has been assigned to the desired private network, an additional, unconfigured network interface will be available on it. You must configure this network interface on the server.

Requirements

  • You have created a private network.
  • You have assigned the required server to the private network in the Cloud Panel.
  • You have logged in to the server as an administrator.
  • You have noted down the server’s IPv4 and IPv6 addresses.

Notes

Instructions on how to establish an encrypted network connection to your server using your computer are provided in the following articles:

Setting up an SSH connection to your Linux server from a Microsoft Windows computer

Setting up an SSH connection to your Linux server from a Linux computer

Please Note

With older Debian 12 images, you may need to configure the network using the /etc/network/interfaces file. You can find instructions in the following article: Adding public IPv4 and IPv6 addresses to a server (Debian 12)

To configure the network interface for a private network, complete the following:

Check whether netplan is being used for the network configuration

This step is only required for Debian 12: To check whether your server is already using Netplan for network configuration, enter the following commands:

  • Change to the /etc/netplan directory.

    [root@localhost ~]# cd /etc/netplan

  • Check whether there is already a configuration file in this directory. To do this, enter the following command:

    [root@localhost ~]# ls

  • Make a note of the name of the configuration file.

Identify the network interface

Determine the name of the network interface. To do this, 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 noprefixroute
     valid_lft forever preferred_lft forever
2: ens6: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
  link/ether 02:01:37:83:4d:66 brd ff:ff:ff:ff:ff:ff
  altname enp0s6
  inet 85.215.124.167/32 metric 100 scope global dynamic ens6
     valid_lft 374sec preferred_lft 374sec
  inet6 2a02:2479:7:e00::/128 scope global dynamic noprefixroute
     valid_lft 3079sec preferred_lft 2079sec
  inet6 2a02:2479:7:e00::1/128 scope global dynamic noprefixroute
     valid_lft 3079sec preferred_lft 2079sec
  inet6 fe80::1:37ff:fe83:4d66/64 scope link
     valid_lft forever preferred_lft forever
3: ens7: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
  link/ether 02:01:bb:ea:2f:f9 brd ff:ff:ff:ff:ff:ff
  altname enp0s7
  inet 10.7.226.13/24 metric 100 brd 10.7.226.255 scope global dynamic ens7
     valid_lft 377sec preferred_lft 377sec
  inet6 fe80::1:bbff:feea:2ff9/64 scope link
     valid_lft forever preferred_lft forever

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

Display the gateway for IPv4 and IPv6

  • To display the default gateway for the active interface, enter the following command:

    IPv4:

    [root@localhost ~]# ip route show | grep 'default'


    IPv6:

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

  • Make a note of the IP addresses of the gateways. These are listed immediately after the ‘default via’ section. Example:

    IPv4 gateway

    [root@localhost ~]# ip route show | grep ‘default’ default via 195.20.234.1 dev ens6 proto dhcp src 195.20.234.94 metric 100


    IPv6 gateway

    [root@localhost ~]# 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.

Display the default DNS servers

  • To view the DNS servers being used, enter the following command:

    [root@localhost ~]# resolvectl --no-pager | grep Server

  • The DNS servers in use will then be displayed at the end of the output. Example:

    [root@localhost ~]# resolvectl --no-pager | grep Server
    Current DNS Server: 212.227.123.16
           DNS Servers: 212.227.123.16 212.227.123.17

  • Make a note of the DNS servers.

Configure the network interface

  • Check whether there is already a configuration file in this directory. To do this, enter the following commands:

    [root@localhost ~]# cd /etc/netplan

    [root@localhost ~]# ls /etc/netplan

  • If there is a configuration file in this directory, rename it. To do this, enter the following command and adapt the placeholders.

    [root@localhost ~]# mv OLD_CONFIGURATION_FILE.yaml OLD_CONFIGURATION_FILE.yaml.old

    Example:

    [root@localhost ~]# mv 50-cloud-init.yaml 50-cloud-init.yaml.old

Please Note

If the file 00-Public_network.yaml is present in the directory, do not rename it, as this file is required for the public network.

  • Create the file /etc/netplan/01-netcfg.yaml using the vi editor. To do this, enter the following command:

    [root@localhost ~]# vi /etc/netplan/01-netcfg.yaml

Note

The vi editor has an insert mode and a command mode. You can enter insert mode by pressing the [i] key. In this mode, the characters you type are inserted into the text immediately. To switch to command mode, press [ESC] afterwards. When you are in command mode, your keystrokes are interpreted as commands.

Caution

Indentation is part of the YAML format’s syntax. Therefore, please ensure that it is used correctly. Otherwise, the configuration may not be applied correctly and the server may no longer be accessible. Always use the space bar for indentation.

  • To use a server on a private network, you must manually assign an IP address during the manual configuration of the network interface, so that the server can be accessed on the private network. This IP address cannot be routed to public networks. To configure the desired static IP address, enter the following information:

    network:
    version: 2
    renderer: networkd
    ethernets:
       NETWORK_INTERFACE:
        addresses:
          - MAIN_IPV4_ADDRESS/32
          - ADDITIONAL_IPV4_ADDRESS/32
          - MAIN_IPV6_ADDRESS/64
          - ADDITIONAL_IPV6_ADDRESS_1/64
        nameservers:
          addresses:
            - NAMESERVER_1_IP_ADDRESS
            - NAMESERVER_2_IP_ADDRESS
        routes:
          - on-link: true
            to: default
            via: DEFAULT_GATEWAY_OF_THE_ACTIVE_INTERFACE
       PRIVATE_NETWORK_INTERFACE:
        dhcp4: no
        addresses:
          - SERVER_IP_ADDRESS_IN_PRIVATE_NETWORK/24
        nameservers:
          addresses:
            - NAMESERVER_1_IP_ADDRESS
            - NAMESERVER_2_IP_ADDRESS

    Example:

    network:
    version: 2
    renderer: networkd
    ethernets:
      ens6:
        addresses:
          - 85.215.124.167/32
          - 212.227.250.35/32
          - 2a02:2479:7:e00::1/64
          - 2a02:2479:7:e00::/64
        nameservers:
          addresses:
            - 212.227.123.16
            - 212.227.123.17
        routes:
          - on-link: true
            to: default
            via: 10.255.255.1
      ens7:
        dhcp4: no
        addresses:
          - 192.168.1.2/24
        nameservers:
          addresses:
            - 212.227.123.16
            - 212.227.123.17

  • Press the [ESC] key to exit edit mode.
  • To exit vi and save the file, type the command :wq and then press the Enter key.
  • To change the permissions of the new configuration file so that it can only be read and modified by the root account, adapt the following command and then enter it:

    [root@localhost ~]# sudo chmod 600 /etc/netplan/CONFIGURATION_FILE.yaml

    Example:

    [root@localhost ~]# sudo chmod 600 /etc/netplan/01-netcfg.yaml

  • To check the configuration file, enter the following command:

    [root@localhost ~]# netplan --debug apply

The server can now be accessed via the private network.

Check the network configuration

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

    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 assigned to the private network. Example:

    root@localhost:~# ping -c 1 192.168.1.3
    PING 192.168.1.3 (192.168.1.3) 56(84) bytes of data.
    64 bytes from 192.168.1.3: icmp_seq=1 ttl=64 time=0.176 ms
    64 bytes from 192.168.1.3: icmp_seq=2 ttl=64 time=0.151 ms
    64 bytes from 192.168.1.3: 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 being sent to the server, the network interface for the private network has been successfully configured.

Notes

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

Using the remote console to access the server