I connected my Raspberry Pi to my laptop via an ethernet cable.

SSH works fine, i can log into the pi and navigate its filesystem.

However, ping fails with every host name (except pinging localhost). Also, sudo apt-get update fails as well.

tried to ping but got connect: Network is unreachable

I couldn't find any working solution for this.

Here is the log from both commands above:

sudo apt-get update:

pi@raspberrypi:~ $ sudo apt-get update
Err http://mirrordirector.raspbian.org jessie InRelease

Err http://archive.raspberrypi.org jessie InRelease

Err http://mirrordirector.raspbian.org jessie Release.gpg
  Could not resolve 'mirrordirector.raspbian.org'
Err http://archive.raspberrypi.org jessie Release.gpg
  Could not resolve 'archive.raspberrypi.org'
Reading package lists... Done
W: Failed to fetch http://mirrordirector.raspbian.org/raspbian/dists/jessie/InRelease

W: Failed to fetch http://archive.raspberrypi.org/debian/dists/jessie/InRelease

W: Failed to fetch http://mirrordirector.raspbian.org/raspbian/dists/jessie/Release.gpg  Could not resolve 'mirrordirector.raspbian.org'

W: Failed to fetch http://archive.raspberrypi.org/debian/dists/jessie/Release.gpg  Could not resolve 'archive.raspberrypi.org'

W: Some index files failed to download. They have been ignored, or old ones used instead.
  • Could not resolve 'archive.raspberrypi.org' = no DNS. Ping the local IPs instead of hostnames to confirm.
    – zedman9991
    Sep 30, 2016 at 15:59
  • @zedman9991 How can i set a DNS via the terminal of the pi? Sep 30, 2016 at 16:03
  • superuser.com/questions/617796/…
    – zedman9991
    Sep 30, 2016 at 16:05
  • 1
    FYI if you use DHCP to get your Pi on the network the DHCP server will give you both an IP and DNS addresses.
    – zedman9991
    Sep 30, 2016 at 16:07
  • The PC is not sharing it's internet.
    – goldilocks
    Sep 30, 2016 at 16:20

1 Answer 1


If you need internet access on your pi, the easiest way is to directly connect the Pi to a router rather than directly to your laptop like so

PI       -> | Router| <-> ISP
Laptop   -> |_______|

With above connection, the router (assumed to configured properly) will lease out an IP to the PI on the same subnet as the laptop and will take care of handling the intranet and internet traffic appropriately. this should allow you to ssh into the PI from the laptop as well connect to the internet from the PI

If you dont have a router, you will need to configure Internet connection sharing on your laptop; the instructions for which depends on the OS running on your laptop. I have had mixed experiences trying to get internet sharing working reliably on windows and on ubuntu. YMMV.

PI -> [Laptop] -(usb dongle ?)-> ISP

My guess as to why ssh (from laptop to PI) works but not pings from Pi to laptop is likely because the laptop OS is configured to block ICMP requests. I have seen that happen on some networked computers in my office.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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