Cart

/ Domain name

/ Your .CO.UK domain
for only £ 4.99**

Get started with your own domain names

Register now

/ Other

/ Latest news

Launch of new Big Storage platform

Read more
Need help?

    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, it will automatically gain a new network adapter for your private network; no reboot required. 

    Before you can use your private network, you will first have to set up internal/private IP addresses before you can make full use of them. In this article we'll show you how to configure internal/private IP addresses in various Linux distributions. For Windows, please see this article.

    • 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
       
    • A wrong configuration can make the network of your VPS unreachable. In that case, you can always use the VPS console in the control panel and correct the configuration.
     

     

    Disabling Cloud Init

     

    Did you install your VPS using the installation via SSH-keys, one time password, or cloud-config user data option? Additional steps are required before configuring the IP address for your private network connection.

    When you've selected one of these options, you use what we call our ‘Fast Installs’ installation method which uses Cloud Init. Cloud Init automatically overwrites your network configuration and for this reason Clud Init, or the Cloud Init control over your network, needs to be disabled as follows (you're free to choose either option):

     

    Step 1

     

    Disabling Cloud Init network management

    Open/create the following file:

    sudo 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:

    sudo touch /etc/cloud/cloud-init.disabled

     

    Step 2 - Ubuntu / Debian additional optional steps

    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:

    sudo 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 using SSH or the VPS console.


     

    Step 2

    Check the name of your private network adapter. You can do this with the following command:

    sudo 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 which contains the configuration of your private network adapter actually exists. This file is often created automatically at the moment you added your VPS to your private network, but not always.

    sudo 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.

    [user@servername ~]$ sudo 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

    Open the private network adapter configuration:

    sudo nano /etc/NetworkManager/system-connections/eth1.nmconnection

    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 + > > enter). Finally, run the following command to restart the private network:

    sudo 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...

     

    Debian 11

     

    Step 1

    Log in to your VPS using SSH or the VPS console.


     

    Step 2 

    Open your network configuration:

    sudo 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: 

    sudo 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. 


     

    Debian 12 or 13 (NetworkManager)

     

    Step 1

    Log in to your VPS via 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

    Here you’re adding a new interface directly beneath the existing one (ens3). Do not modify the existing ‘public’ interface (ens3).

    Note: it’s possible your Debian 11 VPS uses ens8. You can check this with the ip a command.


     

    Step 4

    Save your settings and close your editor (ctrl + > > enter). Finally, restart the network service to apply the changes with one of the following commands: 

    /etc/init.d/networking restart
    systemctl restart networking

     

    Optional: additional private IPs

    Want to configure more internal IPs? Add an extra sub-interface (alias) for each IP address 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

    Use this construct per IP address. A third IP address therefore gets the interface name ens7:1, a fourth ens7:2, etc.


     

    Debian 12 or 13 (netplan)

     

    Step 1

    Log in to your VPS via SSH or the VPS console.


     

    Step 2

    Check the name of your private network adapter. Do this with:

    ip a

    You’ll see output like the example below. For AlmaLinux the name is usually ens7 (ens3 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 noprefixroute
           valid_lft forever preferred_lft forever
    2: ens3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
        link/ether 52:54:00:88:58:6f brd ff:ff:ff:ff:ff:ff
        altname enp0s3
        altname enx52540088586f
        inet 136.144.123.123/24 metric 100 brd 136.144.178.255 scope global dynamic ens3
           valid_lft 85352sec preferred_lft 85352sec
        inet6 2a01:7c8:aabb:cc:5054:ff:fe88:586f/64 scope global dynamic mngtmpaddr noprefixroute
           valid_lft 2591994sec preferred_lft 604794sec
        inet6 fe80::1234:ff:fe88:567f/64 scope link proto kernel_ll
           valid_lft forever preferred_lft forever
    3: ens7: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
        link/ether 52:54:00:af:dc:28 brd ff:ff:ff:ff:ff:ff
        altname enp0s7
        altname enx525400afdc28
    

     

    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. Make sure the indentation matches the configuration of your primary adapter (ens3).

    ens7:
      dhcp4: false
      addresses:
       - 192.168.1.1/24

    Here you’re adding a new interface directly beneath the existing one (ens3). Do not modify the existing ‘public’ interface (ens3).

    In some cases the syntax above may not work. Alternatively, you can add your IP address as follows:

    ens7: 
      dhcp4: false
      addresses: [192.168.1.1/24]

     

    Step 5

    Save your settings and close your editor (ctrl + > > enter). Finally, run the following command to apply the configuration:

    netplan apply

    You can verify your new private IP with:

    ip a

     

    Optional: additional private IPs

    Add any extra IPs directly under the 'addresses' list in your configuration, as in the example below.

    ens7:
      dhcp4: false
      addresses:
       - 192.168.1.1/24
       - 192.168.1.2/24

    Or alternatively:

    ens7:
      dhcp4: false
      addresses: [192.168.1.1/24, 192.168.1.2/24]

     

    FreeBSD

     

    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): 

    sudo 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: 

    sudo /etc/rc.d/netif restart 

    You can then test your IP address using a ping command: 

    ping 192.168.1.2

     

    Ubuntu 22.04/24.04 & Debian 12

     

    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:

    sudo 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: 

    sudo 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]

    Was this article helpful?


    Provide feedback about this article

    Need help?

    Receive personal support from our supporters

    Contact us