Skip to Content

Configure Ubuntu Server 16.04 to use a static IP address

After installing Ubuntu, you might find the IP address has been configured to use a DHCP server and is being assigned a dynamic IP address. In this tutorial, you’ll learn how to configure Ubuntu to use a static IP address.

Note: For the latest version of Ubuntu, see configure Ubuntu Server 18.04 to use a static IP address

Configuring Ubuntu Server 16.04 to use a Static IP Address

In the following example, we will make the IP address static so that the server always starts with 192.168.1.33.

Open the network interfaces config file with your favorite text editor. In this post we will use vim.

sudo vim /etc/network/interfaces

Change the word dhcp to static and then add the following settings below it.

auto ens160
iface ens160 inet static
address 192.168.1.33
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
gateway 192.168.1.1
dns-nameservers 192.168.1.1

Note: The interface name might be different for you (ethX or ensX). You will also need to change the IP address and gateway to what matches your required setup.

Now restart the server using the following command to make the changes take effect.

sudo reboot

Once the server reboots, you should now be able to connect using the new IP address (192.168.1.33) and it will keep this IP address during future restarts.