I am running Debian on my laptop, and Raspbian on my Raspberry Pi 3.

I am connected (via an ethernet cable, no router in between) via ssh to the raspberry, but when I try to access the internet via the raspberry (ping, apt-get...), I get:

ping: unknown host example.com

And it's impossible to access the internet in general, via the RPI.

However I have no problem accessing the internet via my laptop. Disabling my firewall doesn't solve the issue.

How can I access the internet on the RPI ?

  • 1
    Is there any particular reason that you must connect Raspberry Pi this way? You could connect the Raspberry Pi to the router either via ethernet or wifi and you will still be able to ssh your Raspberry Pi from your laptop using ssh. – hcheung Mar 28 '17 at 10:21

Connect your Raspberry Pi to your router using WiFi, or share your laptop's internet with your Raspberry Pi.

Configurring WiFi on the Raspberry Pi 3B

To connect your Raspberry Pi to your router using WiFi, start by scanning the WiFi networks on your Raspberry Pi:

sudo iwlist wlan0 scan

If your WiFi network shows up, we can continue by editing the wpa configuration file:

sudo nano /etc/wpa_supplicant/wpa_supplicant.conf

Add the folowing lines:


Close the file with CTRL+X, Y to confirm.

Now wait a few seconds, then check if your Raspberry Pi is connected by looking if it has an ip address: sudo ifconfig wlan0 (you should see entries such as inet addr and inet6 addr). If your Raspberry Pi isn't connected immediately, try sudo wpa_cli reconfigure and check again after a few seconds.

Sharing internet with the Raspberry Pi 3B

This won't work with certain WiFi Access Points (some reject devices/addresses that didn't authenticate to the WiFi AP themselves).

If you can't connect to your WiFi, or you just prefer to share your laptop's internet with your Raspberry Pi, consider doing the following:

On your Raspberry Pi, edit /etc/network/interfaces and set a static IP address:

sudo nano /etc/network/interfaces

Look for the line iface eth0 inet dhcp and make it iface eth0 inet manual. Close the file with CTRL+X, Y to confirm.

Then edit the file /etc/dhcpcd.conf:

sudo nano /etc/dhcpcd.conf 

Add the following lines: (replace x.x with your desired IP address and x.y with your router IP address).

interface eth0
static ip_address=192.168.x.x
static routers=192.168.x.y
static domain_name_servers=

Close the file with CTRL+X, Y to confirm.

Then, on your Debian laptop, install the package bridge-utils to bridge network connections:

sudo apt-get install bridge-utils

Create the new network interface:

sudo brctl addbr br0

Link the connections (if necessary, replace wlan0 with the network port your laptop uses to connect to the internet, and replace eth0 with the network port your laptop uses to connect to the Raspberry Pi):

sudo brctl addif br0 wlan0 eth0
sudo ifup br0 

Then (still on your Debian laptop), edit /etc/network/interfaces:

sudo nano /etc/network/interfaces

Look for the bridge entry. Make it look like this (again, replace wlan0, eth0, x, x.x and x.y where necessary):

# Bridge setup
iface br0 inet static
bridge_ports wlan0 eth0
  address 192.168.x.x
  broadcast 192.168.x.255
  gateway 192.168.x.y

Close the file with CTRL+X, Y to confirm, and (hopefully) enjoy your bridged internet connection.


You need to connect your Pi to the router. This will give your Pi an IP address from the DHCP service on the router.

This is the easiest way as it will get a Gateway set for which the Pi can then access the internet.

Then you connect to your Pi via SSH using the IP address that the router gave it.

You can find out the IP of the Pi by typing ifconfig in the terminal if you got a mouse and screen connected to it.

If it is headless, no keyboard and screen - Then the best thing is to log in to your router and look at the DHCP table. Most of the time the DNS record will show up as raspberrypi or rasbperrypi.local

You can even try and ping / connect to SSH using the DNS rasperrypi

By just connecting a LAN cable between the two devices all you are doing is creating a separate, new network. This is also possible and you can configure your Ubuntu machine to work like a gateway and give the Pi internet, via your Ubuntu WiFi. This is called interface bridging It means you bridge your WiFi onto LAN port, then your Pi communicates with the Router via this bridge.


If you are using a Macbook and a thunderbolt ethernet adapter to ssh into your PI. Go to:

  1. System Preferences
  2. Then go to Sharing
  3. Then select your Wifi Service under "Share your connection from"
  4. Then select "Thunderbolt Ethernet" from "To computers using"

This requires that your laptop is connected to the internet VIA WIFI.

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.