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 address 192.168.1.12 netmask 255.255.255.0 gateway 192.168.1.1
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 192.168.1.1 dev ens18 proto dhcp src 192.168.1.158 metric 100 192.168.1.0/24 dev ens18 proto kernel scope link src 192.168.1.158 192.168.1.1 dev ens18 proto dhcp scope link src 192.168.1.158 metric 100 davidyin@u20:~$
Other commands I am not using.
Add Static Route
# ip route add 10.10.20.0/24 via 192.168.1.100 dev eth0
Remove Static Route
# ip route del 10.10.20.0/24
Add default gateway
# ip route add default via 192.168.1.100
Add an IP address to a specific interface
# ip addr add 192.168.1.5 dev eth1
Remove an IP address
# ip addr del 192.168.1.5/24 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.