#!/bin/sh PATH=$PATH:/usr/sbin:/sbin echo 1 > /proc/sys/net/ipv4/ip_forward iptables -F INPUT iptables -F FORWARD iptables -F POSTROUTING -t nat iptables -P FORWARD DROP insmod ip_nat_ftp insmod ip_conntrack_ftp iptables -A FORWARD -s 192.168.0.0/24 -j ACCEPT #iptables -A FORWARD -s 172.16.1.0/16 -j ACCEPT iptables -A FORWARD -i eth0 -m state --state ESTABLISHED,RELATED -j ACCEPT ##########web################ #iptables -t nat -A PREROUTING -d 222.240.220.18 -p tcp --dport 80 -j DNAT --to 172.16.1.8 #iptables -t nat -A POSTROUTING -d 172.16.1.8 -p tcp --dport 80 -j SNAT --to 172.16.1.1 #iptables -A FORWARD -o eth0 -d 172.16.1.8 -p tcp --dport 80 -j ACCEPT #iptables -A FORWARD -i eth0 -s 172.16.1.8 -p tcp --sport 80 -m --state ESTABLISHED -j ACCEPT #########mysql############### #iptables -t nat -A PREROUTING -d 222.240.220.18 -p tcp --dport 3306 -j DNAT --to 172.16.1.8 #iptables -t nat -A POSTROUTING -d 172.16.1.8 -p tcp --dport 3306 -j SNAT --to 172.16.1.1 #iptables -A FORWARD -o eth0 -d 172.16.1.8 -p tcp --dport 3306 -j ACCEPT #iptables -A FORWARD -i eth0 -s 172.16.1.8 -p tcp --sport 3306 -m --state ESTABLISHED -j ACCEPT #########ftp################# #iptables -t nat -A PREROUTING -d 222.240.220.18 -p tcp --dport 21 -j DNAT --to 172.16.1.8 #iptables -A FORWARD -o eth0 -d 172.16.1.8 -p tcp --dport 21 -j ACCEPT #iptables -A FORWARD -i eth0 -s 172.16.1.8 -p tcp --sport 21 -m --state ESTABLISHED -j ACCEPT #########ftp-data############ #iptables -A FORWARD -i eth0 -s 172.16.1.8 -p tcp --sport 20 -m --state ESTABLISHED,RELATED -j ACCEPT #iptables -A FORWARD -o eth0 -d 172.16.1.8 -p tcp --dport 20 -m --state ESTABLISHED -j ACCEPT iptables -t nat -A POSTROUTING -o eth0 -s 192.168.0.0/24 -j MASQUERADE iptables -t nat -A POSTROUTING -s 192.168.0.0/16 -o eth0 -j SNAT --to 220.168.64.98 (责任编辑:IT) |