Once you have added your VPSs to a Private Network, you will first have to set up internal IP addresses before you can make full use of them.
In the examples, the 192.168.0.0/16 range is used. However, you can choose one of the IP ranges defined in the RFC for use within private networks: 10.0.0.0/8, 172.16.0.0/12 and 192.168.0.0/16. The examples also use nano as an editor, but you are free to use your favorite editor.
This article covers various Linux OS's. For Windows, please see this article.
- Perform the steps in this article as root, or user with sudo rights.
- In case of incorrect adjustments, you can make your VPS unreachable. Make sure you also have access to your VPS using the console in the control panel (if you do this via SSH). In addition, it is strongly recommended to make a Snapshot in advance which you can fall back on.
Fast Installs
Please note: Did you use our fast installs feature for VPS and chose installation via SSH-keys, one time password, or cloud-config user data? Additional steps are required before configuring the IP address for your private network connection.
Fast Installs uses Cloud Init. Cloud Init automatically overwrites your network configuration and for this reason Clud Init, or the Cloud Init control over your network (you're free to choose either option), needs to be disabled as follows:
Step 1
Disabling Cloud Init network management
Open/create the following file:
nano /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg
Add the contents below and then save and close the file (ctrl + x > y > enter).
network: config: disabled
Disabling Cloud Init
Cloud Init is only used during the initial installation process of your VPS. As such, it doesn't hurt to disable it altogether. This can be done by creating the following empty file:
touch /etc/cloud/cloud-init.disabled
Step 2 - Ubuntu / Debian additional steps
In case of Ubuntu / Debian additional steps are recommended: In order to avoid confusion in the future, you can rename the network configuration file as made by Cloud Init to 01-netcfg.yaml using the command:
mv /etc/netplan/50-cloud-init.yaml /etc/netplan/01-netcfg.yaml
You can now proceed with the configuration of the IP address for your private network. Should Cloud Init still control your network configuration, you may additionally need to use the following command:
dpkg-reconfigure cloud-init
AlmaLinux 8 / Rocky Linux 8 / CentOS Stream 8
Step 1
Log in to your VPS using SSH or the VPS console.
Step 2
Check the name of your private network adapter. This can be done using the command:
ip a
You'll see output similar to the example below. In this example the private network adapter is called eth1 (eth0 is the public adapter).
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 fq_codel state UP group default qlen 1000
link/ether 52:54:00:bb:ae:2c brd ff:ff:ff:ff:ff:ff
inet 136.144.231.47/24 brd 136.144.231.255 scope global dynamic noprefixroute eth0
valid_lft 84992sec preferred_lft 84992sec
inet6 2a01:7c8:d005:298:5054:ff:febb:ae2c/64 scope global dynamic mngtmpaddr
valid_lft 2591969sec preferred_lft 604769sec
inet6 fe80::5054:ff:febb:ae2c/64 scope link
valid_lft forever preferred_lft forever
4: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether 52:54:00:c3:4e:be brd ff:ff:ff:ff:ff:ff
inet6 fe80::4efd:854e:cbde:1676/64 scope link noprefixroute
valid_lft forever preferred_lft forever
Step 3
Open your network configuration file, or create it if it doesn't exist:
nano /etc/sysconfig/network-scripts/ifcfg-eth1
Step 4
Add the options below / adjust the existing configuration. Replace the IP behind 'IPADDR' with the IP address that you actually want to use.
DEVICE=eth1
ONBOOT=yes
NETBOOT=yes
BOOTPROTO=static
IPADDR=192.168.1.2
NETMASK=255.255.255.0
ZONE=public
Step 5
Save your settings and close your editor (ctrl + x > y > enter).
Finally, run the following command to restart the network:
ifdown eth1 && ifup eth1
or:
systemctl restart networking
Optional: extra private IPs
If you want to set up more internal IPs, expand the configuration in step 3 with IPADDR1, IPADDR2, etc. and NETMASK1, NETMASK2, etc.:
DEVICE=eth1
ONBOOT=yes
NETBOOT=yes
BOOTPROTO=static
IPADDR=192.168.1.2
IPADDR1=192.168.1.3
NETMASK=255.255.255.0
NETMASK1=255.255.255.0
ZONE=public
USERCTL=no
AlmaLinux 9 / Rocky Linux 9 / CentOS Stream 9
Have you performed an in-place upgrade from version 8 to 9 of your operating system? First check with ‘ls /etc/sysconfig/network-scripts/’ whether your network configuration is located here. If so, follow the steps for AlmaLinux 8 / Rocky Linux 8 / CentOS Stream 8 instead.
Step 1
Log in to your VPS via SSH or the VPS console.
Step 2
Check the name of your private network adapter. You can do this with the following command:
ip a
You will see an output similar to the example below. For AlmaLinux, the name will usually be eth1 (eth0 is the public adapter).
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 fq_codel state UP group default qlen 1000
link/ether 52:54:00:43:89:72 brd ff:ff:ff:ff:ff:ff
altname enp0s3
altname ens3
inet 136.144.141.71/24 brd 136.144.141.255 scope global dynamic noprefixroute eth0
valid_lft 53329sec preferred_lft 53329sec
inet6 2a01:7c8:fff8:1ef:5054:ff:fe43:8972/64 scope global dynamic noprefixroute
valid_lft 2591960sec preferred_lft 604760sec
inet6 fe80::5054:ff:fe43:8972/64 scope link noprefixroute
valid_lft forever preferred_lft forever
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether 52:54:00:3d:15:d3 brd ff:ff:ff:ff:ff:ff
altname enp0s7
altname ens7
inet 192.168.3.3/24 brd 192.168.3.255 scope global noprefixroute eth1
valid_lft forever preferred_lft forever
inet6 fe80::5054:ff:fe3d:15d3/64 scope link tentative noprefixroute
valid_lft forever preferred_lft forever
It’s possible your private network interface is automatically assigned an IP address (here, 192.168.3.3). We assume you want to adjust it, or that it has not yet been assigned, and we’ll show you how to do so in the following steps.
Step 3
Check whether the file containing the configuration of your private network adapter exists. This file is often created automatically at the moment you added your VPS to your private network, but not always.
ls /etc/NetworkManager/system-connections/eth1.nmconnection
(eth1 is the name of your private network adapter. eth0 is the adapter of your public network.)
Do you see the following output? Then proceed to step 4.
ls /etc/NetworkManager/system-connections/eth1.nmconnection
/etc/NetworkManager/system-connections/eth1.nmconnection
Do you get a ‘No such file or directory’ message? Then add the interface manually with the command below and proceed to step 5:
nmcli connection add \
con-name eth1 \
ifname eth1 \
type ethernet \
ipv4.method manual \
ipv4.addresses 192.168.100.10/24 \
ipv4.gateway 192.168.100.1 \
ipv4.dns 192.168.100.1 \
autoconnect yes
The file /etc/NetworkManager/system-connections/eth1.nmconnection is now created. You can apply any future changes to your private network configuration from this file, as described in step 4.
Step 4
Under '[ipv4]', modify the line that starts with 'address1'. Replace the first IP address with the internal IP you actually want to use and the second one with the gateway address, for example:
...some code...
[ipv4]
address1=192.168.100.10/24,192.168.100.1
dhcp-timeout=90
dhcp-vendor-class-identifier=anaconda-Linux
method=manual
required-timeout=20000
...more code...
Step 5
Save your settings and close your editor (ctrl + x > y > enter). Finally, run the following command to restart the private network:
nmcli connection reload
Optional: extra private IPs
If you want to configure additional internal IPs, extend the configuration in step 4 with address2, address3, etc., but without the gateway:
...some code...
[ipv4]
address1=192.168.100.10/24,192.168.100.1
address2=192.168.100.11/24
dhcp-timeout=90
dhcp-vendor-class-identifier=anaconda-Linux
method=manual
required-timeout=20000
...more code...
CentOS 7
Step 1
Log in to your VPS using SSH or the VPS console.
Step 2
Check the name of your private network adapter. This can be done using the command:
ip a
You'll see output similar to the example below. Your MacAdress can be Je MacAddres is shown like in the example encircled in red. Please note that you write down the MacAddress for eth1 and not eth0.
Step 3
Open your network configuration file, or create it if it doesn't exist:
nano /etc/sysconfig/network-scripts/ifcfg-eth1
(eth1 is the name of your private network adapter. ifcfg-eth0 is the adapter of your public network.)
Step 4
Add the options below / adjust the existing configuration. Replace the IP behind 'IPADDR' with the IP address that you actually want to use.
Do not adjust the values behind HWADDR, UUID, etc. if you have an existing configuration!
DEVICE=eth1
ONBOOT=yes
NETBOOT=yes
BOOTPROTO=static
IPADDR=192.168.1.2
NETMASK=255.255.255.0
ZONE=public
Step 5
Save your settings and close your editor (ctrl + x > y > enter).
Finally, run the following command to restart the network:
systemctl restart network
Optional: extra private IPs
If you want to set up more internal IPs, expand the configuration in step 3 with IPADDR0, IPADDR1, etc. and NETMASK0, NETMASK1, etc.:
DEVICE=eth1
ONBOOT=yes
NETBOOT=yes
BOOTPROTO=static
IPADDR=192.168.1.2
IPADDR1=192.168.1.3
NETMASK=255.255.255.0
NETMASK1=255.255.255.0
ZONE=public
Debian 10
Step 1
Log in to your VPS using SSH or the VPS console.
Step 2
Open your network configuration:
nano /etc/network/interfaces
Step 3
Add the configuration for ens7 at the bottom of the open file.
auto ens7 iface ens7 inet static address 192.168.1.2 netmask 255.255.255.0
So, you add a new interface directly below the existing one (ens3). Do not adjust the existing 'public' interface (ens3).
Step 4
Save your settings and close your editor (ctrl + x > y > enter). Finally, restart your network to process the changes:
systemctl restart networking
Optional: extra private IPs
Do you want to set up more internal IPs? You then add an extra (kind of) sub-adapter for each IP address separately in your configuration:
auto ens7:0 allow-hotplug ens7:0 iface ens7:0 inet static address 192.168.1.3 netmask 255.255.255.0
You use this format per IP address. A third IP address thus gets the interface name ens7:1, a fourth ens7:2 etc.
Debian 11
Step 1
Log in to your VPS using SSH or the VPS console.
Step 2
Open your network configuration:
nano /etc/network/interfaces
Step 3
Add the configuration for ens7 at the bottom of the open file.
auto ens7 iface ens7 inet static address 192.168.1.2 netmask 255.255.255.0
So, you add a new interface directly below the existing one (ens3). Do not adjust the existing 'public' interface (ens3).
Please note: your VPS might use a different interface name (e.g. ens8). This can be checked using the ip a command.
Step 4
Save your settings and close your editor (ctrl + x > y > enter). Finally, restart your VPS to process the changes:
reboot
Optional: extra private IPs
Do you want to set up more internal IPs? You then add an extra (kind of) sub-adapter for each IP address separately in your configuration:
auto ens7:0 allow-hotplug ens7:0 iface ens7:0 inet static address 192.168.1.3 netmask 255.255.255.0
You use this format per IP address. A third IP address thus gets the interface name ens7:1, a fourth ens7:2 etc.
FreeBSD
Please note! Although fully based on FreeBSD, the instructions below do NOT work for pfSense. For this, you will always have to add private IPs via the interface of pfSense.
Step 1
Log in to your VPS using SSH or the VPS console.
Step 2 Open the network configuration (Nano is not standard in FreeBSD):
vi /etc/rc.conf
Step 3
Your private network interface (vtnet1) is probably not yet included in the configuration. Enter the configuration for vtnet1 (the private network interface). Choose an internal IP address that you want to use, for example:
ifconfig_vtnet1="inet 192.168.1.2 netmask 255.255.255.0"
For example, the result looks like this:
Step 4
Save your settings (:wq!) And run the following command to restart the network:
/etc/rc.d/netif restart
You can then test your IP address using a ping command:
ping 192.168.1.2
Ubuntu 20.04
Step 1
Log in to your VPS using SSH or the VPS console.
Step 2
First, check the name of your private network adapter with the command:
ip a
Usually your public interface is called ens3 and the private interface ens7. If yours is called ens4 or ens8 for example, make sure to change the name accordingly in the steps below.
Step 3
Open your network configuration:
nano /etc/netplan/01-netcfg.yaml
Step 4
Add the configuration for ens7 at the bottom of the open file. Please note that spaces (indentation) must match the existing configuration for your primary network adapter.
ens7:
dhcp4: no
addresses:
- 192.168.1.1/24
So, you add a new interface directly below the existing one (ens3). Do not adjust the existing 'public' interface (ens3).
In rare instances, the above might not work. If this happens to you, instead use:
ens7:
dhcp4: no
addresses: [192.168.1.1/24]
Step 5
Save your settings and close your editor (ctrl + x > y > enter). Finally, run the following command to restart the network:
netplan apply
Optional: extra private IPs
Any additional IPs can be added directly under the list of 'addresses' in your configuration as shown in the example below.
ens7: dhcp4: no addresses: - 192.168.1.1/24 - 192.168.1.2/24
Ubuntu 22.04/24.04
Step 1
Log in to your VPS using SSH or the VPS console.
Step 2
First, check the name of your private network adapter with the command:
ip a
Usually your public interface is called ens3 and the private interface ens7. If yours is called ens4 or ens8 for example, make sure to change the name accordingly in the steps below.
Step 3
Open your network configuration:
nano /etc/netplan/01-netcfg.yaml
Step 4
Add the configuration for ens7 at the bottom of the open file. Please note that spaces (indentation) must match the existing configuration for your primary network adapter.
ens7:
dhcp4: no
addresses:
- 192.168.1.1/24
So, you add a new interface directly below the existing one (ens3). Do not adjust the existing 'public' interface (ens3).
In rare instances, the above might not work. If this happens to you, instead use:
ens7:
dhcp4: no
addresses: [192.168.1.1/24]
Step 5
Save your settings and close your editor (ctrl + x > y > enter). Finally, run the following command to restart the network:
netplan apply
Optional: extra private IPs
Any additional IPs can be added directly under the list of 'addresses' in your configuration as shown in the example below.
ens7: dhcp4: no addresses: - 192.168.1.1/24 - 192.168.1.2/24
or alternatively:
ens7:
dhcp4: no
addresses: [192.168.1.1/24, 192.168.1.2/24]