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).
(126.96.36.199) WiFi Device 1 freq A / / (wlan0 = 188.8.131.52/32) PC (192.168.2.33) ------- (eth0 = 192.168.2.1) RPi ----- (wlan1 = 184.108.40.206/32) \ \ (220.127.116.11) 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 18.104.22.168 which is on freq A (wlan0) and udp packets to 22.214.171.124 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 126.96.36.199 -p udp -j MARK --set-mark 11 iptables -t nat -A PREROUTING -s 192.168.1.1 -d 188.8.131.52 -p udp -j MARK --set-mark 12 # IP Routes ip route add 184.108.40.206/24 dev wlan0 table 11 ip route add 220.127.116.11/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.