I've intentionally made a busy home network so I'm forced to learn new things... only problem is now I gotta explain it to you clearly...
The network looks like this:
Code:
Internet Gateway - Wireless
192.168.2.1
|
| -----> 192.168.2.18 wlan0 [GATEWAY-PC(Iptables problems here)] 172.16.1.1 eth0 ---------------> 172.16.3.3 [SSHD-PC]
| 172.24.1.1 eth1 ---------------> 172.24.200.10 [TEST-PC]
|
\ -----> 192.168.2.22 wlan0 [LAPTOP]
I have here an iptables rule on a ubuntu server (GATEWAY-PC) that currently works for it's intended use. No problems there. Traffic coming in from the internet on port 22 is directed to a system running sshd (SSHD-PC).
Code:
stlu@gateway-pc$ iptables -A PREROUTING -t nat -i wlan0 -p tcp --dport 22 -j DNAT --to 172.16.3.3:22
stlu@gateway-pc$ iptables -A FORWARD -p tcp -d 172.16.3.3 --dport 22 -j ACCEPT
Tonight I tried to route traffic through this system from a client (LAPTOP) to another system (TEST-PC) such as:
Code:
stlu@laptop$ sudo route add -net 172.24.0.0/16 gw 192.168.2.18
I tried to ssh into TEST-PC, but instead, iptables rule took over and sent me to the SSHD-PC.
I had hoped that the connection would be forwarded to the 172.24 network because that was the destination address. However this iptables rule is applying itself to traffic that should be routed locally -- without DNAT.
The traffic that I want port-forwarded should be coming from my Internet Gateway into wlan0 with a destination address which will only ever be 192.168.2.18, while the traffic that I DON'T want port-forwarded will have other addresses (172.x) that can be routed locally through the ethernet interfaces, even traffic to other machines on port 22.
Thanks for any tips, this is a learning project and you're helping me learn!
tl;dr:
Internet > GATEWAY-PC :22 > SSHD-PC success.
Laptop > GATEWAY-PC > TEST-PC fail.
Bookmarks