Example NAT usage

Example NAT usage is a little script to show a NAT usage example.
Download

Example NAT usage Ranking & Summary

Advertisement

  • Rating:
  • License:
  • GPL
  • Price:
  • FREE
  • Publisher Name:
  • Stephanie Lockwood-Childs
  • Publisher web site:
  • http://www.linuxguruz.com/iptables/scripts/rc.firewall_014.txt

Example NAT usage Tags


Example NAT usage Description

Example NAT usage is a little script to show a NAT usage example. Example NAT usage is a little script to show a NAT usage example.Sample:#----------------------## Variable Definitions ##----------------------#EXT=eth0INT=eth1# "Masquerading" ExamplePRIV_NETS="128.111.1.1 128.111.185.0/255.255.255.0"MASQ_NET=192.168.1.0/255.255.255.0# "General SNAT" ExampleMAP_FROM=192.168.1.0/255.255.255.0MAP_TO=128.111.185.30-128.111.185.42# "Redirection" ExampleINTERNAL_IP=10.10.1.1# "Port Forwarding" ExampleEXTERNAL_IP=128.111.1.200NEWS_SERVER=10.10.1.38MAIL_SERVER=10.10.1.69# "Load Balancing" ExampleVIRTUAL_SERVER=news.sblug.comSERVER_RANGE=10.10.1.9-10.10.1.15#-------------## NAT Section ##-------------### Flush previous rules#iptables -t nat -F## Masquerading## Masquerading for outgoing connections, except privileged nets are exemptfor NET in $PRIV_NETS ; do iptables -t nat -A POSTROUTING -d $NET -o $EXT -j ACCEPTdoneiptables -t nat -A POSTROUTING -s $MASQ_NET -o $EXT -j MASQUERADE## General SNAT## Internal computers w/ private ips "borrow" public ips of other internal computers to ssh outiptables -t nat -A POSTROUTING -s $MAP_FROM -o $EXT -p tcp --dport ssh -j SNAT --to-source $MAP_TOiptables -t nat -A POSTROUTING -s $MAP_FROM -o $EXT -p udp --dport ssh -j SNAT --to-source $MAP_TO## Redirection## Redirect internal net http traffic through squid proxy, but allow direct access to local web serveriptables -t nat -A PREROUTING -i $INT -d ! $INTERNAL_IP -p tcp --dport www -j REDIRECT --to-port 8080## Port Forwarding## Forward gateway port 7000 to news server and gateway port 8000 to pop mail serveriptables -t nat -A PREROUTING -d $EXTERNAL_IP -p tcp --dport 7000 -j DNAT --to-dest $NEWS_SERVER:nntpiptables -t nat -A PREROUTING -d $EXTERNAL_IP -p tcp --dport 8000 -j DNAT --to-dest $MAIL_SERVER:pop3## Load Balancing## Basic load balancing by redirecting nntp requests to any of several local news serversiptables -t nat -A PREROUTING -d $VIRTUAL_SERVER -p tcp --dport nntp -j DNAT --to-dest $SERVER_RANGE


Example NAT usage Related Software