Skip to content

Instantly share code, notes, and snippets.

@ayjayt
Last active December 9, 2020 04:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ayjayt/a70134d914c4b6e650562dd96994b32e to your computer and use it in GitHub Desktop.
Save ayjayt/a70134d914c4b6e650562dd96994b32e to your computer and use it in GitHub Desktop.
How to turn your BB into a router using wifi as internet source

First, set up DHCP on "router" device:

Give eth0 an IP address (forget command, I gave it 192.168.2.1)

Give DNSMASQ a config file with these lines:

NOTE:

  1. Doubt all lines necessary
  2. ADDED to defaults, and taken from here:
domain-needed
bogus-priv
dhcp-authoritative
local=/MyDevice.lan/
interface=eth0
server=8.8.8.8
server=8.8.4.4
expand-hosts
domain=MyDevice.lan
dhcp-range=eth0,192.168.2.50,192.168.2.200,255.255.255.0,12h

From the same source as above (and as root):

echo 1 > /proc/sys/net/ipv4/conf/eth0/proxy_arp
echo 1 > /proc/sys/net/ipv4/conf/wlan0/proxy_arp
echo 1 > /proc/sys/net/ipv4/ip_forward 

Then, from here (with modification wlan1-->eth0):

iptables -A FORWARD -i eth0 -o wlan0 -j ACCEPT
iptables -A FORWARD -i wlan0 -o eth0 -m state --state ESTABLISHED,RELATED \
         -j ACCEPT
iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE

NOW, on the device that had already been connected to the BB (router), I had to set the default gateway:

ip route add default via 192.168.2.1

It works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment