Ubuntu Network Configuration
Ubuntu 20 uses netplan for network configuration. In order to change the IP settings through the shell/command line, you'll need to follow these steps.
First, get your network adapter name by running the following command and finding it in the list (the one labeled lo
is the loopback and should not be changed):
ip addr
Next, edit the network configuration with the following command:
sudo nano /etc/netplan/00-installer-config.yaml
If setting the OS to use DHCP, modify the file to look like this (ens160
is the name of our network adapter and must be modified if your network adapter is different):
network:
ethernets:
ens160:
dhcp4: true
version: 2
IMPORTANT: Be sure to keep the indentation of 2 spaces inset from one level to the next as it is very critical for the configuration to work.
If setting up a static IP, modify the file to use the following format modifying the addresses, gateway, and nameserver addresses as needed (ens160
is the name of our network adapter and must be modified if your network adapter is different):
network:
ethernets:
ens160:
dhcp4: false
addresses: [192.168.1.110/24]
nameservers:
addresses: [1.0.0.1, 1.1.1.1]
routes:
- to: default
via: 192.168.1.1
version: 2
Finally, run the following command to make the new network settings take effect:
sudo netplan apply
No Comments