User:Thomax:nat-loopback

NAT Loopback Configuration on OpenWRT
Well, first is this little script, which should be placed in /etc/firewall.user:

WANIP=`ifconfig ppp0 | awk '/inet addr/ {split ($2,A,":"); print A[2]}'`
 * 1) get the WANIP from the ppp0 interface

LANIP = 192.168.1.100
 * 1) my lan ip

nat_loopback { iptables -t nat -A prerouting_rule -d $WANIP -p $3 --dport $1 -j DNAT --to $2 iptables -A forwarding_rule -p $3 --dport $1 -d $2 -j ACCEPT iptables -t nat -A postrouting_rule -s 192.168.1.0/24 -p $3 --dport $1 -d $2 -j MASQUERADE }

nat_loopback 80 $LANIP tcp
 * 1) thats for a local apache (yepp, i have a local web server..)

nat_loopback 9000 $LANIP tcp
 * 1) http_listen_port from the OpenSim.ini

nat_loopback 19010 $LANIP udp
 * 1) and the udp port of the region (RegionConfig.ini)

And just because I have a dynamic IP address I need to be sure that the firewall rules get reloaded on each new PPPoE connect. Thats why I created the script /etc/ppp/ip-up.d/connect.sh which looks like this:


 * 1) !/bin/sh


 * 1) Put stuff here you need todo just when your router reconnects to the provider

/etc/init.d/firewall reload

Thats what I've additionally done beside the normal LuCI settings on my openWRT router, which is an asus wl-500gP (with this nice two USB slots :-)

Let me know if it helps you too...

thomax