From OpenSimulator

(Redirected from Users:Thomax:nat-loopback)
Jump to: navigation, search

NAT Loopback Configuration on OpenWRT

Well, first is this little script, which should be placed in /etc/firewall.user:

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

# 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 -p $3 --dport $1 -d $2 -j MASQUERADE

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

# http_listen_port from the OpenSim.ini
nat_loopback 9000 $LANIP tcp         

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

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/ which looks like this:


# 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...


Personal tools
About This Wiki