Ubuntu 20.04 — A short guide to network routes and metrics

Varun
2 min readJun 13, 2021

--

Setting static IP’s on Ubuntu based systems can be tricky. Especially if there are multiple interfaces involved. Here is a short guide to ensure that we do not lose network connectivity. This guide is based on Ubuntu 20.04.

  • Check the interface which needs a static IP assigned using:

ifconfig

In this case, we need to assign an IP to enp4s0

  • Open the network configuration file using:

sudo nano /etc/netplan/01-network-manager-all.yaml

Next, add the static IP, Gateway, Subnet mask to the particular interface name (Eg: enp4s0)

Now, suppose we have multiple network interfaces, and would like our internet access to be only through the above enp4s0 interface, we need to set a route-metric parameter as follows. The final yaml file should look something like this!

Finally, a sudo netplan apply would apply the changes!

PS : Lower the metric value, higher the priority of that particular interface / route.

--

--

Varun

A novice here. In hopes of documenting a few things that I’m passionate about and would like maybe a few people to read and understand