How to configure static IP address on Ubuntu 22.04 Jammy Jellyfish Desktop/Server

The purpose of this tutorial is to configure a static IP address on Ubuntu 22.04 Jammy Jellyfish Linux. When it comes to IP addresses on Ubuntu 22.04, you have two main options for how you configure your network interfaces. You can either obtain an IP address automatically with DHCP, or configure the system to use a static IP address, which never changes.

In this tutorial, we’ll show how to configure a static IP address on Ubuntu 22.04. This can be done either through GUI or command line, and we’ll be going over both methods. Once a static IP address is configured, it won’t change again unless you manually change the IP address later, or turn DHCP on.

DID YOU KNOW?
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.

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
Static IP address on Ubuntu 22.04 Jammy Jellyfish Desktop/Server
Static IP address on Ubuntu 22.04 Jammy Jellyfish Desktop/Server
Software Requirements and Linux Command Line Conventions
Category Requirements, Conventions or Software Version Used
System Ubuntu 22.04 Jammy Jellyfish
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 22.04 step by step instructions




Follow the appropriate section below depending on whether you would like to configure a static IP address via desktop GUI or via command line.

Configure Static IP address on Desktop

  1. Click on the top right network icon and select settings corresponding to the network interface you wish to assign with the static IP address.
    Open network settings from top right corner of GNOME desktop
    Open network settings from top right corner of GNOME desktop
  2. Next, click on the gear box icon next to your network connection you wish to configure. This could be wired or wireless connection.
    Open the network settings of the interface that you want to configure
    Open the network settings of the interface that you want to configure
  3. Click on the IPv4 or IPv6 tab, depending on which type of IP you want to configure. Then, select “manual” and fill in your desired IP address, subnet mask, and default gateway. Optionally, you can also fill in a DNS server. Click “apply” when you’re done.
    Fill out the desired network information for the interface
    Fill out the desired network information for the interface
  4. Restart your network by using the provided ON/OFF switch.

    Restart the network interface for changes to take effect
    Restart the network interface for changes to take effect



  5. Check your new static IP address configuration by clicking on the cog wheel.
    Verify your new static IP address configuration
    Verify your new static IP address configuration

Configure Static IP address on Server

In this example we will set a static IP address on the Ubuntu 22.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, and 192.168.1.1.

  1. Locate and edit with administrative privileges the /etc/netplan/01-network-manager-all.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 and exit the file when done.

    Configure static IP address on Ubuntu 22.04 Server
    Configure static IP address on Ubuntu 22.04 Server
  2. To apply the new Netplan changes execute:
    $ sudo netplan apply
    

    Alternatively, if you run into some issues run:

    $ sudo netplan --debug apply
    



  3. Confirm your new static IP address by using the ip Linux command:
    $ ip a
    
    Check current IP address
    Check current IP address

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.

The workaround is to disable the Connectivity Checking switch.

Disable the Connectivity Checking switch
Disable the Connectivity Checking switch

Closing Thoughts




In this tutorial, you saw how to configure a static IP address on Ubuntu 22.04 Jammy Jellyfish Linux. We performed the steps from both command line and GUI, so that you will be covered whether you are using a desktop computer or just the command line on a server. You can always revert your configuration to go back to DHCP whenever needed.