I'm trying to share the internet connection from a RPi2 connected to internet via wifi to a RPi B+ over ethernet.
I want to use static ip addresses for simplicity.
So RPi2 ("master") is 10.0.0.1
and RPi B+ ("slave") is 10.0.0.2
.
I've configured the /etc/network/interfaces
as following:
RPi2
auto lo
iface lo inet loopback
auto eth0
allow-hotplug eth0
iface eth0 inet static
address 10.0.0.1
gateway 10.0.0.1
netmask 255.255.255.0
broadcast 10.0.0.0
auto wlan0
iface wlan0 inet dhcp
wpa-ssid "XXX"
wpa-psk "YYY"
iface default inet dhcp
RPi
auto lo
iface lo inet loopback
auto eth0
allow-hotplug eth0
iface eth0 inet static
address 10.0.0.2
gateway 10.0.0.1
netmask 255.255.255.0
broadcast 10.0.0.0
iface default inet dhcp
I've also applied some rules to iptables on RPi2:
Chain FORWARD (policy ACCEPT)
target prot opt source destination
ACCEPT all -- anywhere 10.0.0.0/24 state RELATED,ESTABLISHED
ACCEPT all -- 10.0.0.0/24 anywhere
Chain POSTROUTING (policy ACCEPT)
target prot opt source destination
MASQUERADE all -- 10.0.0.0/24 !10.0.0.0/24
The /etc/resolv.conf
on the "slave" machine is set to nameserver 10.0.0.1
I can ping successfully each other machine, the "master" can access the internet, but when I try to ping google.com from the "slave" I get this error:
ping: unknown host google.com
Any idea how can I make it working?
Thanks