I've installed Ubuntu 14.04 LTS Server in my machine on a separate hard drive alonside my Windows 7 installation. The Windows OS has full network connectivity and internet access through the Ethernet, but the Ubuntu installation does not.

I have a hunch that this could be because my router which sees 2 different computers with the same MAC address, and the DHCP is not working. How do I assign the machine a common static IP so that both partitions can use my network? I am new to Ubuntu and I couldn't figure out which file to edit so that I can assign the static IP.

  • 1
    Hi & Welcome to AU. I'm actually lost when you say Windows & Ubuntu on a separate partition. Because either it has to be a dual boot which will run separately or else it has to be a VM (virtual machine). Can you please elaborate on how both of these OS operates and configured?? :)
    – AzkerM
    May 21, 2014 at 17:52
  • 1
    You WILL have problems with two simultaneously connected machines with the same MAC address, but not if they are running at different times. So your problem is probably in some other place, if I understand well (and even if you have the server in a VM, the VM will solve the MAC problem for you; each VM has its own unique MAC).
    – Rmano
    May 21, 2014 at 18:08
  • See help.ubuntu.com/14.04/serverguide/network-configuration.html . The router doesn't see two computers ; it sees the same interface card (NIC) no matter which is running.
    – belacqua
    May 21, 2014 at 19:24

5 Answers 5


I'm not sure if this will solve your problem, but this answers your question and I think it's worth a shot.

To assign a static IP, you need to edit /etc/network/interfaces.

The interface will probably be called eth0.

The current entry will look something like:

auto eth0
iface eth0 inet dhcp

You will need to change this to:

auto eth0
iface eth0 inet static

You will have to change the numbers around depending on your network, but you can find out the information by checking out ipconfig from Windows.

Make sure you choose an address outside the address space of the DHCP server.

Then restart networking sudo service networking restart. If that gives you trouble, reboot the machine.

  • @dan08- I believe dns-nameservers is also needed here. I suggest you edit your answer.
    – chili555
    May 22, 2014 at 14:47
  • 24
    Restart eth0 with sudo ifdown eth0 && sudo ifup eth0 instead of the last command. Jan 27, 2015 at 4:45
  • In my env gateway ended with .254, not sure if this applies for everyone. Other than that this answer works for 14.14
    – mau
    May 9, 2015 at 15:59
  • 1
    Does not work by me, I still got DHCP IP. Sadly it is coming from a hybrid modem + router device, which does not have to feature to set static IP by MAC address. :S I might need to buy a router. :S According to ifdown eth0 the interface is not configured.
    – inf3rno
    Feb 28, 2016 at 16:57
  • but now the network would start automatically
    – Allan Ruin
    Aug 10, 2016 at 16:10

Set your IP address changes in /etc/network/interfaces. Example:

auto eth0
iface eth0 inet static


Don't give your DNS configurations in /etc/resolv.conf because while we restart the server sometimes the configuration get erased.

So use vim /etc/resolvconf/resolv.conf.d/base (while updating configs in this it doesn't get removed)


search  (domain name)

Save and then restart your server, this fixed my static issue! :)

  • 3
    Bare in mind that your device name can be other than eth0. Mine are enp1s7 and enp2s15. I have 2 LAN card. May 5, 2016 at 21:40

I found I had to include the dns settings:

auto lo enp0s25

iface lo inet loopback

iface enp0s25 inet static
    dns-search example.com

See https://help.ubuntu.com/lts/serverguide/network-configuration.html

  • you missing gateway Jan 9, 2018 at 0:22
  • yes, thanks @Pavel Niedoba, now that I look more closely on my server, I'm not sure how I missed that. Fixed. Jan 10, 2018 at 2:37
  • 1 is not a valid IP address
    – papaiatis
    Mar 20, 2018 at 12:45

Ubuntu 20.04 doesn't have /etc/network/interfaces and uses /etc/netplan/<config file>.yaml instead.

The .yaml config file is auto generated and can have many names but as long as it has .yaml extension it should work fine. Mine was 50-cloud-init.yaml on one machine, 00-installer-config.yaml on another.

To set the ip to, in /etc/netplan/<config file>.yaml:

            dhcp4: false
            addresses: []
              addresses: [,,]
    version: 2

You can look up what your current gateway is using ip route and put that in instead of

Also instead of eth0 you can have a different name for your network. If so, keep your network's name there.

Then sudo netplan apply

This kicked me out of SSH because I was SSHed through an old ip. I had to reboot the computer manually. Restarting router is a good idea too at this point to clear possible ip conflicts.

Also I found suggestions to edit the generator of this yaml file in /etc/cloud but I found no fool-proof docs how to do this. Instead, Canonical provides https://netplan.io/examples with a whole bunch of copy-paste configurations for the config.yaml file, which seem like a great approach for most cases.


Change the interfaces config:

$ sudo nano /etc/network/interfaces

Then replace the following configuration:

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto ens160
iface ens160 inet static
# Enter your specific IP address

Then trigger it via:

$ sudo service networking restart


$ sudo ifdown ens160; ifup ens160

If you encountered with an error, do the following command:

$ ip addr flush dev ens160

Also, you can reboot the os: sudo reboot


  • ens160 is my ethernet name, you can check it via $ ifconfig command.
  • This works and tested in Ubuntu 14.04 and 16.04.
  • Here's Ubuntu 18.04 configuration method.

You must log in to answer this question.

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