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 '14 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 '14 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 '14 at 19:24

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
   address 10.253.0.50
   netmask 255.255.255.0
   network 10.253.0.0
   gateway 10.253.0.1
   dns-nameservers 8.8.8.8

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 '14 at 14:47
  • 21
    Restart eth0 with sudo ifdown eth0 && sudo ifup eth0 instead of the last command. – Kenny Evitt Jan 27 '15 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 '15 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 '16 at 16:57
  • but now the network would start automatically – Allan Ruin Aug 10 '16 at 16:10

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

auto eth0
iface eth0 inet static

address 192.168.1.128
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
gateway 192.168.1.1

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)

example:

search  (domain name)
nameserver 8.8.8.8
nameserver 8.8.4.4

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. – Vladimir Vukanac May 5 '16 at 21:40

I found I had to include the dns settings:

auto lo enp0s25
iface lo inet loopback
iface enp0s25 inet static
    address 192.168.1.128
    netmask 255.255.255.0
    gateway 8.8.8.8.7
    dns-search example.com
    dns-nameservers 8.8.8.8 8.8.4.4

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

  • you missing gateway – Pavel Niedoba Jan 9 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. – user8128167 Jan 10 at 2:37
  • 1
    8.8.8.8.7 is not a valid IP address – papaiatis Mar 20 at 12:45

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
        address 192.168.1.130
        netmask 255.255.255.0
        gateway 192.168.1.1
        dns-nameservers 8.8.8.8 8.8.4.4

Then trigger it via:

$ ifdown ens160; ifup ens160

If you confront with an error, do it command:

$ ip addr flush dev ens160


[NOTE]:

ens160 is my ethernet name, you can check it through $ ifconfig command.

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.