Iptables-script

From OpenSimulator

(Difference between revisions)
Jump to: navigation, search
(New page: <script lang=bash> #!/bin/sh wanip=`wget -qO- http://checkip.dyndns.org/ | sed 's|.* \(digit:*\.digit:*\.digit:*\.digit:*\).*|\1|'` lanip=`ifconfig | grep 'inet addr:'...)
 
m
Line 1: Line 1:
<script 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|'`
Line 6: Line 6:
 
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
</script>
+
</source>

Revision as of 10:02, 4 May 2008

#!/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
Personal tools
General
About This Wiki