How to Set a Static IP Address in Ubuntu

By default, the IP address of your computer – whatever it may be – is probably “dynamic.” It’s mostly a convenience thing because network admins (and less techy computer users) don’t need to go through the hassle of creating individual IP addresses for each computer on their network. But there are also good reasons why you may want to set a static IP address in Ubuntu – from improved security, to gaming, faster Internet speeds, and port forwarding.

In this article we’ll show you how to go about setting a static IP address in Ubuntu.

To set a static IP address, you’ll first need to get the tool that shows you your IP information (essentially the equivalent to ipconfig in Windows). To install it, go to the Terminal and enter:

This will install the Net Tools app.

Once you’ve done that, you can check most of your IP information by going to the Terminal and entering ifconfig. The crucial information to remember from the results is highlighted below (specifically, inet/ip address and netmask):

set-static-ip-in-ubuntu-ifconfig

There are a couple of bits of info missing from this, however – namely the DNS and the Gateway. To bring that information up, type:

where “eno1” should be replaced with the network device name of your PC as shown in ifconfig (it could be “eth0,” for example). The crucial info you need to remember from here are the numbers next to IP4.GATEWAY, IP4.DNS[1] and IP4.DNS[2].

set-static-ip-in-ubuntu-gateway-etc

Once you have all the information, you’ll need to go to the network connection editor in Ubuntu, a convenient graphical interface that lets you customize your IP settings. In the Terminal, enter nm-connection-editor to open it.

Next, pick the device that connects to the Internet (in my case “Wired connection 1”), then click the “IPv4 Settings” tab. Change the “Method” to “Manual” using the dropdown, then in the “Addresses” box below, enter the following:

Address: Enter the static IP you want to use. Remember that it needs to be on the same subnet as your gateway, so the numbers after the last point need to be the same. My Gateway is 192.168.0.1, so I made my static IP address 192.168.0.11.

Netmask: Refer to the info you got from “ifconfig” and type in the same Netmask as what’s listed.

Gateway: Refer to the info in “nmcli dev show” and type the gateway listed at “IP4.GATEWAY.”

DNS servers: Same as with gateway, but type in the numbers listed at IP4.DNS[1] and IP4.DNS[2].

In the end my settings looked like those below.

set-static-ip-in-ubuntu-connection-editor

When you’re ready, click “Save,” then go to the Terminal and type:

to restart your network with the new static IP configuration. You can check that it’s work by running ifconfig again and seeing if your new IP address is now there. If that fails, just reboot your PC, and the new settings should implement themselves.

set-static-ip-in-ubuntu-changed

You’ll now have a static IP configuration on your Ubuntu computer. Remember that you’ll need to do this for each device on your network, as the static IP only applies to individual devices and not the entire network.

Image credit: server configuration command lines on a monitor by DepositPhotos

Leave a Reply

Yeah! You've decided to leave a comment. That's fantastic! Check out our comment policy here. Let's have a personal and meaningful conversation.