How to Setup Static IP address on Ubuntu20.04 Server

UbuntuNetwork,Ubuntu

If GUI is not installed on Ubuntu, you need to setup Network configuration by editing some files.

Here is an example of how to set static IP address on Ubuntu 20.04.


Move the default configuration file.

$ mv /etc/netplan/00-installer-config.yaml /etc/netplan/00-installer-config.yaml.bkup

Edit Network Configuration file to add a static IP address.

$ vi /etc/netplan/01-netcfg.yaml

Example: 01-netcfg.yaml file

network:
	ethernets:
        #Network Interface name
		ens3:
			dhcp4: no
			addresses: [172.16.201.12/16]
			gateway4: 172.16.0.1
			nameservers:
				addresses: [9.9.9.9]
			dhcp6: no
	version: 2

*You need to replace the network interface name with the appropriate one.

Enable the setting.

$ netplan apply

Check the Network Settings.

$ ip addr