Raspberry Pi Internet Bridge

One handy use for the Pi is to bridge an internet connection.  The Monkey found a way to connect the Pi to a mobile hot-spot via WiFi  and pass that internet connection to the wired interface.

And here’s one way to do that:

The following site provided A LOT of help:

# Update your /etc/wpa_supplicant/wpa_supplicant.conf file
sudo nano /etc/wpa_supplicant/wpa_supplicant.conf
#  ** Be absolutely sure the ssid matches perfectly

# Set a static IP on the wired interface:

New Way:
( According to: http://www.techsneeze.com/configuring-static-ip-raspberry-pi-running-raspbian/ )

# You’ll need to open the config file for editing.

sudo nano /etc/dhcpcd.conf
# **  Note the extra "c" in the name of the file

At the bottom of the file you will need to add settings such as:

interface eth0
static ip_address=ip.address.of.pi/24
static routers=
# Leave static routers blank on eth0 so it does not become the default route.
static domain_name_servers=ip.address.of.pi
# First DNS server to check is the Pi, then OpenNIC, with OpenDNS as a last attempt
static domain_search=example.com
static domain_name=example.com

This sets your desired static IP, and the appropriate settings for your resolv.conf You’ll notice it uses your local DNS, OpenNIC (, and OpenDNS (, Level 3 DNS servers are also an option ( You will also want to change ‘example.com’ to be your local domain.

You should now reboot to test all of your changes.

sudo reboot

3. Now we need to route the traffic from the wireless interface to the wired interface:

sudo iptables -A FORWARD -o wlan0 -i eth0 -s ip-address.of-network.behind.pi/24 -m conntrack --ctstate NEW -j ACCEPT
sudo iptables -A FORWARD -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
sudo iptables -t nat -F POSTROUTING
sudo iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE
sudo iptables-save | sudo tee /etc/iptables.sav
Place the following line in your /etc/rc.local file (just before "exit 0" line):
iptables-restore < /etc/iptables.sav
  • edit /etc/sysctl.conf and uncomment:


Reboot the Pi

sudo reboot

For more info about IPtables:

A useful tutorial is here on how to Set up a DHCP server using dnsmasq.

Leave a Reply

Your email address will not be published. Required fields are marked *