The objective of this guide is to configure static IP address on Ubuntu 20.04 Focal Fossa Linux.
In this tutorial you will learn:
- How to set static IP address on Ubuntu Desktop and Server
- How to set static gateway and DNS server
By default your current Ubuntu system uses DHCP server to configure its networking settings. Hence, the configuration of your IP address is dynamic. In many scenarios, simply configuring your router or local DHCP server is a preferred way to set a static address to any host regardless of the operating system in use. Check your router manual and assign the static IP address to your host based on its MAC address using the DHCP service.
Software Requirements and Conventions Used
Category | Requirements, Conventions or Software Version Used |
---|---|
System | Installed or upgraded Ubuntu 20.04 Focal Fossa |
Software | N/A |
Other | Privileged access to your Linux system as root or via the sudo command. |
Conventions |
# – requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command$ – requires given linux commands to be executed as a regular non-privileged user |
How to configure static IP address on Ubuntu 20.04 step by step instructions
Configure Static IP address on Desktop
Configure Static IP address on Server
In this example we will set a static IP address on the Ubuntu 20.04 server to 192.168.1.202/24
with default gateway to 192.168.1.1
and DNS servers 8.8.8.8
8.8.4.4
192.168.1.1
.
- Locate and edit with administrative privileges the
/etc/netplan/50-cloud-init.yaml
file with the following configuration. Update your desired static IP address, DNS server and gateway where appropriate:# This file is generated from information provided by # the datasource. Changes to it will not persist across an instance. # To disable cloud-init's network configuration capabilities, write a file # /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following: # network: {config: disabled} network: ethernets: enp0s3: dhcp4: false addresses: [192.168.1.202/24] gateway4: 192.168.1.1 nameservers: addresses: [8.8.8.8,8.8.4.4,192.168.1.1] version: 2
Save the file.
- To apply the new Netplan changes execute:
$ sudo netplan apply
Alternatively, if you run into some issues run:
$ sudo netplan --debug apply
-
Confirm your new static IP address by using the
ip
linux command:$ ip a
Troubleshooting
Question mark over the network icon on GNOME desktop
The question mark over the network icon on GNOME desktop means that from some reason the network internal self-check failed.