How to assign static IP address on Ubuntu Linux

Here are the steps to assign an IP address to an Ubuntu Server using the Settings app and Terminal commands.

Ubuntu static IP address

On Ubuntu (version 22.04, 21.04, or older releases), it’s possible to assign a static IP address through the Settings interface or the Terminal using commands, and in this guide, you will learn how.

Once you complete the installation of the Ubuntu Server (or client version), the device will receive a network configuration assigned automatically by the Dynamic Host Configuration Protocol (DHCP) server available in the local network. Although this configuration is enough to access the network and internet, it’s a good idea to assign a static network configuration as you probably are setting up the system to serve different services, such as file and print sharing and others.

The reason is that a dynamic configuration can change at any time, and a static network configuration is permanent, meaning that devices in the network will be able to always reach the server with the address.

This guide will teach you the steps to configure a static IP address for your Ubuntu Server installation. You can also use these instructions for the client version of the Linux distro.

Set static IP address configuration on Ubuntu Linux (GUI)

To assign a static IP address on Ubuntu (server or client) through the Settings app, use these steps:

  1. Open Settings.

  2. Click on Network.

  3. Click the Settings button for the “Wired” network interface.

    Ubuntu network open settings

  4. Click the IPv4 tab.

  5. Select the Manual option for the “IPv4 Method” setting.

  6. Under the “Addresses” section, confirm the static IP address in the “Address” setting — for example, 10.1.4.201.

    Ubuntu assign static IP address

  7. Confirm the subnet mask in the “Netmask” settings — for example, 255.255.255.0.

  8. Confirm the gateway address (usually the router’s IP) in the “Gateway” setting.

  9. Turn off the Automatic toggle switch for the “DNS” setting.

  10. Confirm the DNS address(es) for this static configuration — for example, the router IP address or your preferred DNS address, such as the ones from Google Public DNS, 8.8.8.8, 8.8.4.4.

    Quick note: You have to use a comma (,) to separate multiple addresses.
  11. (Optional) Click the IPv6 tab.

  12. Select the Disable option in the “IPv6 Method” setting.

  13. Click the Apply button.

  14. (Optional) Turn off and on the Wired toggle switch on the “Network” page if the configuration isn’t working.

Once you complete the steps, the Linux distro will start using the new static network configuration.

Set static IP address configuration on Ubuntu Linux (command)

To assign a static IP address on Ubuntu Linux (server or client), use these steps:

  1. Open Terminal

  2. Type the following command to determine the network interface name and press Enter:

    sudo ip a

    Ubuntu view IP config command

  3. Type the following command to open the configuration file and press Enter:

    sudo nano /etc/netplan/01-network-manager-all.yaml
  4. Copy and paste the following configuration (changing the TCP/IP settings with your settings):

    network:
      renderer: networkd
      ethernets:
        ens33:
          addresses:
            - 10.1.4.201/24
          nameservers:
            addresses: [8.8.4.4, 8.8.8.8]
          routes:
            - to: default
              via: 10.1.4.1
      version: 2

    In the command, change “ens33” for the name of your server network adapter name and “10.1.4.201/24” for the static IP address and subnet mask after the forward slash (/) you want to assign to the Ubuntu Server. For example, the “/24” assigns the “255.255.255.0” address. Also, change “8.8.4.4, 8.8.8.8” for static DNS addresses. The comma (,) is only required when setting up multiple addresses. And change “10.1.4.1” for the default gateway of your network (usually the router IP address).

    Ubuntu static IP set commands

  5. Press “Ctrl + O,” “Enter,” and “Ctrl + X” to save the changes and exit the text editor.

  6. Type the following command to apply the new static IP address configuration and press Enter:

    sudo netplan apply
  7. (Optional) Type the following command to confirm the static network configuration and press Enter:

    ip addr show ens33

    Ubuntu confirm IP address

    In the command, change “ens33” to the name of the adapter.

After you complete the steps, the static  IP address configuration will apply to the network adapter on Ubuntu (server or client).