Changing the IP Address on Ubuntu Server 20.04

To modify the IP address on Ubuntu Server 20.04, first you will need to SSH into your system.

You need to change directory to the location that the IP address configuration is.

cd /etc/netplan

Now you can run the command "ls" to show the files in this directory and locate the configuration yaml file. In my case, it is 00-installer-config.yaml. We need to edit this file with nano.

sudo nano /etc/netplan/00-installer-config.yaml

From here, change the IP address information. I will leave an example at the bottom. Once the IP is changed, use CTRL-X to exit, press Y to save, and press enter. You should now be back to your command line. Run the following command.

sudo netplan apply

If you need to change the hostname, run the following command, and change the name to reflect what you need.

hostnamectl set-hostname UbuntuHostName

Example

network:
  ethernets:
    ens160:
      addresses:
      - 192.168.1.5/24
      gateway4: 192.168.1.1
      nameservers:
        addresses:
        - 192.168.1.1
        search:
        - domain.local
  version: 2

Back to Ubuntu Guides

Add a comment