- Install wifi-api
snap install wifi-ap
.
- After installation, I had issues with DHCP connections, so I connected every device by assigning static IPs
- Ensure the Pi has a static IP address over eth0.
wifi-ap
assigns it a static IP address at wlan0
- Bridge using IP tables, see example:
# eth0 has internet connection
# wlan0 lacks internet connection
# 192.168.0.x subnet for eth0
sudo iptables -A FORWARD -o eth0 -i wlan0 -s 192.168.0.0/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 eth0 -j MASQUERADE
- Save iptables:
sudo iptables-save | sudo tee /etc/iptables.sav
- Add
iptables-restore < /etc/iptables.sav
to /etc/rc.local
so that the rules can be loaded on startup. If it does not exist, paste the following into it:
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
iptables-restore < /etc/iptables.sav
exit 0