Ubuntu – Unable to ping any hosts, ifconfig: eth0 connection

kernelnetworking

My problem started with this question: Failed to start Load Kernel Modules Ubuntu 16.04

Now I can boot but only log in on tty1. I am trying to get sudo apt-get update to work to try and fix all the other issues. The problem is, that I can not connect to the internet. ifconfig tells me that I have a connection, and sudo dhclient wlan0 and sudo dhclient eth0 now execute successfully, but pinging any host won't work via hostname (I always get a unknown host error). I can successfully ping 8.8.8.8 though.

service network-manager status shows active and running

ip route has a default route default via 192.168.1.1 dev eth0

How can I connect to the internet?

Best Answer

It looks like you are booting in single-user, networkless, failsafe level.

To fix your DNS issues, just:

echo "nameserver 8.8.8.8" > /etc/resolv.conf

Then at least from that session, you should be able to ping by hosts. Assuming 8.8.8.8 is ping-able (as you stated) and that it is one of google's free DNS servers.

This way, while you'd have DNS servers set up, it is not guaranteed that apt-get will work. As a fail-safe boot, partitions might have been mounted read-only or not mounted at all.

If you can't create/edit /etc/resolv.conf because the filesystem is mounted read-only, as being root you can fix that (assuming the filesystem can be mounted read-write -- i.e. not a hardware limitation) with:

mount -o remount,rw /

Then do the command again to set the nameserver. Assuming /etc is a directory under partition mounted in /, and no dedicated partition for /etc.

To add another DNS server (append) to the file:

echo "nameserver 8.8.4.4" >> /etc/resolv.conf
Related Question