ipfw+natd port forward does not work as intended

Unga unga888 at yahoo.com
Wed Apr 3 11:32:58 UTC 2013


Hi all

I'm on 192.168.1.62, the server running on 192.168.1.3 and listen to port 1234. I want any connection going out of my machine to port 1234 to port forward to 192.168.1.3:1234.

But when I attempt to connect to 192.168.1.1:1234 , natd shows following verbose message:
natd[2051]: Aliasing to 192.168.1.62, mtu 1500 bytes
Out {default}[TCP]  [TCP] 192.168.1.62:45642 -> 192.168.1.1:1234 aliased to
           [TCP] 192.168.1.62:45642 -> 192.168.1.1:1234


This is FreeBSD 8.1-RELEASE and the kernel is built with following options:
options         IPFIREWALL              # Enable ipfw
options         IPFIREWALL_FORWARD      # Enable ipfw forward
options         IPDIVERT


/etc/rc.conf
--------------

# Enable ipfw firewall
firewall_enable="YES"
firewall_script="/etc/rc.firewall.test"

# Natd
gateway_enable="YES"
natd_enable="YES"
natd_interface="msk0"
natd_flags="-f /etc/natd.conf"
sysctl net.inet.ip.forwarding=1

/etc/rc.firewall.test
-----------------------

#!/bin/sh


IFACE=msk0

IPFW=/sbin/ipfw

${IPFW} -f flush
${IPFW} add 100 divert natd ip from any to any 1234 via ${IFACE} 
${IPFW} add 60000 permit ip from any to any


/etc/natd.conf
-----------------

port 8668
log
verbose
interface msk0 
redirect_port tcp 192.168.1.3:1234 1234


Is there any configuration error above?

Best regards
Unga


More information about the freebsd-questions mailing list