Subject: Redirecting a port
To: None <netbsd-help@netbsd.org>
From: Mikael K <mickek@myrealbox.com>
List: netbsd-help
Date: 05/05/2002 00:35:51
Hello!

I've been trying to redirect a port on my NetBSD gateway to my Windows ftp
server. The gateway works fine except for this and I've been trying to
fixe this for days and I'm feeling very lost. I'll try to include as much
information as I can. If it is anything I've not included that could give you
a hint, please tell. Does anyone have any good links, been looking trough
the NetBSD's documentation a lot but don't find any clues to what I've
done wrong.


  -----------        --------         -----   ----------------
 | dsl modem |- ne2 | NetBSD | fxp0 -| hub |-| Win ftp server |
  -----------        --------         -----   ----------------
                                        | desktop machines

# ifconfig ne2

ne2: flags=8863<UP,BROADCAST,NOTRAILERS,RUNNING,SIMPLEX,MULTICAST> mtu 1500
        address: 00:50:ba:a6:4b:b1
        media: Ethernet autoselect (10baseT)
        inet 208.217.73.43 netmask 0xffffff00 broadcast 208.217.73.255
        inet6 fe80::250:baff:fea6:4bb1%ne2 prefixlen 64 scopeid 0x2

# ifconfig fxp0

fxp0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
        address: 00:a0:c9:43:e9:e5
        media: Ethernet autoselect (10baseT)
        status: active
        inet 192.168.0.1 netmask 0xffffff00 broadcast 192.168.0.255
        inet6 fe80::2a0:c9ff:fe43:e9e5%fxp0 prefixlen 64 scopeid 0x1

# sysctl -w net.inet.ip.forwarding
net.inet.ip.forwarding = 1

in /etc/ipnat.conf
map ne2 192.168.0.0/24 -> 0/32 proxy port ftp ftp/tcp 
map ne2 192.168.0.0/24 -> 0/32 portmap tcp/udp 40000:60000
map ne2 192.168.0.0/24 -> 0/32

#redirection to my ftp server
rdr ne2 0.0.0.0/0 port 21 -> 192.168.0.2 port 21 tcp

in /etc/ipf.conf
pass in all
pass out all

in /etc/rc.conf

ipfilter=YES                #Stateful firewall
ipnat=YES                   #Network Address Translation
ipmon=YES                   #Firewall logging
ipmon_flags="-Dsn"


Thank you in advance
Mikael Karlsson