We are currently setting up a system where we are using a Linux computer (debian) that acts as a WiFi control and router. The Linux computer connects to two WiFi networks (let's call them A and B) via WiFi (wlan0 and wlan1). A PC is then connected via ethernet to the Linux box to allow it access to any device on the two WiFi networks. See ASCII art image
WiFi A (192.170.1.xx) / / PC (192.168.2.xx) ----- (192.168.2.1) Linux (22.214.171.124) \ \ WiFi B (192.170.1.xx)
Protocols that we need routed:
- SSH to any 192.170.1.xx device from PC
- TCP on ports 1234/4321 to any 192.170.1.xx device from PC
- PING to any 192.170.1.xx device from PC
The question relates to how to setup the IPTables
- The PC has the gateway set to 192.168.2.1 so any packets that the PC sends to 192.170.1.xx will be routed to the Linux box?
This is what I think should work (not yet tested). Could you please indicate if this is correct or I have a fundamental mistake in my logic?
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE iptables -A FORWARD -i eth0 -o wlan0 -m state --state RELATED,ESTABLISHED -j ACCEPT iptables -A FORWARD -i eth0 -o wlan 1-m state --state RELATED,ESTABLISHED -j ACCEPT iptables -A FORWARD -i wlan0 -o eth0 -j ACCEPT iptables -A FORWARD -i wlan1 -o eth0 -j ACCEPT