Article overview

Help article

How do I add an IPv4 or IPv6 address to my Linux VPS?

In this article, we explain how to add an IPv4 and IPv6 address to your Linux VPS.

A VPS includes 1 IPv4 address by default, but you can expand this to a maximum of 10 IPv4 addresses via the control panel. A maximum limit of 20 IPv4 addresses applies to the VPSs of the PRO series.

Each VPS has a /64 IPv6 range at its disposal by default, where 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 likeliness that you will not have enough is quite small! The default gateway falls outside of the /64 range so as netmask you always use a /48 range.

When you order an extra IPv4 address or add an extra IPv6 address to your IP addresses via the control panel, these cannot be automatically added to your VPS via DHCP. Additional IP addresses are added manually to the network interfaces.

  • This manual is about public IP addresses. In this manual, you will find more information about setting up internal addresses (for your private network).
  • In case a misconfiguration makes your VPS unreachable, it is best to create a snapshot first.

This article covers the following topics:

(Free)BSD:

CentOS 6.x:

CentOS 7.x:

Debian:

Debian 9:

Ubuntu 14.04:

Ubuntu 16.04:

Ubuntu 18.04:


How do I order an IPv4 address in the control panel?

 

Step 1

In the control panel go to 'VPS & Colocation'. On the left side of this page click the VPS you wish to add an extra IP address to. Then click the blue 'Network information' button on the right side of the page.

control panel network information


 

Step 2 

Here you will see an overview of all current IPv4 and IPv6 addresses of the VPS. Click the button 'Request an IPv4 address'

control panel request an ipv4 address


 

Step 3 

Click the plus button to add an extra IPv4 address. Then click 'Order' at the bottom of the page to complete the order.

control panel order ip address


 

Step 4

Within seconds, an extra IPv4 address will appear in the overview which you can then configure in the network interfaces of your VPS.

control panel added ipv4 address

Please note: IP addresses are automatically assigned based on the available IPs in the 'pool' of physical blade. So, you can get a subsequent IP address in exactly the same IP range, but it can also deviate completely.

 


How do I add an IPv6 address in the control panel?

 

Step 1

In the control panel go to 'VPS & Colocation'. On the left side of this page click the VPS you wish to add an extra IP address to. Scroll down and click the blue 'Network information' button on the right side of the page.

control panel network information 


 

Step 2


Here you will see an overview of all current IPv4 and IPv6 addresses of the VPS. Click the button 'Add a new IPv6 address'.

control panel request ip address


 

Step 3


At the top, you will see the IPv6 range you can create an IPv6 address from. Enter the desired IPv6 address and possibly a reverse DNS name / PTR record. Once you have done this click on 'Add new IPv6 address'.

control panel add ipv6 address

This IPv6 address will now also appear in the overview of addresses.


FreeBSD

How do I add an IPv4 address in FreeBSD? 

Step 1 

Connect to the VPS via the VPS console or via SSH and log in.


 

Step 2 

Once logged in you see the current network interfaces and the set IPs by means of the command:

ifconfig -a

For the next steps, it is especially important that you are aware of the correct adapter name. Which is vtnet0 in this example.    


 

Step 3 

Now add the extra IPv4 address in the network interfaces by executing the following commands (you can use another editor such as vim of course): 

nano /etc/rc.conf

A configuration file opens, and you modify the following:

  • Add the gateway (this is replaced by your own gateway IP): 
    defaultrouter="149.210.204.1"
  • Change the ifconfig_vtnet0 = "DHCP" line to a manually configured IP: 
    ifconfig_vtnet0="inet 149.210.202.105 netmask 255.255.255.0"
  • Add the extra IPs in the lines below, making sure that the _alias0 have consecutive numbers. 
    ifconfig_vtnet0_alias0="inet 149.210.202.105 netmask 255.255.255.255"
    ifconfig_vtnet0_alias1="inet 149.210.202.118 netmask 255.255.255.255"

Here, defaultrouter is the IP address of the gateway, which for your IP address can be found in the control panel. The netmask is 255.255.255.0 for the main IP address, you set this to 255.255.255.255 for all 'extra' IP addresses. An alternative possibility is to add all aliases via the following example: 

ifconfig_vtnet0_aliases="\
   inet 149.210.202.105/24 \
   inet 149.210.202.118/24 \

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


 

Step 4 

Reset your network interfaces with the following command to use the new IP address: 

/etc/rc.d/netif restart && /etc/rc.d/routing restart

 

Step 5

If you run ifconfig -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. Repeat the above steps if you want to add more IP addresses.  

How do I add an IPv6 address in FreeBSD?

Step 1 

Connect to the VPS via the VPS console or via SSH and log in.


 

Step 2 

Once logged in you see the current network interfaces and the set IPs by means of the command:

ifconfig -a

For the next steps, it is especially important that you are aware of the correct adapter name. Which is vtnet0 in this example.  


 

Step 3 

Now add the extra IPv6 address in the network interfaces by executing the following commands (you can use another editor such as vim of course): 

sudo nano /etc/rc.conf

In the opened configuration file, adjust the following:

  • Change the ifconfig_vtnet0_ipv6 line to a manually configured IP:
    ifconfig_vtnet0_ipv6="inet6 2a01:7c8:aab8:77::1/48"
  • Add the extra IPs in the lines below, making sure that the _alias0 have consecutive numbers.
    ifconfig_vtnet0_ipv6="inet6 2a01:7c8:dead:beef::2/48"
    ifconfig_vtnet0_alias0="inet6 2a01:7c8:dead:beef::1234/48"  
    
  • An alternative possibility is to add all aliases via the following example: 

    ifconfig_vtnet0_aliases=" \
       inet6 2a01:7c8:aab8:77::1337/48 \
       inet6 2a01:7c8:aab8:77::13:17/48 \
    

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


 

Step 4 

Reset your network interfaces with the following command to use the new IP address: 

sudo /etc/rc.d/netif restart && /etc/rc.d/routing restart

 

Step 5 

If you run ifconfig -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. 

Repeat the above steps if you want to add more IP addresses. 

CentOS 6 

How do I add an IPv4 address in CentOS 6.X? 

Step 1 

Connect to the VPS via the VPS console or via SSH and log in.


 

Step 2

Once logged in you see the current network interfaces and the set IPs by means of the command:

ifconfig -a

Check whether an extra IP address has already been configured on eth0:1 and verify the name of the adapter. In this example this is eth0. 

centos 6 ifconfig output


 

Step 3

Now add the extra IPv4 address in the network interfaces by executing the following commands (you can use another editor such as vim of course): 

sudo nano /etc/sysconfig/network-scripts/ifcfg-eth0:1

Please note that if you have already set an extra IP address to eth0:1, that you use the next interface (ie eth0:2). 

An empty configuration file opens. Enter the following: 

DEVICE=eth0:1
BOOTPROTO=static
IPADDR=149.210.202.105
GATEWAY=149.210.202.1
NETMASK=255.255.255.0
ONBOOT=yes

IPADDR is the IP address that you want to set and GATEWAY the gateway, which for your IP address can be found in the control panel. You need to leave the (sub) NETMASK at 255.255.255.0. 

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


 

Step 4 

To be able to use the new IP address you will have to reset the network interfaces via the following command:  

sudo /etc/init.d/network restart

 

Step 5 

If you run ifconfig -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. 

centos 6 ifconfig added ip

Repeat the above steps if you want to add more IP addresses. In addition, it is not mandatory to add the gateway if the extra IP address is in the same /24 range. If this is not the case then you will have to add this, because otherwise, you will have trouble reaching other IPs within the TransIP network.

How do I add an IPv6 address in CentOS 6.X? 

Step 1 

Connect to the VPS via the VPS console or via SSH and log in.


 

Step 2 

Once logged in you see the current network interfaces and the set IPs by means of the command:

ifconfig -a

For the next steps, it is especially important that you are aware of the correct adapter name. Which is eth0 in this example.  

iconfig centos 6


 

Step 3

Now add the extra IPv6 address in the network interfaces by executing the following commands (you can use another editor such as vim of course): 

sudo nano /etc/sysconfig/network-scripts/ifcfg-eth0

You will see a file which looks like the screenshot below. 

centos 6 eth0 config

In the opened configuration file, add the following lines:

IPV6INIT=yes
IPV6ADDR=2a01:7c8:aab8:77::1337
IPV6_DEFAULTGW=2a01:7c8:aab8::1

Save the changes and exit nano (ctrl + x > y > enter). If you want to add more IPv6 addresses, add the following line: 

IPV6ADDR_SECONDARIES="2a01:7c8:aab9:77::1338 2a01:7c8:aab8:77::1339" (etc)

 

Step 4 

Reset your network interfaces with the following command to use the new IP address: 

sudo /etc/init.d/network restart

If you run ifconfig -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. 

Repeat the above steps if you want to add more IP addresses.

CentOS 7 

How do I add an IPv4 address in CentOS 7? 

Step 1 

Connect to the VPS via the VPS console or via SSH and log in.


 

Step 2 

Once logged in you see the current network interfaces and the set IPs by means of the command:

ifconfig -a

For the next steps, it is especially important that you are aware of the correct adapter name. Which is eth0 in this example.    

centos 7 ifconfig


 

Step 3 

Now add the extra IPv4 address in the network interfaces by executing the following command (you can use another editor such as vim of course): 

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

Please note: In CentOS 6 an extra interface had to be created for each individual IP address, such as eth0:1, eth0:2, etc. In CentOS 7 this is no longer necessary. 

centos 7 default ifcfg

The existing configuration file opens and you add the following: 

IPADDR0=149.210.175.3
IPADDR1=149.210.193.224
IPADDR2=149.210.193.225
NETMASK0=255.255.255.0
NETMASK1=255.255.255.0
NETMASK2=255.255.255.0
GATEWAY0=149.210.175.1
GATEWAY1=149.210.193.1
GATEWAY2=149.210.193.1

IPADDR(x) is the IP address that you want to set and GATEWAY(x) the gateway, which for your IP address can be found in the control panel

For every IP address that you add, you use an ascending number, i.e. IPADDR0, IPADDR1, IPADDR2, IPADDR3, etc. The same applies to gateways if applicable. You need to leave the (sub)NETMASK at 255.255.255.0. 

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


 

Step 4 

Reset your network interfaces with the following command to use the new IP address: 

systemctl restart network

 

Step 5 

If you run ifconfig -a or ip addr again you will see the newly added IPv4 address. You can test this IP address by performing a ping test from another computer / IP. 

centos 7 added ipv4 address

Repeat the above steps if you want to add more IP addresses. In addition, it is not mandatory to add the gateway if the extra IP address is in the same /24 range. If this is not the case then you will have to add this, because otherwise, you will have trouble reaching other IPs within the TransIP network. 

How do I add an IPv6 address in CentOS 7? 

Step 1 

Connect to the VPS via the VPS console or via SSH and log in.


 

Step 2 

Once logged in you see the current network interfaces and the set IPs by means of the command:

ifconfig -a

For the next steps, it is especially important that you are aware of the correct adapter name. Which is eth0 in this example.  

centos ifconfig


 

Step 3 

Now add the extra IPv6 address in the network interfaces by executing the following command (you can use another editor such as vim of course): 

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

You will see an output that looks like the screenshot below. 

centos eth0 ipv6

In the opened configuration file, add the following lines if they are missing: 

IPV6INIT=yes
IPV6ADDR=2a01:7c8:aab8:77::1337
IPV6_DEFAULTGW=2a01:7c8:aab8::1

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

If you want to add more IPv6 addresses, add the following line:

IPV6ADDR_SECONDARIES="2a01:7c8:aab8:77::1338 2a01:7c8:aab8:77::1339" (etc.)

 

Step 4 

Reset your network interfaces with the following command to use the new IP address: 

systemctl restart network

If you run ifconfig -a or ip addr again you will see the newly added IPv6 address. You can test this IP address by performing a ping test from another computer / IP. 

Repeat the above steps if you want to add more IP addresses. 

Debian 

How do I add an IPv4 address in Debian? 

Step 1 

Connect to the VPS via the VPS console or via SSH and log in.


 

Step 2 

Once logged in you see the current network interfaces and the set IPs by means of the command:

ifconfig -a

For the next steps, it is especially important that you are aware of the correct adapter name. Which is eth0 in this example.    

ifconfig output


 

Step 3 

Now add the extra IPv4 address in the network interfaces by executing the following command (you can use another editor such as vim of course): 

sudo nano /etc/network/interfaces

Please note that if you have already set an extra IP address to eth0:0, that you use the next interface (i.e. eth0:1).

debian eth0 add ip
A configuration file should be opened where the main IPv4 address should already be set and you enter the following: 

auto eth0:0
allow-hotplug eth0:0
iface eth0:0 inet static
    address 149.210.202.105
    netmask 255.255.255.0
    gateway 149.210.202.1

 IPADDR is the IP address that you want to set and GATEWAY the gateway, which for your IP address can be found in the control panel. Leave the (sub) NETMASK at 255.255.255.0. 

Save the changes and exit nano (ctrl + x > y > enter). For additional IPv4 addresses, add eth0:1, eth0:2, and so on.  


 

Step 4 

Reset your network interfaces with the following command to use the new IP address: 

sudo service networking restart

 

Step 5 

If you run ifconfig -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. 

debian ifconfig extra ip

How do I add an IPv6 address in Debian?

Step 1 

Connect to the VPS via the VPS console or via SSH and log in.


 

Step 2 

Once logged in you see the current network interfaces and the set IPs by means of the command:

ifconfig -a

For the next steps, it is especially important that you are aware of the correct adapter name. Which is eth0 in this example.  

ifconfig output


 

Step 3 

Now add the extra IPv6 address in the network interfaces by executing the following command (you can use another editor such as vim of course): 

sudo nano /etc/network/interfaces

In the opened configuration file, add the following lines: 

address 2a01:7c8:aab8:77::1337
netmask 48
gateway 2a01:7c8:aab8::1

The address is the IP address that you want to set and GATEWAY the gateway, which for your IP address can be found in the control panel. You need to leave the (sub) NETMASK at 48. Save the changes and exit nano (ctrl + x > y > enter).   


 

Step 4

Reset your network interfaces with the following command to use the new IP address: 

sudo service networking restart

 

Step 5 

If you run ifconfig -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. 

Repeat the above steps if you want to add more IP addresses.

Debian 9 

At the moment of writing, there is no documentation at Debian about adding extra IP addresses in Debian 9.
The steps below ensure that your IP addresses can be reached, but changes require a reboot. Other options like service networking restart or ifdown ens3 && ifup ens3 make your IP addresses unreachable. Once Debian has updated its documentation for Debain 9, we will also adjust this in our documentation.

How do I add an IPv4 address in Debian 9?

Step 1 

Connect to the VPS via the VPS console or via SSH and log in.


 

Step 2 

Once logged in you see the current network interfaces and the set IPs by means of the command:

ip a

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

debian 9 ip a output


 

Step 3 

Now add the extra IPv4 address in the network interfaces by executing the following command (you can use another editor such as vim of course): 

sudo nano /etc/network/interfaces

Please note that if you have already set an extra IP address to ens3:0, that you use the next interface (i.e. ens3:1). A configuration file opens with only the loopback interface set. You add your existing and new IP address statically with the following code: 

auto ens3
allow-hotplug 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
    gateway 136.144.210.1

The IP that you use is the IP address that you added in your control panel. The gateway for your IP address can be found in the control panel. You need to leave the (sub) NETMASK at 255.255.255.0. Save the changes and exit nano (ctrl + x > y > enter). For additional IPv4 addresses, add ens3:1, ens3:2, and so on. 


 

Step 4 

Reset your VPS to use the new IP address:

sudo reboot

 

Step 5

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

How do I add an IPv6 address in Debian 9? 

Step 1 

Connect to the VPS via the VPS console or via SSH and log in.


 

Step 2 

Once logged in you see the current network interfaces and the set IPs by means of the command:

ip a

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

debian 9 ip a


 

Step 3 

Now add the extra IPv6 address in the network interfaces by executing the following command (you can use another editor such as vim of course): 

sudo nano /etc/network/interfaces

You add your IPv6 addresses statically in the opened configuration file (in this example a primary IPv6 address is included first, followed by a secondary IPv6 address): 

iface ens3 inet6 static
    address 2a01:7c8:d001:61::1
    netmask 48
    gateway 2a01:7c8:d001::1

iface ens3 inet6 static
    address 2a01:7c8:d001:61::1337
    netmask 48

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


 

Step 4 

Reset your VPS to use the new IP address:

sudo reboot

 

Step 5 

If 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. Should you want to add more IP addresses then add the following piece again, replacing the IPv6 address in the example with your new IPv6 address: 

iface ens3 inet6 static
address 2a01:7c8:d001:61::1337 netmask 48

Ubuntu 14.04 

How do I add an IPv4 address in Ubuntu 14.04? 

Step 1 

Connect to the VPS via the VPS console or via SSH and log in.


 

Step 2 

Once logged in you see the current network interfaces and the set IPs by means of the command:

ifconfig -a

For the next steps, it is especially important that you are aware of the correct adapter name. Which is eth0 in this example.    

ubuntu 14 ifconfig


 

Step 3 

Now add the extra IPv4 address in the network interfaces by executing the following command (you can use another editor such as vim of course): 

sudo nano /etc/network/interfaces

A configuration file opens in which only the loopback network interface is set. Add the following below:

auto eth0
iface eth0 inet dhcp

auto eth0:0
allow-hotplug eth0:0
iface eth0:0 inet static
     address 37.97.219.3
     netmask 255.255.255.0
     gateway 37.97.219.1

The extra IP address that you enter after 'Address' can be found in your control panel. Set the (sub)netmask to 255.255.255.0.

Save the changes and exit nano (ctrl + x > y > enter). For additional IPv4 addresses, add eth0:1, eth0:2, and so on.  


 

Step 4 

Restart your network to use the new IP address:

sudo ifdown eth0 && ifup eth0

Ubuntu cannot use /etc/init.d/networking restart or systemctl restart networking for example. This is regarded as a 'feature' to prevent possible connection problems. 

Please note: reboot your VPS if the above does not work.


 

Step 5

If you run ifconfig -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. 

ubuntu 14 ifconfig 2 ips

How do I add an IPv6 address in Ubuntu 14.04?

Step 1 

Connect to the VPS via the VPS console or via SSH and log in.


 

Step 2 

Once logged in you see the current network interfaces and the set IPs by means of the command:

ifconfig -a

For the next steps, it is especially important that you are aware of the correct adapter name. Which is eth0 in this example.    

ubuntu 14 ifconfig


 

Step 3 

Now add the extra IPv6 address in the network interfaces by executing the following command (you can use another editor such as vim of course): 

sudo nano /etc/network/interfaces

In the opened configuration file, add the following lines: 

iface eth0 inet6 static
address 2a01:7c8:aab8:77::1337
netmask 48
gateway 2a01:7c8:aab8::1

Use the IPv6 address which you created in your control panel. Save the changes and exit nano (ctrl + x> y> enter).


 

Step 4 

Restart your network to use the new IP address:

sudo ifdown eth0 && ifup eth0

Ubuntu cannot use /etc/init.d/networking restart or systemctl restart networking for example. This is regarded as a 'feature' to prevent possible connection problems. 

Please note: reboot your VPS if the above does not work.


 

Step 5 

If you run ifconfig -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.

Repeat the above steps if you want to add more IP addresses.

Ubuntu 16.04 

How do I add an IPv4 address in Ubuntu 16.04? 

 

Step 1 

Connect to the VPS via the VPS console or via SSH and log in.


 

Step 2 

Once logged in you see the current network interfaces and the set IPs by means of the command:

ifconfig -a

For the next steps, it is especially important that you are aware of the correct adapter name. Which is ens3 in this example. Please note: the name of your network adapter is changed compared to Ubuntu 14.04.

ubuntu 16 ifconfig


 

Step 3 

Now add the extra IPv4 address in the network interfaces by executing the following command (you can use another editor such as vim of course): 

sudo nano /etc/network/interfaces

A configuration file opens in which only the loopback network interface is set. Add the following lines in the opened configuration file:

auto ens3:0
allow-hotplug ens3:0
iface ens3:0 inet static
    address 37.97.219.3
    netmask 255.255.255.0
    gateway 37.97.219.1

The extra IP address that you enter after 'Address' can be found in your control panel. Set the (sub)netmask to 255.255.255.0.

Save the changes and exit nano (ctrl + x > y > enter). For additional IPv4 addresses, add ens3:1, ens3:2, and so on.  


 

Step 4 

Restart your network to use the new IP address:

sudo ifdown ens3 && ifup ens3

Ubuntu cannot use /etc/init.d/networking restart or systemctl restart networking for example. This is regarded as a 'feature' to prevent possible connection problems. 

Please note: reboot your VPS if the above does not work.


 

Step 5 

If you run ifconfig -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.

ubuntu 16 ifconfig 2 ips

How do I add an IPv6 address in Ubuntu 16.04?

Step 1 

Connect to the VPS via the VPS console or via SSH and log in.


 

Step 2 

Once logged in you see the current network interfaces and the set IPs by means of the command:

ifconfig -a

 

or the next steps, it is especially important that you are aware of the correct adapter name. Which is ens3 in this example. Please note: the name of your network adapter is changed compared to Ubuntu 14.04.

 

ubuntu 16 ifconfig


 

Step 3

Now add the extra IPv4 address in the network interfaces by executing the following command (you can use another editor such as vim of course): 

sudo nano /etc/network/interfaces

A configuration file opens in which only the loopback network interface is set. Add the following lines in the opened configuration file:

iface ens3 inet6 static
    address 2a01:7c8:aab8:77::1337
    netmask 48
    gateway 2a01:7c7:aab8::1

Use the IPv6 address which you created in your control panel. Save the changes and exit nano (ctrl + x> y> enter).


 

Step 4 

Restart your network to use the new IP address:

sudo ifdown eth0 && ifup eth0

Ubuntu cannot use /etc/init.d/networking restart or systemctl restart networking for example. This is regarded as a 'feature' to prevent possible connection problems. 

Please note: reboot your VPS if the above does not work.


 

Step 5 

If you run ifconfig -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.

ubuntu 16 ifconfig 2 ips

Repeat the above steps if you want to add more IP addresses.

Ubuntu 18.04

Before we start setting up, we consider some important changes from Ubuntu 18.04 compared to the predecessors.

Static interfaces (/etc/network/ nterfaces) have been abandoned in Ubuntu 18.04 and a switch is made to NetPlan. Netplan is a YAML network configuration abstraction for various backends. At the time of writing, NetworkManager and systemd-networkd are supported as backend.

More specifically, this means that your network configuration happens in a yaml file, namely in /etc/netplan/01-netcfg.yaml.

Because of these changes an ifconfig -a output will no longer accurately show if you have more than one IP address linked to your network interface. This is one of the main reasons why the ip command is now mainly used. Some useful options that you can use for this are:

  • ip a
    
    The a stands for address (ip route command can also be used) and shows you linked IP addresses.
  • ip l
    The l stands for list (ip route command can also be used) and shows you network adapters and configuration like mtu and linkstate.
  • ip r
    The r stands for route (ip route command can also be used) and shows the routing tables of your IP addresses.
How do I add an IPv4 address in Ubuntu 18.04?

Step 1 

Connect to the VPS via the VPS console or via SSH and log in.


 

Step 2 

Once logged in you see the current network interfaces and the set IPs by means of the command:

ip a

You will be shown an overview as below.

ubuntu 18 ip a


 

Step 3

Now you add the extra IPv4 address in the network interfaces. Ubuntu 18.04 uses Netplan instead of the static interface file (/etc/network/interfaces). Open your network configuration by executing the following command (you can use another editor of course):

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

A configuration file opens that looks like the screenshot below (nano is slightly modified in the current, newer version).

ubuntu 18 netplan

In the file, adjust the values as follows:

   ethernets:
      ens3:
        dhcp4: no
        dhcp6: yes
        addresses:
          - 149.210.181.124/24
          - 149.210.189.113/24
        gateway4: 149.210.181.1

First, enter your primary IPv4 address with the range /24 addition (in our example 149.210.181.124/24). Enter additional IPv4 addresses on a new line using the same syntax, e.g.: - 149.210.189.113/24


The IPv4 addresses that you enter under 'Addresses' can be found in your control panel. The gateway4 value is the gateway of your primary IP.

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


 

Step 4

To be able to use the new IP address you process the changes using the following command:

sudo netplan apply

 

Step 5

 

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

How do I add an IPv6 address in Ubuntu 18.04?

 Step 1 

Connect to the VPS via the VPS console or via SSH and log in.


 

Step 2 

Once logged in you see the current network interfaces and the set IPs by means of the command:

ip a

You will be shown an overview as below.

ubuntu 18 ip a


 

Step 3

Now you add the extra IPv6 address in the network interfaces. Ubuntu 18.04 uses Netplan instead of the static interface file (/etc/network/interfaces). Open your network configuration by executing the following command (you can use another editor of course):

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

A configuration file opens that looks like the screenshot below (nano is slightly modified in the current, newer version).

ubuntu 18 netplan

In the file, adjust the values as follows:

   ethernets:
      ens3:
        dhcp4: yes
        dhcp6: no
        addresses:
          - 2a01:7c8:aab5:4cd::1/64
          - 2a01:7c8:aab5:4cd::2/64
        gateway6: 2a01:7c8:aab5::1

First enter your primary IPv6 address with the range /64 addition (in our example 2a01:7c8:aab5:4cd::1/64). Enter additional IPv4 addresses on a new line using the same syntax, e.g.: - 2a01:7c8:aab5:4cd::1/64

The IPv6 addresses that you enter under 'Addresses' can be found in your control panel. The gateway6 value is the gateway of your primary IPv6 address.

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


 

Step 4

To be able to use the new IP address you process the changes using the following command:

sudo netplan apply

 

Step 5

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

IPv4 & IPv6

You can combine the steps for ipv4 and ipv6 to statically set both your IPv4 and IPv6 addresses, as follows for example:

ethernets:
      ens3:
        dhcp4: no
        dhcp6: no
        addresses:
          - 149.210.181.124/24
          - 149.210.189.113/24
          - 2a01:7c8:aab5:4cd::1/64
          - 2a01:7c8:aab5:4cd::2/64
        gateway4: 149.210.181.1
        gateway6: 2a01:7c8:aab5::1

 

Do you have a good idea?

Give us your idea! If it's popular we'll add it to the wishlist!

Has this article been helpful?

Create an account or log in to leave a rating.

Comments

Create an account or log in to be able to leave a comment.

Are you stuck?

Ask one of our specialists to assist you

Contact us