I have a laptop connected to wifi. I would like to connect my Raspberry Pi to it with an ethernet cable and have access to internet thanks to the laptop connection.

I have found a lot of partial solutions on the internet, but nothing that worked properly AND survived reboot (I managed twice to get internet access, but after reboot it stopped working and further modifications destroyed the working configuration). Would anyone have any idea of what are the files that need to be set up properly on both side? I work with Ubuntu on my laptop, Raspbian on the Raspberry Pi.

Laptop side:

auto lo
iface lo inet loopback
iface eth0 inet static

/etc/default/isc-dhcp-server Added the line



ddns-update-style none;
default-lease-time 3600;
max-lease-time 7200;
subnet netmask {
option routers;

RPi side
Nothing has been modified. It is basically Raspbian after going through raspi-config after install but nothing else at all.

i) Run the following script on the laptop


# bring up the eth0 interface
sudo ifup eth0

# start DHCP service
sudo service isc-dhcp-server start

# enable forwarding from the ethernet to wireless router
sudo /sbin/iptables --table nat -A POSTROUTING -o wlan0 -j MASQUERADE

ii) Connect the RPi to the laptop thanks to the ethernet cable
iii) Connect to the RPi via ssh (this works perfectly)

Laptop side
tail /var/log/syslog right after connecting the RPi

Aug 10 17:22:19 shinagan kernel: [ 1257.119401] atl1c 0000:05:00.0: atl1c: eth0 NIC Link is Up<100 Mbps Full Duplex>
Aug 10 17:22:19 shinagan dhcpd: DHCPREQUEST for from b8:27:eb:ce:d4:9e (groundStation) via eth0
Aug 10 17:22:19 shinagan dhcpd: DHCPACK on to b8:27:eb:ce:d4:9e (groundStation) via eth0

hostname -I

ip route

default via dev tun0 proto static dev wlan0 proto kernel scope link src metric 9 via dev tun0 proto static dev tun0 proto kernel scope link src dev eth0 scope link metric 1000 via dev wlan0 proto static dev eth0 proto kernel scope link src

RPi side
hostname -I

ip route

default via dev eth0 metric 202 dev eth0 proto kernel scope link src metric 202

ip neigh dev eth0 lladdr f4:6d:04:fd:1e:a1 DELAY

ip neigh show dev eth0 lladdr f4:6d:04:fd:1e:a1 REACHABLE

ping -c3 [that's the laptop adress. Works well]

PING ( 56(84) bytes of data.
64 bytes from icmp_req=1 ttl=64 time=0.514 ms
64 bytes from icmp_req=2 ttl=64 time=0.573 ms
64 bytes from icmp_req=3 ttl=64 time=0.619 ms

--- ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2002ms
rtt min/avg/max/mdev = 0.514/0.568/0.619/0.051 ms

ping -c3 [google dns. Cannot connect...]

PING ( 56(84) bytes of data.
Then it hangs forever...

ping -c3 www.google.com [does not resolve the address]

ping: unknown host www.google.com

Reference to documentation on the matter or explanations would be a plus, as my knowledge of the phenomenons is limited!

Your Answer

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

Browse other questions tagged or ask your own question.