ubuntu set static ip

Dynamic IP assignment generally works fine on Ubuntu, but if you plan to configure the system as a server, setting a Static IP address is a good idea. Setting a new static IP is also an effective fix for IP-related networking issues.

Ubuntu systems typically use the NetworkManager or networkd daemons for managing network connection settings. We’ll cover multiple ways to set a static IP through these backends.

Before You Begin

We’ll deal with Class C IPv4 addresses (e.g, in this tutorial as that’s the norm. This means the subnet prefix is 24, and you should only change the last octet (77 in the above example) when setting the static IP address. 

The rest of the address (192.168.10) should match your default gateway. For instance, the new IP address could be something like  

Aside from this, the new static IP shouldn’t already be assigned to another device. You should also consider setting the IP outside of the DHCP range to minimize the chance of IP conflict.

NetworkManager GUI

If you’re new to Ubuntu, you’ll likely find NetworkManager’s graphical interface to be the most intuitive.

  1. Launch the Settings app and open the Network (Ethernet) or Wi-Fi tab as appropriate.
    ubuntu network settings
  2. Click on the Settings button and switch to the IPv4 tab.
    ubuntu ipv4 automatic dhcp
  3. Select Manual and provide the IP Address, Netmask, and Gateway. You can optionally fill in the DNS server as well if you’d like. Then, click on Apply and restart the network to apply the changes.
    apply ip changes ubuntu
  4. You can click on the Settings cog again to verify the change.
    ubuntu ip configuration


Netplan is the standard method for configuring networking on Ubuntu. It reads the network configurations at boot from /{lib,etc,run}/netplan/*.yaml and writes this configuration to /run. Then, it hands off device control to the chosen daemon (networkd or NetworkManager).

You’ll find the default netplan config file named 01-network-manager-all.yaml or 50-cloud-init.yaml in the /etc/netplan directory. Let’s see what config changes you need to make to set the static IP. 

Start by checking the interface’s device name.

nmcli device status

Use a text editor like nano to edit the config file.

sudo nano /etc/netplan/*.yaml

Copy the following configuration.

  version: 2
  renderer: NetworkManager
      dhcp4: no
        - to: default
          addresses: [,]

This configuration tells Netplan to use the NetworkManager daemon. This part is included in the default config too, but after that, we’re using our own configuration to set the static IP.

  • We specified that we’re modifying the enp42s0 interface, which we know is our Ethernet connection from earlier. 
  • We set DHCP to disabled and set the interface’s IP address with the subnet prefix ( 
  • Next, we defined routing via the default gateway and set the DNS servers. 

You can change these values while keeping the number of prefix spaces the same as above. Test if your own configuration will work with

sudo netplan try 

If the config is ok, you’ll see a configuration accepted message. You can confirm that the static IP has been set with

ip a


In the first method, we used the NetworkManager GUI from the Ubuntu control center to set a static IP. This time, we’ll show how you can use the command-line version (nmcli) to do the same thing.

Start by checking the connection name.

nmcli c

Now, use nmcli to modify your connection and set the static IP like so

sudo nmcli con modify 'Wired connection 1' ipv4.method manual ipv4.addresses ipv4.gateway ipv4.dns ","
  • We’re specifying that we’re modifying ‘Wired connection 1’, which we know is our Ethernet connection from earlier. 
  • We set the IPv4 method to manual. 
  • We set the IP address with the subnet prefix.
  • We set the default gateway.
  • Finally, we set the DNS servers.

You can set your own values in place of these and start the connection with the new parameters like so

sudo nmcli con up id ‘Wired connection 1’

Finally, you can confirm that the static IP was set with

ip a

Nmcli Interactive Editor

If setting the Static IP as done above feels confusing, or you want to learn to make further connection changes, the interactive editor is a good alternative. To start, edit the connection with it like so

sudo nmcli con edit ‘Wired connection 1’

Use the following commands to set the Static IP. As done earlier, we’re setting the IP assignment method to manual, then entering the IP address, default gateway, and DNS server parameters.

set ipv4.method manual 
set ipv4.addresses 
set ipv4.gateway 
set ipv4.dns,

If you want to learn to use the editor further, enter help inside the editor to display the usable commands. Then, use the print and describe commands to learn about the configurable settings (e.g., print ipv4, describe ipv4.gateway, etc.).

Once you’re satisfied with your new configuration, apply the changes with

save persistent

Exit nmcli and verify the static IP change with

ip a


If you’re using the systemd-networkd daemon to manage your network configurations, you can also directly edit the config file to set a static IP address.  

Use a text editor to edit the config file. We’ll use nano.

sudo nano /etc/systemd/networkd.conf

Use the format provided below for your configuration.



You can change the interface name, IP address, gateway, and DNS parameters as appropriate.

Once you’re satisfied, press Ctrl + O to save the new config. Then, apply the changes by restarting the networkd service.

sudo systemctl restart systemd-networkd

Ip Command

If you only need a static IP address for your current session, you can use the ip command to temporarily change your IP address.

Note the device’s logical name using

sudo lshw -c network

Now, note the current IP address with

ip a

Add a new IP address to the device like so.

sudo ip addr add dev enp42s0

Here, we added with netmask 24 to the enp42s0 interface, which is our Ethernet connection. Now, remove the previous IP address like so

sudo ip addr del dev enp42s0

Finally, verify that the static IP was successfully set with

ip a

Do keep in mind that this IP change will revert back after the connection resets. This can mean a loss of connection, network daemon restart, or system restart.

Anup Thapa

Senior Writer

Anup Thapa is a Linux enthusiast with an extensive background in computer hardware and networking. His goal is to effectively communicate technical concepts in a simplified form understandable by new Linux users. To this end, he mainly writes beginner-friendly tutorials and troubleshooting guides. Outside of work, he enjoys reading up on a range of topics, traveling, working out, and MOBAs.