Ubuntu 22.04 network configuration

Canonical prides itself on making their Ubuntu 22.04 Jammy Jellyfish Linux operating system very simple to use, even if you do not have a lot of technical knowledge. Despite its simplicity, Ubuntu has a lot going on under the hood to make things work, including networking configuration that allows you to connect to local devices or servers across the world.

Although Ubuntu and its networking settings should normally, and ideally, work without a hitch, there may come a time where you need to roll up your sleeves and do some tinkering to get things sorted out. Or, maybe you’re just curious about various network configuration on the system.

In this tutorial, we will show you how to get started with network configuration on Ubuntu 22.04 Jammy Jellyfish. This can include simple tasks like viewing your system’s IP address, to more complex things like restarting your networking service, which may come in handy when troubleshooting network issues. Read on to start learning about network configuration on Ubuntu 22.04.

In this tutorial you will learn:

  • How to get local and public IP addresses
  • How to get DNS IP address and default gateway
  • How to set static IP address from GUI and command line
  • More Netplan configuration settings
Ubuntu 22.04 network configuration
Ubuntu 22.04 network configuration
Software Requirements and Linux Command Line Conventions
Category Requirements, Conventions or Software Version Used
System Ubuntu 22.04 Jammy Jellyfish
Software Netplan (installed by default)
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 get local and public IP addresses




If your system is connected to the internet, you are most likely using at least two IP addresses on your system. One IP address is your system’s local address, which is used to communicate with other devices on your home network. This includes your router and any devices you have connected to it.

Your public IP address is the one that devices over the internet will see you connecting from. This is an IP address that is routable on the world wide web, and will grant you connectivity to other servers and routers around the world. Typically, a home network has one public IP address, which is shared by every device that is connected to your router. Of course, other types of networking scenarios exist, but this is the most common.

  1. To see your local IP address, you can run the following command in terminal:
    $ ip a
    

    Locate the requested network interface and check for the assigned IP address. Additionally, the above command also reveals the network interface hardware address (also known as the MAC address).

    Retrieving local IP address with ip a command on Ubuntu 22.04
    Retrieving local IP address with ip a command on Ubuntu 22.04

    On our test system, the local IP address is 10.0.2.15.

  2. There are also various ways to get your public IP address. You can go to a website like ip chicken or execute one of the following commands in terminal:
    # echo $(wget -qO - https://api.ipify.org)
    OR
    # echo $(curl -s https://api.ipify.org)
    
  3. To check for currently used DNS server IP address, execute this command:
    $ systemd-resolve --status | grep Current
    
  4. To display default gateway IP address, run this command:
    $ ip r
    
  5. You can also check for this information from your desktop GUI. To check for the internal IP address, default gateway, MAC address and DNS server settings on Ubuntu 22.04 Jammy Jellyfish desktop first open Settings and click on Network menu and hit the gear wheel of the desired network interface.
    How to find my IP address, default gateway and DNS server on Ubuntu 22.04 Jammy Jellyfish desktop
    How to find my IP address, default gateway and DNS server on Ubuntu 22.04 Jammy Jellyfish desktop

How to set static IP address

You can configure a static IP address on Ubuntu 22.04 Jammy Jellyfish either from command or GUI. First, we will cover the instructions to configure one from GNOME GUI.



  1. Start by opening Settings and click on Network menu and hit the gear wheel of the desired network interface.
  2. Next, click the IPv4 tab, and then the manual configuration option.
  3. Fill out your desired IP address, subnet mask, and default gateway. Do not forget to also specify a custom DNS server if you wish. When you are done, click Apply to finalize the changes.
    Configuring a static IP in GNOME GUI on Ubuntu 22.04
    Configuring a static IP in GNOME GUI on Ubuntu 22.04

It is also possible to configure a static IP address from command line, which will be essential if you are running a server and do not have access to a GUI desktop.

  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. Save and exit the file after you have applied your changes.
    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
    
  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 a command:
    $ ip a
    

More Netplan configuration settings

Ubuntu 22.04 Jammy Jellyfish uses Netplan to manage many network configuration settings. This is a frontend made by Canonical, and is meant to make the configuration process more simple.

To learn more about Netplan configuration on Ubuntu 22.04, it is recommended that you check our guide on Netplan network configuration tutorial for beginners.

Note that one of the most essential Netplan commands you are likely to need in the case of troubleshooting is how to restart the networking service. That can be done with following command:

$ sudo netplan apply


Closing Thoughts

In this tutorial, we learned about basic network configuration on Ubuntu 22.04 Jammy Jellyfish Linux. We saw this through various processes such as how to view or set a static IP address, MAC address, default gateway, DNS server, etc. We also saw how to manage the network configuration from both command line and GUI.