How to Configure Network Interfaces on Ubuntu 20.04

There are a lot of guidelines online to show you how to configure the Network Interface. Here is my own records for Ubuntu 20.04.

The configuration file of Network interface is /etc/network/interfaces

The sample of Static IP config on eth0 interface as below


auto eth0
iface eth0 inet static

After the change, use the following command to restart the Networking.

sudo netplan apply

Another method to restart networking is working on a specific network interface. For example ens18

$ sudo ip link set ens18 down $ sudo ip link set ens18 up

How to show the IP address of the Network Interfaces?

Use ifconfig to show the IP address.

If you don’t have this command, install it with the command sudo apt install net-tools

Use IP command to show the IP address

# ip addr show

How to Check Route Table?

ip route show

davidyin@u20:~$ ip route show

default via dev ens18 proto dhcp src metric 100 dev ens18 proto kernel scope link src dev ens18 proto dhcp scope link src metric 100
Other commands I am not using.

Add Static Route

# ip route add via dev eth0

Remove Static Route
# ip route del

Add default gateway
# ip route add default via

Add an IP address to a specific interface
# ip addr add dev eth1

Remove an IP address
# ip addr del dev eth1

I always like to use a Router to assign a static IP to the network device. I just need to know the MAC address then I can do it at DD-WRT router.

Services > Service > Static Leases

The lease expiration is left empty. It means never expire.



Leave a Reply

Your email address will not be published. Required fields are marked *