Date: Wed, 31 Jul 2019 12:38:31 -0700 From: Yuri <yuri@rawbw.com> To: "freebsd-net@freebsd.org" <freebsd-net@freebsd.org> Subject: ipfw questions: how to forward incoming TCP connections from the same host? Message-ID: <16dd8ba4-26e4-928b-c448-8294d13ece02@rawbw.com>
next in thread | raw e-mail | index | archive | help
I need to forward incoming TCP connections made to my host 192.168.5.3 on the port 3100 to the IP address 10.0.0.101 port 3000 connected through another interface. These rules work when connection is made from a remote host: ipfw -q nat 19001 config redirect_port tcp 10.0.0.101:3000 192.168.5.3:3100 ipfw -q add 19001 nat 19001 tcp from any to 192.168.5.3 3100 in recv sk0 ipfw -q add 19001 nat 19001 tcp from 10.0.0.101 3000 to any out xmit sk0 Question#1: How to allow connections from the same host to be forwarded the same way? Connections from the host's LAN IP address pass through lo0, but this rule doesn't work when added: ipfw -q add 19001 nat 19001 tcp from 192.168.5.3 to 192.168.5.3 3100 in recv lo0 Wireshark shows that the incoming connection is from 192.168.5.3 to 192.168.5.3 on 3100 but it gets immediately rejected instead of being forwarded. This rule looks very similar to the second rule above, just the interface is different. Why doesn't it work? Question#2: When lo0 is added to the third rule above it stops working for the return traffic: ipfw -q add 19001 nat 19001 tcp from 10.0.0.101 3000 to any out xmit sk0 xmit lo0 Just adding "xmit lo0" makes it to fail for sk0 too. When several interfaces are present in the rule, doesn't this mean that it should apply to all of them? Perhaps multiple interfaces can only be used in recv/xmit combination? Why does this command accept two xmit clauses then? Thank you, Yuri
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?16dd8ba4-26e4-928b-c448-8294d13ece02>