Configure static IP on Ubuntu 16

Share this post to your friends !
  • 1

SystemMen - In this article, I will guide you through the static IP configuration on Ubuntu server 16. Using IP is a common requirement when you build your system, you need to manage your IP closely and clearly.

Check current configuration

You open the ssh window to Ubuntu machine, type the following command to check if the server is currently configured DHCP or static IP configuration. For example, my server has two interfaces, enp0s3 and enp0s8. I want to implement on enp0s8.

cat /etc/network/interfaces | grep enp0s8
configure-static-ip-on-ubuntu-16-01 Configure static IP on Ubuntu 16
Check current configuration.

As you can see in the image above, the interface is currently configured to IP through DHCP.

Set static IP for the interface

To set the static IP for the enp0s8 interface, type the following command to open the configuration file:

nano /etc/network/interfaces

Type the following if you are a regular user:

sudo nano /etc/network/interfaces

The configuration file will open similar to the image below.

configure-static-ip-on-ubuntu-16-02 Configure static IP on Ubuntu 16
File configuration interface initially.

Now delete the following two lines in the file.

auto enp0s8
iface enp0s8 inet dhcp

Then, you copy the following code to the place just deleted 2 lines above.

auto enp0s8 
iface enp0s8 inet static


  • the static IP assigned to the interface.
  • netmask used for interface, this is /24.
  • gateway.
  • declare IP of DNS server, here we use DNS google.
configure-static-ip-on-ubuntu-16-03 Configure static IP on Ubuntu 16
Add static IP setup code.

After you finish adding, press Ctrl + X -> press y -> press Enter. This will save the file.

Next you type the following command to flush the old IP, you must be careful at this step. If you were previously ssh over the old IP, after you run this command, you will be disconnected from ssh.

sudo ip addr flush enp0s8

Then, you run the command to restart the network service so that the interface can receive the new IP.

sudo systemctl restart networking.service

Now you can check the new IP:

ip a


With this tutorial, you were able to completely configure a static IP for a server running Ubuntu server 16.

If you liked this article, then please subscribe to our YouTube Channel for more video tutorials. You can also find us on Twitter and Facebook.

Share this post to your friends !
  • 1
If you appreciate what we share in this blog, you can support us by:
  1. Stay connected to: Facebook | Twitter | Google Plus | YouTube
  2. Subscribe email to recieve new posts from us: Sign up now.
  3. Start your own blog with SSD VPS - Free Let's Encrypt SSL ($2.5/month).
  4. Become a Supporter - Make a contribution via PayPal.
  5. Support us by purchasing Ribbon Lite Child theme being using on this website.

We are thankful for your support.

«« »»

Got something to say? Join the discussion

Please keep in mind that all comments are subject to our Comment Policy. Your email address will not be published.
This site uses Akismet to reduce spam. Learn how your comment data is processed.