Ubuntu 17 / 18 / 20

From Ubuntu 17.10 and on the /etc/network/interfaces file is no longer used. It uses Netplan. This configuration file is found at /etc/netplan. Now we will edit the configuration file, we recommend to use ‘nano’ to edit the file:

nano /etc/netplan/01-netcfg.yaml

Adding a static IP in the netplan file is easier than you might think. Just add a comma after the current address and add the new one. We have highlighted this.

# This file describes the network interfaces available on your system
# For more information, see netplan(5).
network:
 version: 2
 renderer: networkd
 ethernets:
   ens3:
     dhcp4: no
     dhcp6: no
     addresses: [192.168.1.50/24,192.168.1.51/24]
     gateway4: 192.168.0.1
     nameservers:
       addresses: [93.190.136.10,217.23.0.121]

To apply the new configuration, apply with the following in the command line:

netplan apply

If you want to add more IP addresses, simply add this after the one that was just added and separate by using a comma. Do not add any spaces in between.

Note: if you receive an error, please check the configuration as netplan is very space and character sensitive. If you don’t use the exact amount of spaces in the above example it will fail.

If you are unsure if your configuration is correct feel free to contact us here.

Learn more about our services: worldstream.com