- 论坛徽章:
- 18
|
本帖最后由 gilet 于 2010-05-21 12:58 编辑
- #!/bin/bash
- #Description:
- #a.This script is mainly used to implement the function of NAT
- #b.Implemented for:
- # The script in / root, the script name iptables
- # chmod 744 /root/iptables
- # /root/iptables
- #c.Or directly in the start-up can be as follows:
- # vi /etc/rc.d/rc.local
- #Write the following line:
- # /root/iptables
- #d.Made by gilet 2010/05/20
- ##################################################################################
- #0.Please enter your parameter values:
- EXIF='eth1'
- EXIN='eth0'
- EXNET='192.168.1.0/24'
- #1.Here are the rules. If necessary. We should not change
- #Start with the removal of routing rules:
- PATH=/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin:/root/bin
- export PATH
- modprobe ip_nat_ftp
- modprobe ip_conntrack
- echo "1">/proc/sys/net/ipv4/ip_forward
- iptables -t mangle -F
- iptables -t mangle -X
- iptables -t mangle -Z
- iptables -F
- iptables -X
- iptables -Z
- iptables -t nat -F
- iptables -t nat -X
- iptables -t nat -Z
- iptables -P INPUT DROP
- iptables -P OUTPUT ACCEPT
- iptables -P FORWARD ACCEPT
- iptables -t nat -P PREROUTING ACCEPT
- iptables -t nat -P POSTROUTING ACCEPT
- iptables -t nat -P OUTPUT ACCEPT
- iptables -A INPUT -i lo -j ACCEPT
- iptables -A INPUT -p tcp --dport 22 -j ACCEPT
- iptables -A INPUT -p tcp --dport 3600 -j ACCEPT
- iptables -A INPUT -p tcp --dport 1723 -j ACCEPT
- iptables -A INPUT -p tcp -s 192.168.1.0/24 -m multiport --dports 3690,3000,5902,3306,8000 -j ACCEPT
- iptables -A INPUT -p ICMP -s 192.168.1.0/24 -j ACCEPT
- iptables -t nat -A PREROUTING -d 221.11.86.241 -p tcp -m tcp --dport 80 -j DNAT --to-destination 192.168.1.253
- iptables -t nat -A PREROUTING -d221.11.86.240 -p tcp -m tcp --dport 80 -j DNAT --to-destination 192.168.1.250
- iptables -t nat -A PREROUTING -d 221.11.86.241 -p tcp -m tcp --dport 25 -j DNAT --to-destination 192.168.1.250
- iptables -t nat -A PREROUTING -d 221.11.86.240 -p tcp -m tcp --dport 25 -j DNAT --to-destination 192.168.1.250
- iptables -t nat -A PREROUTING -d 221.11.86.241 -p tcp -m tcp --dport 110 -j DNAT --to-destination 192.168.1.250
- iptables -t nat -A PREROUTING -d 221.11.86.240 -p tcp -m tcp --dport 110 -j DNAT --to-destination 192.168.1.250
- iptables -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
- iptables -t nat -A POSTROUTING -s $EXNET -o $EXIF -j SNAT --to 221.11.86.241
复制代码 |
|