User:Thomax:nat-loopback

From OpenSimulator

(Difference between revisions)
Jump to: navigation, search
 
(2 intermediate revisions by one user not shown)
Line 1: Line 1:
 +
 +
== NAT Loopback Configuration on OpenWRT ==
 +
 +
 
Well, first is this little script, which should be placed in ''/etc/firewall.user'':
 
Well, first is this little script, which should be placed in ''/etc/firewall.user'':
  

Latest revision as of 18:21, 3 May 2011

[edit] 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
LANIP = 192.168.1.100

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
}                                                                                             


# 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/connect.sh which looks like this:

#!/bin/sh

# 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

Personal tools
General
About This Wiki