1

We have a windows server with DHCP and 2 Linux machines with Ubuntu 16

if we set /etc/network/interfaces like this:

# The loopback network interface
auto lo eth0
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet static
address 192.168.1.18
netmask 255.255.255.0

allow-hotplug eth0
  iface eth0 inet dhcp

Then all works fine. So in short, first the machine sets static IP then it uses DHCP and it gets that ip 192.168.1.18

And if we delete those two last lines:

allow-hotplug eth0
  iface eth0 inet dhcp

There is no internet at all on the machine. Can anyone explain this please?

  • 1
    You didn't specify a gateway. The OS doesn't know where to route packets for the Internet. Using DHCP, the gateway's IP address would be supplied by the DHCP server. – Jos Jun 13 at 9:06
  • This can be, I will try – lewis4u Jun 13 at 9:08
  • 1
    You're also not setting any dns-nameservers – steeldriver Jun 13 at 9:13
  • I tried and it didn't work, but there is one more thing now I figured it out that this is not ubuntu server, It's a Debian. does this matter at all? P.S. I have network with your proposal but no internet! – lewis4u Jun 13 at 13:39
2

"Can anyone explain this please?" Yes, your interfaces file is seriously deficient. You have not specified a gateway nor the very important DNS nameservers.

I suggest that you amend the file to:

# The loopback network interface
auto lo eth0
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet static
address 192.168.1.18
netmask 255.255.255.0
gateway 192.168.1.1
dns-nameservers 8.8.8.8 192.168.1.1

allow-hotplug eth0

Please be certain that the specified static IP address is outside the DHCP range in the router to avoid collisions.

Restart the interface:

sudo ifdown eth0 && sudo ifup -v eth0

Confirm that you are connected:

ping -c3 www.ubuntu.com
  • Still doesn't work :(, maybe because this is not ubuntu but Debian? – lewis4u Jun 14 at 7:24
  • Probably not. Have you confirmed that the requested static IP address is outside the DHCP pool used in the router? Have you confirmed that the gateway address is actually x.1 and not x.254 or some other? You can check other devices on the same network; i.e. phones, iPads, etc.. Finally, in sudo ifdown eth0 && sudo ifup -v eth0, the -v for verbose should produce some clues as to the success or failure of the connection. What does it say? – chili555 Jun 14 at 19:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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