0

I am trying to allow a device connected to eth0 to access devices on wlan0 and wlan1. Diagram shown below. The WiFi devices are on different frequencies and I cannot bridge them (not supported).

                                                    (192.170.1.32) WiFi Device 1 freq A
                                                    /
                                                   /
                                                (wlan0 = 192.170.1.250/32)
PC (192.168.2.33) -------  (eth0 = 192.168.2.1) RPi ----- 
                                                (wlan1 = 192.170.1.251/32)
                                                   \
                                                    \
                                                    (192.170.1.69) WiFi Device 2 freq B

I have tried to then setup the IPTables to direct to the correct network (I know in advance what the IP address of each device on the network are)

For example if I want th0 interface to send all udp packets to 192.170.1.69 which is on freq A (wlan0) and udp packets to 192.170.1.9 which is on freq B (wlan1).

# Iptables
sudo iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE
iptables -t nat -A PREROUTING -s 192.168.1.1 -d 192.170.1.69 -p udp -j MARK  --set-mark 11
iptables -t nat -A PREROUTING -s 192.168.1.1 -d 192.170.1.79 -p udp -j MARK  --set-mark 12

# IP Routes
ip route add 192.170.1.0/24 dev wlan0 table 11
ip route add 192.170.1.0/24 dev wlan1 table 12

However, this does not work. I cannot get it to send out messages to the correct devices - I feel because it is too simple.

  • How does your routing table look like? Normally the forward slash is used instead of the backslash to give the netmask like 192.170.1.0/24 – Lambert Sep 15 '17 at 16:07
  • Edited (typo mistake). And what you do you mean by "How does your routing table look like?" Do you mean the output from route -n? – Lhh92 Sep 15 '17 at 16:35
  • I strongly advice to use different IP ranges on your two WLAN networks, e.g. 192.168.44.*/24 and 192.168.55.*/24, or whatever. Overlapping IP ranges will cause all kinds of trouble. Also, stay in the private use range. This is basically a routing problem (people seem to want to use iptables for routing all the time lately, but that's nonsense), so look at ip route and ip route help. – dirkt Sep 17 '17 at 13:39
0

The answer ended up being an application called parprouted. This is an ARP Proxy that allows devices to view the network as a single logical network even when they are physically separated. The ARP proxy works at the Layer 3 meaning you do not have to deal with layer 2 (link layer). For a good article on how ARP Proxies work see here http://www.tcpipguide.com/free/t_ProxyARP-2.htm

A bridge method does not work in this case. Primarily because WiFi does not seem to use the same framing schema as ethernet and is not easily bridged.

I did not look long enough into the ip route method to figure out how to do that. I am not too sure how to configure it but I think ip tables might need to be used to filter based on the destination ip address.

My network configuration was as follows

                                                                        (192.170.1.32) WiFi Device 1 freq A
                                                                        /
                                                                       /
                                                                    (wlan0 = 192.170.1.250/24)
PC (192.170.1.251/24) -------  (eth0 = 192.170.1.251/24) RPi ----- 
                                                                    (wlan1 = 192.170.1.251/24)
                                                                       \
                                                                        \
                                                                        (192.170.1.69) WiFi Device 2 freq B

And parprouted was started using parprouted eth0 wlan0 wlan1

  • There are two other programs you could have looked into using: arptables and ebtables. arptables is used for, as the name suggests, ARP. ebtables is for ethernet. – Charles Addis Sep 18 '17 at 3:56
  • I am unsure why this answer got downvoted? It fixed the issue I was having and provided a clean solution for the network I was working with...... – Lhh92 Sep 20 '17 at 1:00
  • Gave it an upvote to even it out :) – Charles Addis Sep 20 '17 at 6:02

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.