- 论坛徽章:
- 0
|
我公司的上级机构邮件服务器是由exchange建立的,我们客户端用web之outlook web access方式访问邮件服务器收取邮件,我建立的代理服务器设置为透明代理,使用iptables照sykt 发表帖子http://bbs.chinaunix.net/forum/viewtopic.php?t=485719&show_type=做的防火墙,但是运行防火墙以后,收取邮件却无法显示出邮件信息,但是上其他网站等正常!
我的firewall配置如下:
#!/bin/sh
#外网网卡;
EXT_IF="eth0"
FW_IP="192.168.1.60"
#内网网卡
INT_IF="eth1"
LAN_IP="10.10.1.15"
LAN_IP_RANGE="10.10.1.0/255.255.255.0"
echo "Enabling IP FORWARDING......................"
echo "1" >; /proc/sys/net/ipv4/ip_forward
echo "Enabling iptables rules...................."
iptables -F
iptables -X
iptables -F -t mangle
iptables -X -t mangle
iptables -F -t nat
iptables -X -t nat
iptables -Z -t nat
iptables -P INPUT DROP
iptables -P FORWARD DROP
iptables -P OUTPUT DROP
iptables -A FORWARD -p tcp --dport 4444 -j DROP
iptables -A FORWARD -p udp --dport 4444 -j DROP
iptables -A FORWARD -p tcp --dport 445 -j DROP
iptables -A FORWARD -p udp --dport 445 -j DROP
iptables -A FORWARD -p tcp --dport 69 -j DROP
iptables -A FORWARD -p udp --dport 69 -j DROP
iptables -A FORWARD -p tcp --dport 135 -j DROP
iptables -A FORWARD -p udp --dport 135 -j DROP
iptables -A FORWARD -p tcp --dport 139 -j DROP
iptables -A FORWARD -p udp --dport 139 -j DROP
#yunxu ping localhost,ping 10.10.0.0/2
iptables -A INPUT -p icmp -i lo -j ACCEPT
iptables -A OUTPUT -p icmp -o lo -j ACCEPT
# open lan to lan linking
iptables -A INPUT -i lo -j ACCEPT
#yun xu proxy server to Lan pc send data(or ping)
iptables -A INPUT -p ALL -i $INT_IF -s $LAN_IP_RANGE -j ACCEPT
iptables -A OUTPUT -p ALL -o $INT_IF -d $LAN_IP_RANGE -j ACCEPT
#noenable INT_LAN ping LAN PC
iptables -A INPUT -i $EXT_IF -s 10.10.1.0/24 -j DROP
iptables -A INPUT -i $EXT_IF -s 10.0.0.0/8 -j DROP
iptables -A INPUT -i $EXT_IF -s 172.16.0.0/12 -j DROP
iptables -A INPUT -i $EXT_IF -s 127.0.0.0/8 -j DROP
iptables -A INPUT -i $EXT_IF -s 10.10.50.0/24 -j DROP
#if going to proxy_fire dhcp, don't open,only proxy_fire do dhcp ok
iptables -A INPUT -p udp -i $INT_IF --dport 67 --sport 68 -j DROP
iptables -A OUTPUT -o $EXT_IF -p tcp -m state --state ESTABLISHED,NEW -j ACCEPT
#form EXT_LAN to LAN packs
iptables -A INPUT -i $EXT_IF -p tcp -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A FORWARD -i $EXT_IF -p tcp -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A FORWARD -i $EXT_IF -p udp -m state --state ESTABLISHED,RELATED -j ACCEPT
#ding yi LAN to EXT_LAN packs
iptables -A FORWARD -i $INT_IF -s 10.10.0.0/24 -j ACCEPT
iptables -A INPUT -m limit --limit 3/minute --limit-burst 3 -j LOG --log-level INFO --log-prefix "IPT INPUT packetd died:"
iptables -A FORWARD -f -m limit --limit 100/s --limit-burst 100 -j ACCEPT
iptables -A FORWARD -p icmp -m limit --limit 1/s --limit-burst 10 -j ACCEPT
iptables -A FORWARD -p tcp --tcp-flags SYN,ACK,FIN,RST, RST -m limit --limit 1/s -j ACCEPT
#open UDP packers
iptables -A FORWARD -p udp -d $LAN_IP_RANGE -i $EXT_IF -j ACCEPT
#open mail POP3 and SMTP
iptables -A INPUT -i $EXT_IF -p tcp -s any/0 --sport 1024:65535 -d $FW_IP --dport 25 -j ACCEPT
iptables -A OUTPUT -o $EXT_IF -p tcp ! --syn -s $FW_IP --sport 25 -d any/0 --dport 1024:65535 -j ACCEPT
iptables -A OUTPUT -o $EXT_IF -p tcp -s $FW_IP --sport 1024:65535 -d any/0 --dport 25 -j ACCEPT
iptables -A INPUT -i $EXT_IF -p tcp ! --syn -s any/0 --sport 25 -d $FW_IP --dport 1024:65535 -j ACCEPT
iptables -A OUTPUT -o $EXT_IF -p tcp -s $FW_IP --sport 1024:65535 -d any/0 --dport 110 -j ACCEPT
iptables -A INPUT -i $EXT_IF -p tcp ! --syn -s any/0 --sport 110 -d $FW_IP --dport 1024:65535 -j ACCEPT
#open 80 port
iptables -A OUTPUT -o $EXT_IF -p tcp -s $FW_IP --sport 1024:65535 -d any/0 --dport 80 -j ACCEPT
iptables -A INPUT -i $EXT_IF -p tcp ! --syn -s any/0 --sport 80 -d $FW_IP --dport 1024:65535 -j ACCEPT
#open server DNS port:53
iptables -A OUTPUT -o $EXT_IF -p udp -s $FW_IP --sport 1024:65535 -d any/0 --dport 53 -j ACCEPT
iptables -A INPUT -i $EXT_IF -p udp -s any/0 --sport 53 -d $FW_IP --dport 1024:65535 -j ACCEPT
#error change tcp pack check
iptables -A OUTPUT -o $EXT_IF -p tcp -s $FW_IP --sport 1024:65535 -d any/0 --dport 53 -j ACCEPT
iptables -A INPUT -i $EXT_IF -p tcp ! --syn -s any/0 --sport 53 -d $FW_IP --dport 1024:65535 -j ACCEPT
#open the server DNS searching:user UDP
iptables -A OUTPUT -o $EXT_IF -p udp -s $FW_IP --sport 53 -d any/0 --dport 53 -j ACCEPT
iptables -A INPUT -i $EXT_IF -p udp -s any/0 --sport 53 -d $FW_IP --dport 53 -j ACCEPT
#open the server DNS :user tcp
iptables -A OUTPUT -o EXT_IF -p tcp -s $FW_IP --sport 53 -d any/0 --dport 53 -j ACCEPT
iptables -A INPUT -i EXT_IF -p tcp ! --syn -s any/0 --sport 53 -d $FW_IP --dport 53 -j ACCEPT
#open SSH port:22
iptables -A OUTPUT -o $EXT_IF -p tcp -s $FW_IP --sport 1024:65535 -d any/0 --dport 22 -j ACCEPT
iptables -A INPUT -i $EXT_IF -p tcp ! --syn -s any/0 --sport 22 -d $FW_IP --dport 1024:65535 -j ACCEPT
iptables -A OUTPUT -o $EXT_IF -p tcp -s $FW_IP --sport 1020:1023 -d any/0 --dport 22 -j ACCEPT
iptables -A INPUT -i $EXT_IF -p tcp ! --syn -s any/0 --sport 22 -d $FW_IP --dport 1020:1023 -j ACCEPT
#open lan worknet FPT
iptables -A OUTPUT -o $EXT_IF -p tcp -s $FW_IP --sport 1024:65535 -d any/0 --dport 21 -j ACCEPT
iptables -A INPUT -i $EXT_IF -p tcp ! --syn -s any/0 --sport 21 -d $FW_IP --dport 1024:65535 -j ACCEPT
iptables -A INPUT -i $EXT_IF -p tcp ! --syn -s any/0 --sport 20 -d $FW_IP --dport 1024:65535 -j ACCEPT
iptables -A OUTPUT -o $EXT_IF -p tcp -s $FW_IP --sport 1024:65535 -d any/0 --dport 20 -j ACCEPT
#open passive FTP
iptables -A OUTPUT -o $EXT_IF -p tcp -s $FW_IP --sport 1024:65535 -d any/0 --dport 1024:65535 -j ACCEPT
iptables -A INPUT -i $EXT_IF -p tcp ! --syn -s any/0 --sport 1024:65535 -d $FW_IP --dport 1024:65535 -j ACCEPT
#-----------------------start net------------------------
#iptables -t nat -A POSTROUTING -o $EXT_IF -s $LAN_IP_RANGE -j SNAT --to $FW_IP
iptables -t nat -A POSTROUTING -j MASQUERADE
#set proxy to squid
iptables -t nat -A PREROUTING -i $INT_IF -p tcp --dport 80 -j REDIRECT --to-ports 808
#iptables -t nat -A POSTROUTING -j MASQUERADE
#source address change SNAT
#iptables -t nat -A POSTROUTING -o $EXT_IF -s $LAN_IP_RANGE -j SNAT --to $FW_IP
#open DNAT
#iptables -A FORWARD -i $EXT_IF -p tcp -d 10.10.1.15 --dport 80 -j ACCEPT
#iptables -t nat -A PREROUTING -i $EXT_IF -p tcp -d $FW_IP --dport 80 -j DNAT --to 10.15.1.15 |
|