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.

[EDIT]
1) CURRENT SET UP
Laptop side:
/etc/network/interface

auto lo
iface lo inet loopback
iface eth0 inet static
address 192.168.1.1
netmask 255.255.255.0
network 192.168.1.0

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

INTERFACES="eth0"

/etc/dhcp/dhcpd.conf

ddns-update-style none;
default-lease-time 3600;
max-lease-time 7200;
authoritative;
subnet 192.168.1.0 netmask 255.255.255.0 {
option routers 192.168.1.1;
range 192.168.1.100 192.168.1.200;
}

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

2) PROCEDURE
i) Run the following script on the laptop

#!/bin/sh

# 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)

3) VARIOUS OUTPUTS
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 192.168.1.100 from b8:27:eb:ce:d4:9e (groundStation) via eth0
Aug 10 17:22:19 shinagan dhcpd: DHCPACK on 192.168.1.100 to b8:27:eb:ce:d4:9e (groundStation) via eth0

hostname -I

192.168.1.1 10.0.0.2 10.10.0.82

ip route

default via 10.10.0.81 dev tun0 proto static
10.0.0.0/24 dev wlan0 proto kernel scope link src 10.0.0.2 metric 9
10.10.0.1 via 10.10.0.81 dev tun0 proto static
10.10.0.81 dev tun0 proto kernel scope link src 10.10.0.82
169.254.0.0/16 dev eth0 scope link metric 1000
173.193.211.195 via 10.0.0.1 dev wlan0 proto static
192.168.1.0/24 dev eth0 proto kernel scope link src 192.168.1.1

RPi side
hostname -I

192.168.1.100

ip route

default via 192.168.1.1 dev eth0 metric 202
192.168.1.0/24 dev eth0 proto kernel scope link src 192.168.1.100 metric 202

ip neigh

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

ip neigh show

192.168.1.1 dev eth0 lladdr f4:6d:04:fd:1e:a1 REACHABLE

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

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

--- 192.168.1.1 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 8.8.8.8 [google dns. Cannot connect...]

PING 8.8.8.8 (8.8.8.8) 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 acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.