Cart

    Sorry, we could not find any results for your search querry.

    Configuring an internal/private IP on your Linux VPS

    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

     

    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

     

    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
    

     

    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.

    centos 7 ip a output


     

    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 
    IPADDR0=192.168.1.3 
    NETMASK=255.255.255.0 
    NETMASK0=255.255.255.0 
    ZONE=public
    

     

    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 with the command:

    ip a
    

    Most commonly it will be called ens7:

    ipa centos8 ens7

    centos 7 ip a output


     

    Step 3

    Open your network configuration file, or create it if it doesn't exist: 

    nano /etc/sysconfig/network-scripts/ifcfg-ens7

    (ens7 is the name of your private network adapter. ens3 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 they exist in your configuration.

    DEVICE=ens7
    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:

    nmcli networking off
    nmcli networking on

    For the first internal IP you can also use systemctl restart NetworkManager. Any additional IP's require nmcli (the NetworkManager CLI client) using the commands above.


     

    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
    

     

    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:

    freebsd network configuration with private network


     

    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

    Need help?

    Receive personal support from our supporters

    Contact us