timdonovan
Posts: 7
Joined: Wed Oct 28, 2015 3:50 pm

Route wlan0 to wlan1 (wifi extender)

Tue Jun 06, 2017 1:11 pm

Hi,

I am trying to build a wifi extender (i.e. 2 wifi devices, one running as an access point, the other connected to an existing internet source). There are a few tutorials out there that are either a) extending via ethernet or b) outdated or c) don't seem to work.

I have successfully created a working AP on wlan0 (using hostapd), have got dnsmasq (and I tried isc-dhcp-server successfully too) working to assign IP addresses and have wlan1 connected to my internet source.

What I cannot get working is forwarding traffic from wlan0 to wlan1. I have tried:

Using IP tables (connected devices still cannot connect to internet when trying this):
sudo iptables -t nat -A POSTROUTING -o wlan1 -j MASQUERADE
sudo iptables -A FORWARD -i wlan1 -o wlan0 -m state --state RELATED,ESTABLISHED -j ACCEPT
sudo iptables -A FORWARD -i wlan0 -o wlan1 -j ACCEPT

Using brctl (connected devices stop getting an IP address when trying this):
brctl addbr bridge0
brctl addif bridge0 wlan0 wlan1
ifconfig bridge0 up (bridge gets a 169. IP here, not sure if this is right)

Other points:
- Latest raspbian-jessie-lite
- Have enabled IPV4 forwarding
- Board is Pi Rev 2 Model B
- Pi power is fine
- I have eth0 plugged in so I can ssh in, even if the wlan0/1 go down

Any pointers would be greatly appreciated, as I feel I'm very close but cannot figure out the issue!

Note sure if its helpful but 'route' shows:
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
default router.asus.com 0.0.0.0 UG 202 0 0 eth0
default router.asus.com 0.0.0.0 UG 304 0 0 wlan1
192.168.1.0 * 255.255.255.0 U 202 0 0 eth0
192.168.1.0 * 255.255.255.0 U 304 0 0 wlan1
192.168.200.0 * 255.255.255.0 U 303 0 0 wlan0

Thanks.

timdonovan
Posts: 7
Joined: Wed Oct 28, 2015 3:50 pm

Re: Route wlan0 to wlan1 (wifi extender)

Tue Jun 06, 2017 1:15 pm

Man, 2 days of fiddling around, turns out if you yank out the ethernet cable the whole routing thing works fine. Not sure whats causing that but never mind, don't need ethernet access now that it's all working.

Ernst
Posts: 1257
Joined: Sat Feb 04, 2017 9:39 am
Location: Germany

Re: Route wlan0 to wlan1 (wifi extender)

Tue Jun 06, 2017 1:46 pm

timdonovan wrote:Man, 2 days of fiddling around, turns out if you yank out the ethernet cable the whole routing thing works fine. Not sure whats causing that but never mind, don't need ethernet access now that it's all working.
The answer is that you have two interfaces within the same subnet that have routing entries with different metrics.
Any traffic that hits these routing entries will be send on an active interface with the lowest metric.
What this means is that the Pi will always try to use the eth0 interface (if connected) for outgoing traffic (on this route) because it has the lowest metric.
The road to insanity is paved with static ip addresses

Return to “Troubleshooting”