I have two wlan interfaces:
wlan0 is an AP managed by hostapd, where as
wlan1 is a normal wifi interface, which is connected to my home router via wpa_supplicant.
Additionally I have my
eth0 interface, which is also connected to my router. I want to build up a wifi repeater for the pi.
I have the following iptables rules
AP_INTERFACE="wlan0" # ap SOURCE_INTERFACE="wlan1" # to router # Flush rules iptables -t nat -F iptables -F # Apply new rules iptables -t nat -A POSTROUTING -o $SOURCE_INTERFACE -j MASQUERADE iptables -A FORWARD -i $SOURCE_INTERFACE -o $AP_INTERFACE -m state --state RELATED,ESTABLISHED -j ACCEPT iptables -A FORWARD -i $AP_INTERFACE -j ACCEPT # Save rules iptables-save > /etc/iptables/rules.v4 # iptables-persistent
If I use this script to set my iptables rules, the clients connected to the AP cannot access anything else than the Pi itself, because the packets are not forwarded. If I changed the
eth0 it works for unknown reasons.
auto lo iface lo inet loopback iface eth0 inet manual allow-hotplug wlan1 iface wlan1 inet manual wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf allow-hotplug wlan0 iface wlan0 inet static address 10.10.11.1 netmask 255.255.255.0
Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 0.0.0.0 10.10.10.1 0.0.0.0 UG 202 0 0 eth0 0.0.0.0 10.10.10.1 0.0.0.0 UG 304 0 0 wlan1 10.10.10.0 0.0.0.0 255.255.255.0 U 202 0 0 eth0 10.10.10.0 0.0.0.0 255.255.255.0 U 304 0 0 wlan1 10.10.11.0 0.0.0.0 255.255.255.0 U 0 0 0 wlan0 169.254.0.0 0.0.0.0 255.255.0.0 U 303 0 0 wlan0