0

I have a physical machine running ubuntu server 16.04, and I am having a bit of trouble interacting with it. When I run ifconfig I see it's public IP address, but when I try to ping it from another machine nothing happens.

What I have been able to do in order to interact with it, is on the server, login as some user, run sudo service networking restart and then I can interact with the machine remotely (ping for example). However, the second I run exit or logout on the server, I can no longer interact with it again.

It's also worth noting that I don't seem to be able to ping anything from the server until I restart the networking like I mentioned just above. Once I restart networking, I can ping out, but again once I log out and in again, I am back where I started.

How can I begin to have the networking setup such that it simply works on boot?

The contents of /etc/network/interfaces is:

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

source /etc/network/interfaces.d/*

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto enp8s0
iface enp8s0 inet dhcp

UPDATE:

It would appear that even after restarting the networking service, I can still only intermittently ping it.

  • Please provide the contents of /etc/networking/interfaces – Jared Starkey Jun 14 '16 at 15:15
  • I have updated the original post with the contents of that file –  Jun 14 '16 at 15:22
  • How are you able to ping the machine if it has a dynamic IP address? Is this running a desktop environment and, by default, Network Manager? – chili555 Jun 14 '16 at 15:28
  • It looks like you're using an SFP based network card. Is this correct? When you log off, are the lights still lit? Who is the device maker? – Jared Starkey Jun 14 '16 at 15:28
  • @chili555 the machine has no desktop environment, just the command line available to me. –  Jun 14 '16 at 15:30
  • @JaredStarkey It is an onboard ethernet controller. lshw tells me the card is a RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller –  Jun 14 '16 at 15:34

3 Answers3

1

I suggest the following /etc/network/interfaces file:

auto lo
iface lo inet loopback

auto enp8s0
iface enp8s0 inet static
address 192.168.254.120 
netmask 255.255.255.0
gateway 192.168.254.1
dns-nameservers 8.8.8.8 192.168.254.1

Be sure to select an address outside the range used for DHCP in the router. Of course, substitute your details here.

Now get the system to read and use the changes:

sudo ifdown enp8s0 && sudo ifup enp8s0

Check that you can reach the internet:

ping -c3 www.ubuntu.com
chili555
  • 60,188
  • This wound up doing the trick for me! I had to do some editing as my machine has a public IP address, but this was definitely the right path. –  Jun 15 '16 at 13:58
0

Please use the method from the second answer to edit your interfaces file and set a static IP.

-1

You can try /etc/rc.local. To run a command at startup, use sudo nano /etc/rc.local and at the first availble line, type sudo networking restart. hope this helps

PMiner
  • 17
  • This kind of solution is a little scary, personally speaking. Its a workaround that ignores whatever the core issue is. Who knows though, it may solve the problem. – Jared Starkey Jun 14 '16 at 15:30
  • rc.local is only invoked at boot, not logout/in. Moreover, restarting networking is deprecated. – chili555 Jun 14 '16 at 15:31