I am a new with Linux, having years experience with Windows servers/desktops and am having issues setting a static IP. I am using a method used for previous versions of Ubuntu, which doesn't seem to work with 16.04

I have used the command sudo nano /etc/network/interface and added the following

iface enp0s25 inet static

I have rebooted the system and the Ethernet is pretty much dead, ping doesn't work at all. I have tried to modify /etc/NetworkManager/NetworkManager.conf and made the following changes

#dns=dnsmasq (comment out the dnsmasq)
managed=true (changed from false)

With this I can get Ethernet to work sporadically, however it eventually fails.

I have tried this configuration on two other machines plus a virtual machine as well and all have the same results. I can confirm these settings work fine when I install Windows on any of these machines. As well when I let DHCP auto configure, everything works fine no issues.

I figure I am missing something here, setting up a static IP should not be difficult at all.

  • the only thing I notice and it may have just been a typo here but I would change the Dns-nameservers to dns-nameservers probably not going to do anything to solve this issue but may stop other issues from happening
    – John Orion
    Commented May 2, 2016 at 0:20
  • 1
    Dns-nameservers is acceptable syntax wise so it shouldn't be an issue. When it was working with DHCP, did you run an ifconfig to check the interface name or did you assume it was enp0s25? Also do you have an auto enp0s25 at the top of your config file? If you don't its possible that the interface is just not coming up on boot.
    – Andrew
    Commented May 2, 2016 at 0:30
  • Please edit your question and post the exact content of your /etc/network/interfaces file. While editing your message, highlight the text of this file, then click on the {} code link on the top of the message editor so that it will properly format the text making it easier for us to read the content. Also do execute this command ip address and perform the same steps to {} (code format) that output. Commented May 2, 2016 at 4:05

9 Answers 9


I had the same problem and this was my solution:

sudo nano /etc/network/interfaces

and paste (altering for your network) this under # The primary network interface:

auto enp0s25
iface enp0s25 inet static

You can get correct interface name using Terminal command ifconfig -a on ubuntu 16.04 or ip address on 18.04+

Shutdown your Virtual Machine and then!!! Go to network settings and click on refresh MAC address button a few times :)

enter image description here

and start your VM and you should get internet!

UPDATE 20.02.2019

For ubuntu 18.04+ you need to edit this file


            addresses: []
            dhcp4: no
              addresses: [,]
            optional: true
    version: 2
  • 2
    Great thanks I appreciate it. It seems to work now, with no problems. It is very solid right now!
    – TeeStar
    Commented May 7, 2016 at 2:07
  • In addition to the dns-nameservers fix, I had to use this fix: askubuntu.com/questions/574569/… My ISP is monkeybrains.net.
    – BSalita
    Commented Aug 22, 2016 at 23:38
  • does not work in my VMWare player with ubuntu16.04
    – ZhaoGang
    Commented Mar 8, 2021 at 6:26
  • I suppose you didn't configure the network properly in VM-Ware Player.... but your bigger problem is: Why do you still use Ubuntu 16.04... The support is "end of life"...
    – lewis4u
    Commented Mar 8, 2021 at 7:33

Setting the static IP address as above in the accepted answer here works, but one has to flush the old IP addr setting and then restart networking.service:

sudo ip addr flush enp0s25
sudo systemctl restart networking.service

Then verify it is correct:

ip add
  • 2
    The flush was necessary to avoid the old address being present on the interface (based on ip addr). The systemctl restart works too, though ifdown and ifup on the interface will work more selectively.
    – RichVel
    Commented Nov 28, 2016 at 13:28
  • 2
    thx @Grant. adding flush made this work Commented Feb 1, 2017 at 13:19
  • 3
    In Ubuntu 16.04 and newer flush is necessary! Commented May 2, 2017 at 12:05
# interfaces(5) file used by ifup(8) and ifdown(8)
# auto lo
# iface lo inet loopback
auto enp2s0 
iface enp2s0 inet static
  • 1
    ifcace should be iface on line 5 Commented Jun 28, 2017 at 14:33
  • @twoleggedhorse: Fixed the typo for the answer but I had to add a few # in the first line because you cannot have an edit without at least 6 changed characters that are not whitespace Commented Nov 28, 2017 at 17:11

sudo vim /etc/network/interfaces

    auto lo
    iface lo inet loopback
    auto eth0
    iface eth0 inet static

sudo ifdown eth0 && sudo ifup eth0

  • 10
    Hi @lanni654321, maybe you should edit your answer and add a few word, briefly explaining what you are doing and why? i think that would make your answer even more helpful, what do you think? Commented Oct 14, 2016 at 6:58

I had the same problem and the solution "was" simply... for me, at least.

auto ens160
iface ens160 inet static

#Add internal route
up route add -net gw dev ens160

And, create an empty file with the name of the network interface in:

~$ touch /etc/network/interfaces.d/ens160

It works...


I had the same problem and this was my solution: Remove all empty lines at the end of the file /etc/network/interface.


If your server is showing that old IP as well as new assigned IP, simply restart your server. It will automatically flush old IP and persist the new one.
And if you don't want to restart your server, use this command:

sudo ip addr flush <your-interface-here>


Run this simple commands to see if your network interface(s) are set to come up when the machine boots / restarts.

grep "auto" /etc/network/interfaces

If no lines are printed to standard output, then open /etc/network/interfaces with a text editor (vi, nano, sed) and hopefully you will see something similar to the image below below.

A default /etc/network/interfaces file

Obviously, if grep did not return any lines to the terminal window, the format of your /etc/network/interfaces cannot be very similar at all. :-) However, follow the format of the auto lines.

auto lo
(Loopback configuration follows)

auto enp0s3
(primary interface configuration follows)


Now, on your machine.

auto yourInteraceNameHere
(your interface configuration follows)

Don't know which interface names are available? Run this command.

ifconfig -a

The following command will return just the names of the network interfaces.

ifconfig -a | grep encap | awk {'print $1'}

enter image description here


I used to set static IPs on my Ubuntu machines and then I noticed that I can just assign the IP address using my router. This may be the simplest solution. Just log in to your router, find the attached devices, and assign the IP address there.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .