Forum Moderators: bakedjake
I can do something similar with socat like:
socat TCP4-LISTEN:8000,fork TCP4:192.168.11.3:8000
but I thought it'd be faster in the kernel than a userland program ;-)
My iptables setup is like that:
cat /proc/sys/net/ipv4/ip_forward
1
iptables -P FORWARD DROP
iptables -F
iptables -A FORWARD -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -N int_fwd
iptables -A FORWARD -s 192.168.32.10 -d 192.168.0.0/255.255.0.0 -j int_fwd
iptables -A int_fwd -j ACCEPT
iptables -P PREROUTING ACCEPT
iptables -t nat -F
iptables -A PREROUTING -i eth0 -p tcp -m multiport --dports 8000 -j DNAT --to-destination 192.168.11.3
The firewall machine is on the 192.168.32.0 network and can reach 192.168.11.3, well it all works with socat but not with iptables.
Any clues? I use the same ports as I used with socat so the firewall is not blocking them out, I stop socat before testing with iptables of course ;-)
PS. Sorry if these rules are not enough, I didn't want to post the whole thing - only relevant parts.
PPS. Forgot to mention - I have an if before the -j ACCEPT in the stupid looking int_fwd chain, so if I set debug_log_nat=1 it logs it to syslog, same for PREROUTING. Both are logged.
[lists.netfilter.org...]
in this case both machines are on the same subnet, so the packet has to be source natted so that the translated packet gets back to the box with the nat translation.
Sean
It doesn't need SNAT to my knowledge, netfilter should figure out by itself that it's a DNAT'ed connection and forward it back to the client.