Port forwarding on FreeBSD via ipnat


Hi..

it's normally happen when your server is running "behind the firewall" and using private ip network, we use port forwarding to forward "request" based on specified ports on services...

in this case, we take apache/http port 80 as an example

 

 

1- FreeBSD FW gateway + ipnat

ext ip = based on ISP, it's dynamic

internal ip = 10.0.0.200

 

 

2- NetBSD server which running web/apache/http

ip 10.0.0.147 port 80/tcp

 

 

3- For IPNAT setup, refer to my previous HOW-TO NAT with ipnat on FreeBSD,

 

just edit /etc/ipnat.conf and add this value:

 

rdr tun0 0/0 port 80 -> 10.0.0.147 port 80 tcp/udp

 

SAVE!!!

 

tun0 is device tunnel 0 created while ure using ppp foa dialing your DSL connection, any connection froum outside/internet to web services port 80, receive by FreeBSD gateway box, will be redirected to the NetBSD web server..

 

so after saving, u just need to flush and run/apply the rules..NAT with ipnat on FreeBSD

 

 

trunasuci# ipnat -FC && ipnat -f /etc/ipnat.rules

2 entries flushed from NAT table

4 entries flushed from NAT list

 

 

trunasuci# ipnat -l

List of active MAP/Redirect filters:

map xl1 10.0.0.0/24 -> 0.0.0.0/32

rdr tun0 0.0.0.0/0 port 80 -> 10.0.0.147 port 80 tcp/udp

List of active sessions:

MAP 10.0.0.200      22    <- -> 10.0.0.200      22    [10.0.0.5 4741]

 

 

so now u can test it from outside/internet and see if u can reach the webserver behind the firewall..

 

 

 

 

IT"S SUCCCESSS!!!