ipfw questions: how to forward incoming TCP connections from the same host?
Yuri
yuri at rawbw.com
Wed Jul 31 19:38:40 UTC 2019
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
More information about the freebsd-net
mailing list