From Ubuntu 18.04, a switch was made to configure network using NetPlan written in YAML. In this article, we will learn how to configure additional IPs in newer versions of Ubuntu, such as Ubuntu 18.04, 19.04, 19.10 and 20.04 using Netplan.
If you're looking to configure static IPv4 network, click on here.
A side note on this, YAML is strict on indentation so we will use 2 spaces through out the guide.
We will have 2 cases while configuring Additional IPv4.
All the IPv4 belong to one subnet.
Example: 18.104.22.168/24, 22.214.171.124/24 and 126.96.36.199/24 belong to a single subnet.
IPv4 belong to a different subnets.
Example: 188.8.131.52/24 and 184.108.40.206/24 belong to a different subnet.
Edit the default configuration file,
Make the following changes to it.
network: version: 2 renderer: networkd ethernets: ens3: dhcp4: no addresses: - 220.127.116.11/27 - 18.104.22.168/27 - 22.214.171.124/27 gateway4: 126.96.36.199 nameservers: addresses: - 188.8.131.52 - 184.108.40.206
Then apply the changes made to the configuration file by
Test if the network is up by running
This should show all the IPs configured in
We will not modify the default configuration file BUT we will create a new configuration file for each IP that belongs to a different subnet.
We will create a new network configuration file,
Add the following content into it
network: version: 2 renderer: networkd ethernets: ens3: dhcp4: no addresses: - 220.127.116.11/24 gateway4: 18.104.22.168 nameservers: addresses: - 22.214.171.124 - 126.96.36.199
Apply the configuration changes by running
You can create more number of network configuration files depending on the subnets you have.
And to confirm if the additional IPs are working, run
You should get something similar to the following output:
This concludes our topic of configuring additional IPv4 on Ubuntu.
If you can not configure and facing technical difficulties, kindly reach out to us via Support Ticket.