This tutorial will deal with Ubuntu static IP address configuration. It will provide the reader with a step by step procedure how to set static IP address on Ubuntu Server vianetplanand Ubuntu Desktop usingNetworkManager. Static IP address is recommended for servers as the static address does not change as oppose to a dynamic IP address assignment via DHCP server.
This tutorial will work for all recent versions of Ubuntu, including the latest LTS release, Ubuntu 22.04 Jammy Jellyfish. Ubuntu offers us a GUI method and command line method to set a static IP address, and both methods are covered below.
DID YOU KNOW? Did you know that static IP address can also be achieved by DHCP server? DHCP server allows for a manual MAC address binding to a specific IP address, which will result in client receiving same static IP address with each dynamic IP address request.
In this tutorial you will learn how to:
Set static IP address on Ubuntu Desktop using aNetworkManager
Configure static IP address on Ubuntu server vianetworkddaemon
Ubuntu Static IP configuration
Software Requirements and Conventions Used
Software Requirements and Linux Command Line ConventionsCategoryRequirements, Conventions or Software Version Used
System
Installed or Ubuntu Server/Desktop
N/A
Other
Privileged access to your Linux system as root or via thesudocommand.
Conventions
#– requires givenlinux commandsto be executed with root privileges either directly as a root user or by use ofsudocommand $– requires givenlinux commandsto be executed as a regular non-privileged user
Ubuntu Static IP configuration step by step
Ubuntu Desktop
The simplest approach on how to configure a static IP address on Ubuntu Desktop is via GNOME graphical user interface:
Click on the top right network icon and select settings of the network interface you wish to configure to use a static IP address on Ubuntu.
Open network settings Ubuntu Desktop
Click on the settings icon to start IP address configuration.
Start network configuration to set static IP address
SelectIPv4tab.
Static IPv4 IP address Ubuntu Desktop
Select manual and enter your desired IP address, netmask, gateway and DNS settings. Once ready clickApplybutton.
Enter your desired static IP address
Turn OFF and ON switch to apply your new network static IP configuration settings.
Apply your new network configuration settings
Click on the network settings icon once again to confirm your new static IP address settings.
Confirm your new IP address settings
Ubuntu Server
To configure a static IP address on your Ubuntu server you need to modify a relevantnetplannetwork configuration file within/etc/netplan/directory.
NOTE Carefully check therendererstanza in your configuration file. If the renderer configuration is set toNetworkManagerthen your Ubuntu’s system network configuration is managed by GUI Network Manager. Change the renderer torenderer: networkdif you do not wish to configure your network IP address via Graphical User Interface ( desktop ).
For example, you might find there a default netplan configuration file called50-cloud-init.yamlor01-network-manager-all.yamlwith a following content using thenetworkddeamon to configure your network interface via DHCP:
# 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:
addresses: []
dhcp4: true
version: 2
Default dynamic IP address settings on Ubuntu Server
To set your network interfaceenp0s3to static IP address192.168.1.233with gateway192.168.1.1and DNS server as8.8.8.8and8.8.4.4replace the above configuration with the one below.
WARNING Note, you must adhere to a correct code indent for each line of the block. In other words the prefix number of spaces for each line is important. Otherwise you may end up with an error message similar to: Invalid YAML at //etc/netplan/01-netcfg.yaml line 7 column 6: did not find expected key.
# 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:
version: 2
renderer: networkd
ethernets:
enp0s3:
dhcp4: no
addresses: [192.168.1.233/24]
gateway4: 192.168.1.1
nameservers:
addresses: [8.8.8.8,8.8.4.4]