I'm trying to use a Raspberry Pi to act similarly to a network bridge by using
MASQUERADE. Although I know there are many technical reasons that this is not a bridge, all I need to do is get web traffic from the hardwired port
eth0 to the wireless network the Pi is connected to through
wlan0. However, it seems not to be working; even though there is internet access on the Pi, DNS fails on the computer I wish to connect to the network through the Pi.
Following the instructions here, I used the following commands:
echo "1" > /proc/sys/net/ipv4/ip_forward iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE
I wanted this to work and run as soon as
wlan0 is enabled, so I added it to
/etc/network/interfaces in a
post-up clause. I noticed that the Pi failed to properly obtain the gateway from the DHCP on the network, so I had it set that manually in the same statement. Here is the full contents of
auto lo iface lo inet loopback iface eth0 inet manual allow-hotplug wlan0 iface wlan0 inet manual wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf post-up route add default gw 10.110.0.11; echo "1" > /proc/sys/net/ipv4/ip_forward ; iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE
The Pi is configured to have a static IP in
/etc/dhcpcd.conf using the following:
interface eth0 static ip_address=192.168.0.5/24 static routers=192.168.0.5 static domanin_name_servers=220.127.116.11 18.104.22.168
Then, on the computer I wish to receive the connection on, I configure it to have its own IP in the same subnet (I picked
192.168.0.2), have the same subnet mask (
255.255.255.0), and I set the gateway to
192.168.0.5. While I can see the Pi from the computer (I can ping and
ssh to it), it doesn't seem to be receiving the internet connection through it; I can't visit any website, DNS lookup fails. How can I resolve this?
Thanks for your help!