Iptables-script
From OpenSimulator
(Difference between revisions)
m (Removed 'Template:' prefix from template includings and/or changed external-link into internal-link) |
m (Robot: Cosmetic changes) |
||
Line 3: | Line 3: | ||
<br /> | <br /> | ||
− | ==Descriptioon== | + | == Descriptioon == |
This script will reroute all LAN->WAN traffic that's normally blocked(router loopback prevention). It solves the issue where only LAN-users OR WAN-users can connect, but not both. Use it on every LAN-client that's trying to connect to a LAN-UGAI. External ip in your ./Region/Region.xml should be your WAN-ip. | This script will reroute all LAN->WAN traffic that's normally blocked(router loopback prevention). It solves the issue where only LAN-users OR WAN-users can connect, but not both. Use it on every LAN-client that's trying to connect to a LAN-UGAI. External ip in your ./Region/Region.xml should be your WAN-ip. | ||
− | ==Source== | + | == Source == |
<source lang="bash"> | <source lang="bash"> | ||
#!/bin/sh | #!/bin/sh | ||
wanip=`wget -qO- http://checkip.dyndns.org/ | sed 's|.* \([[:digit:]]*\.[[:digit:]]*\.[[:digit:]]*\.[[:digit:]]*\).*|\1|'` | wanip=`wget -qO- http://checkip.dyndns.org/ | sed 's|.* \([[:digit:]]*\.[[:digit:]]*\.[[:digit:]]*\.[[:digit:]]*\).*|\1|'` | ||
− | lanip=`ifconfig | + | lanip=`ifconfig | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print $1}'` |
echo "Rewriting iptables using $wanip(wan) and $lanip(lan)..." | echo "Rewriting iptables using $wanip(wan) and $lanip(lan)..." | ||
iptables -t nat -A OUTPUT --dst $wanip -p tcp --dport 9000:9010 -j DNAT --to-destination $lanip | iptables -t nat -A OUTPUT --dst $wanip -p tcp --dport 9000:9010 -j DNAT --to-destination $lanip | ||
iptables -t nat -A OUTPUT --dst $wanip -p udp --dport 9000:9010 -j DNAT --to-destination $lanip | iptables -t nat -A OUTPUT --dst $wanip -p udp --dport 9000:9010 -j DNAT --to-destination $lanip | ||
</source> | </source> |
Latest revision as of 19:27, 3 March 2012
[edit] Descriptioon
This script will reroute all LAN->WAN traffic that's normally blocked(router loopback prevention). It solves the issue where only LAN-users OR WAN-users can connect, but not both. Use it on every LAN-client that's trying to connect to a LAN-UGAI. External ip in your ./Region/Region.xml should be your WAN-ip.
[edit] Source
#!/bin/sh wanip=`wget -qO- http://checkip.dyndns.org/ | sed 's|.* \([[:digit:]]*\.[[:digit:]]*\.[[:digit:]]*\.[[:digit:]]*\).*|\1|'` lanip=`ifconfig | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print $1}'` echo "Rewriting iptables using $wanip(wan) and $lanip(lan)..." iptables -t nat -A OUTPUT --dst $wanip -p tcp --dport 9000:9010 -j DNAT --to-destination $lanip iptables -t nat -A OUTPUT --dst $wanip -p udp --dport 9000:9010 -j DNAT --to-destination $lanip