Cart

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

    Adding an IPv4 or IPv6 address in Debian 12

    When you order an extra IPv4 address or add an extra IPv6 address to your IP addresses via the control panel, they are not automatically added to your VPS via DHCP. You must manually add extra IP addresses to the network interfaces.

    In this article, we explain how to add or set a static IPv4 and IPv6 address on your Debian 12 VPS. For this, you need an extra IPv4 and/or IPv6 address (depending on what you want to configure/add). If you do not have them yet, first consult one of the following articles:

    See here for an overview of all our guides to add an extra or static IPv4 and IPv6 addresses to different Linux distros, or here for Windows.

    • Follow the steps in this guide as a root user (or install sudo).
       
    • This guide is about public IP addresses. In this guide you can find more information about setting up internal addresses (for your private network).
       
    • A VPS includes one IPv4 address by default (except SandboxVPS), but you can expand this to a maximum of ten IPv4 addresses via the control panel. For VPSs in the PRO series, the limit is a maximum of 20 IPv4 addresses.
       
    • Each VPS has a /64 IPv6 range by default, from which IP addresses can be added as desired. A /64 IPv6 range contains a total of 18,446,744,073,709,551,616 IP addresses, so the chance of not having enough is quite small! The gateway falls outside this range, so you always set the netmask to 48.
     

     

    Adding an IPv4 address in Debian 12


     

    Step 1

    Connect to your VPS via the VPS console or via SSH.



    Step 2

    Once logged in, you can see the current network interfaces and the configured IPs with the command:

    ip a

    For the following steps, it is especially important that you are aware of the correct adapter name. In this example, it is ens3.

    debian 9 ip a output


     

    Step 3

    Did you choose for an installation using a one time password, SSH-keys, or Cloud-config file? If so, follow the steps in the ‘Fast Installs installatie’ tab. If not, follow the steps in the ‘Manual installation’ tab.

    Manual installation

    Now you'll add the static/extra IPv4 address to your network interface. Open the configuration of your network interface:

    sudo nano /etc/network/interfaces

    A configuration file opens which shows only the configuration for the loopback device. You can add a static/new IP address using the following syntax:

    auto ens3
    iface ens3 inet static
        address 136.144.210.124
        netmask 255.255.255.0
        gateway 136.144.210.1
    auto ens3:0
    allow-hotplug ens3:0
    iface ens3:0 inet static
        address 136.144.210.181
        netmask 255.255.255.0
    • address is the IPv4 address you want to configure which can be found in the control panel. Leave the (sub)netmask as 255.255.255.0.
    • Optionally, you can let your primary IPv4 address be retrieved through DHCP by using iface ens3 inet dhcp for the auto ens3 interface.
    • Don't set additional gateways for your extra IPv4 addresses, unless the IPv4 address falls outside the /24 range of the primary IPv4 address.

    Save the changes and close nano (ctrl + x > > enter). Add additional IPv4 addresses underneath as ens3:1, ens3:2, etc.

     
     

    Fast Installs installation

     First, disable Cloud Init. Then, move/replace the existing configuration and modify the permissions:

    sudo touch /etc/cloud/cloud-init.disabled
    sudo mv /etc/network/netplan/50-cloud-init.yaml /etc/netplan/01-netcfg.yaml
    sudo 600 /etc/netplan/01-netcfg.yaml

    The last command ensures only the root user has read/write permissions to the configuration file.

    Next, open the network configuration:

    sudo nano /etc/netplan/01-netcfg.yaml

    A file opens which shows the configuration as created by Cloud Init. Add a new/static IPv4 address using the following syntax:

    network:
        ethernets:
            ens3:
                dhcp4: false
                dhcp6: true
                addresses:
                  - 149.210.181.124/24
                  - 149.210.189.113/24
                routes:
                  - to: default
                    via: 149.210.181.1    
    • address is the IPv4 address you want to configure which can be found in the control panel. Leave the (sub)netmask as 255.255.255.0.
    • Don't configure a gateway for extra IPv4 adresses, unless the IPv4 address falls outside the /24 range of the primairy IPv4 address.

    Save the changes and close nano (ctrl + x > > enter). 

     
     

     

    Step 4

    To apply the new IP address, restart your network and bring the new interface down and up again (note that this will break your SSH connection).

     

    Manual installation

    sudo systemctl restart networking

     

    Fast installs installation

    sudo netplan apply

     

    Step 5

    When you run ip a again, you will see the newly added IPv4 address. You can test this IP address by performing a ping test from another computer/IP.


     

    Adding an IPv6 address in Debian 12


     

    Step 1

    Connect to your VPS via the VPS console or via SSH.



     

    Step 2

    Once logged in, you can see the current network interfaces and the configured IPs with the command:

    ip a

    For the following steps, it is especially important that you are aware of the correct adapter name. In this example, it is ens3.

    debian9 ip a output 1 ip



     

    Step 3

    Did you choose for an installation using a one time password, SSH-keys, or Cloud-config file? If so, follow the steps in the ‘Fast Installs installatie’ tab. If not, follow the steps in the ‘Manual installation’ tab.

    Manual installation

    Now you'll add the static/extra IPv4 address to your network interface. Open the configuration of your network interface:

    sudo nano /etc/network/interfaces

    A configuration file opens which shows only the configuration for the loopback device. You can add a static/new IP address using the following syntax:

    auto ens3
    iface ens3 inet static
        address 136.144.210.124
        netmask 255.255.255.0
        gateway 136.144.210.1
    auto ens3:0
    allow-hotplug ens3:0
    iface ens3:0 inet static
        address 136.144.210.181
        netmask 255.255.255.0
    • address is the IPv4 address you want to configure which can be found in the control panel. Leave the (sub)netmask as 255.255.255.0.
    • Optionally, you can let your primary IPv4 address be retrieved through DHCP by using iface ens3 inet dhcp for the auto ens3 interface.
    • Don't set additional gateways for your extra IPv4 addresses, unless the IPv4 address falls outside the /24 range of the primary IPv4 address.

    Save the changes and close nano (ctrl + x > > enter). Add additional IPv4 addresses underneath as ens3:1, ens3:2, etc.

     
     

    Fast Installs installation

     First, disable Cloud Init. Then, move/replace the existing configuration and modify the permissions:

    sudo touch /etc/cloud/cloud-init.disabled
    sudo mv /etc/network/netplan/50-cloud-init.yaml /etc/netplan/01-netcfg.yaml
    sudo 600 /etc/netplan/01-netcfg.yaml

    The last command ensures only the root user has read/write permissions to the configuration file.

    Next, open the network configuration:

    sudo nano /etc/netplan/01-netcfg.yaml

    A file opens which shows the configuration as created by Cloud Init. Add a new/static IPv4 address using the following syntax:

    network:
        ethernets:
            ens3:
                dhcp4: yes
                dhcp6: no
                addresses:
                  - 2a01:7c8:aab5:4cd::1/48
                  - 2a01:7c8:aab5:4cd::2/48
                routes:
                  - to: default
                    via: 2a01:7c8:aab5::1     
    • address is the IPv4 address you want to configure which can be found in the control panel. Leave the (sub)netmask as 255.255.255.0.
    • Don't configure a gateway for extra IPv4 adresses, unless the IPv4 address falls outside the /24 range of the primairy IPv4 address.

    Save the changes and close nano (ctrl + x > > enter). 

     
     

     

    Step 4

    To apply the new IP address, restart your network and bring the new interface down and up again (note that this will break your SSH connection).

     

    Manual installation

    sudo systemctl restart networking

     

    Fast installs installation

    sudo netplan apply


    Step 5

    When you run ip a again, you will see the newly added IPv6 address. You can test this IP address by performing a ping test from another computer/IP.

    debian9 extra ipv6 addresses



     This concludes our tutorial on adding (static) IPv4 and IPv6 addresses in Debian 12.

    Need help?

    Receive personal support from our supporters

    Contact us