I have two wlan interfaces: wlan0 wlan1.

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

# 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 SORUCE_INTERFACE to 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

route -n

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface         UG    202    0        0 eth0         UG    304    0        0 wlan1   U     202    0        0 eth0   U     304    0        0 wlan1   U     0      0        0 wlan0     U     303    0        0 wlan0
  • This may be the default route. Run route -n to display the routing table. – Anonymous Aug 18 '17 at 14:52
  • I added the route -n output to the post. – Scrumplex Aug 18 '17 at 15:05
  • So you have two default routes to Internet ( but eth0 has priority, having the lowest metric. At this point you could try: (sudo) route del -net gw netmask dev eth0 and test again. NB: untested but should work. – Anonymous Aug 18 '17 at 15:19
  • That actually fixed it! Can I instead of deleting just change the priority of the route? Changing the priority would be the solution. (Edit your answer) – Scrumplex Aug 18 '17 at 15:21
  • I see several options from now: one option would be to set fixed metrics in your interfaces file (see: unix.stackexchange.com/questions/292940/…. Another option would be tweaking your DHCP settings to discard that secondary route on eth0 (See: raspberrypi.org/forums/viewtopic.php?f=66&t=90469) – Anonymous Aug 18 '17 at 17:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.