- 论坛徽章:
- 0
|
本帖最后由 1404383934 于 2012-06-27 22:44 编辑
防火墙开启的情况下用PuTTY连接服务器,报Network error: Connection timeout的错误……
首先,之前在家里内网测试全部通过。然后今天去托管,在机房下面的办公室内测试,也是可以连接。
奇怪就奇怪在,在家里始终连接不了,不得已把iptables给stop掉,就可以连上了……
规则是写在一个脚本里,并用rc.local调用,在开机时加载。
以下是用iptables-save存储下来的规则集,求高手看下有什么地方不对,研究整整一天了,自己看不出来。
请教!!!!或者教我如何去trace或类似debug也可以……
有描述不清的地方,请指正,另外hosts.allow和deny都是空的。
- # Generated by iptables-save v1.3.5 on Wed Jun 27 21:17:17 2012
- *mangle
- :PREROUTING ACCEPT [400:40815]
- :INPUT ACCEPT [400:40815]
- :FORWARD ACCEPT [0:0]
- :OUTPUT ACCEPT [397:55532]
- :POSTROUTING ACCEPT [397:55532]
- COMMIT
- # Completed on Wed Jun 27 21:17:17 2012
- # Generated by iptables-save v1.3.5 on Wed Jun 27 21:17:17 2012
- *nat
- :PREROUTING ACCEPT [28:4357]
- :POSTROUTING ACCEPT [36:2675]
- :OUTPUT ACCEPT [36:2675]
- COMMIT
- # Completed on Wed Jun 27 21:17:17 2012
- # Generated by iptables-save v1.3.5 on Wed Jun 27 21:17:17 2012
- *filter
- :INPUT DROP [0:0]
- :FORWARD DROP [0:0]
- :OUTPUT DROP [0:0]
- :ACCEPTLOG - [0:0]
- :DROPLOG - [0:0]
- :REJECTLOG - [0:0]
- :RELATED_ICMP - [0:0]
- :SYN_FLOOD - [0:0]
- -A INPUT -p icmp -m limit --limit 1/sec --limit-burst 2 -j ACCEPT
- -A INPUT -p icmp -m limit --limit 1/sec --limit-burst 2 -j LOG --log-prefix "PING-DROP:"
- -A INPUT -p icmp -j DROP
- -A INPUT -p icmp -f -j DROPLOG
- -A INPUT -p icmp -m state --state ESTABLISHED -m limit --limit 3/sec --limit-burst 8 -j ACCEPT
- -A INPUT -p icmp -m state --state RELATED -m limit --limit 3/sec --limit-burst 8 -j RELATED_ICMP
- -A INPUT -p icmp -m icmp --icmp-type 8 -m limit --limit 3/sec --limit-burst 8 -j ACCEPT
- -A INPUT -p icmp -j DROPLOG
- -A INPUT -i lo -j ACCEPT
- -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
- -A INPUT -p tcp -m multiport --dports 135,137,138,139,445,1433,1434 -j DROP
- -A INPUT -p udp -m multiport --dports 135,137,138,139,445,1433,1434 -j DROP
- -A INPUT -m state --state INVALID -j DROP
- -A INPUT -p tcp -m state --state NEW -m tcp --tcp-flags FIN,SYN,RST,PSH,ACK,URG FIN,SYN,RST,PSH,ACK,URG -j DROP
- -A INPUT -p tcp -m state --state NEW -m tcp --tcp-flags FIN,SYN,RST,PSH,ACK,URG NONE -j DROP
- -A INPUT -p tcp -m tcp --tcp-flags FIN,SYN,RST,ACK SYN -j SYN_FLOOD
- -A INPUT -s 0.0.0.0/254.0.0.0 -j DROP
- -A INPUT -s 2.0.0.0/255.0.0.0 -j DROP
- -A INPUT -s 5.0.0.0/255.0.0.0 -j DROP
- -A INPUT -s 7.0.0.0/255.0.0.0 -j DROP
- -A INPUT -s 10.0.0.0/255.0.0.0 -j DROP
- -A INPUT -s 23.0.0.0/255.0.0.0 -j DROP
- -A INPUT -s 27.0.0.0/255.0.0.0 -j DROP
- -A INPUT -s 31.0.0.0/255.0.0.0 -j DROP
- -A INPUT -s 36.0.0.0/254.0.0.0 -j DROP
- -A INPUT -s 39.0.0.0/255.0.0.0 -j DROP
- -A INPUT -s 42.0.0.0/255.0.0.0 -j DROP
- -A INPUT -s 49.0.0.0/255.0.0.0 -j DROP
- -A INPUT -s 50.0.0.0/255.0.0.0 -j DROP
- -A INPUT -s 77.0.0.0/255.0.0.0 -j DROP
- -A INPUT -s 78.0.0.0/254.0.0.0 -j DROP
- -A INPUT -s 92.0.0.0/252.0.0.0 -j DROP
- -A INPUT -s 96.0.0.0/240.0.0.0 -j DROP
- -A INPUT -s 112.0.0.0/248.0.0.0 -j DROP
- -A INPUT -s 120.0.0.0/255.0.0.0 -j DROP
- -A INPUT -s 169.254.0.0/255.255.0.0 -j DROP
- -A INPUT -s 172.16.0.0/255.240.0.0 -j DROP
- -A INPUT -s 173.0.0.0/255.0.0.0 -j DROP
- -A INPUT -s 174.0.0.0/254.0.0.0 -j DROP
- -A INPUT -s 176.0.0.0/248.0.0.0 -j DROP
- -A INPUT -s 184.0.0.0/252.0.0.0 -j DROP
- -A INPUT -s 192.0.2.0/255.255.255.0 -j DROP
- -A INPUT -s 197.0.0.0/255.0.0.0 -j DROP
- -A INPUT -s 198.18.0.0/255.254.0.0 -j DROP
- -A INPUT -s 223.0.0.0/255.0.0.0 -j DROP
- -A INPUT -s 224.0.0.0/224.0.0.0 -j DROP
- -A INPUT -p udp -m state --state NEW -m udp --dport 53 -j ACCEPT
- -A INPUT -p tcp -m state --state NEW -m tcp --dport 53 -j ACCEPT
- -A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT
- -A INPUT -p tcp -m state --state NEW -m tcp --dport 443 -j ACCEPT
- -A INPUT -p tcp -m state --state NEW -m tcp --dport 110 -j ACCEPT
- -A INPUT -p tcp -m state --state NEW -m tcp --dport 143 -j ACCEPT
- -A INPUT -p tcp -m state --state NEW -m tcp --dport 995 -j ACCEPT
- -A INPUT -p tcp -m state --state NEW -m tcp --dport 25 -j ACCEPT
- -A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT
- -A INPUT -p tcp -m state --state NEW -m tcp --dport 21 -j ACCEPT
- -A INPUT -p tcp -m state --state NEW -m tcp --dport 50000:50030 -j ACCEPT
- -A INPUT -j REJECTLOG
- -A FORWARD -p icmp -f -j DROPLOG
- -A FORWARD -p icmp -j DROPLOG
- -A FORWARD -m state --state INVALID -j DROP
- -A FORWARD -j REJECTLOG
- -A OUTPUT -p icmp -j ACCEPT
- -A OUTPUT -p icmp -f -j DROPLOG
- -A OUTPUT -p icmp -m state --state ESTABLISHED -m limit --limit 3/sec --limit-burst 8 -j ACCEPT
- -A OUTPUT -p icmp -m state --state RELATED -m limit --limit 3/sec --limit-burst 8 -j RELATED_ICMP
- -A OUTPUT -p icmp -m icmp --icmp-type 8 -m limit --limit 3/sec --limit-burst 8 -j ACCEPT
- -A OUTPUT -p icmp -j DROPLOG
- -A OUTPUT -o lo -j ACCEPT
- -A OUTPUT -m state --state NEW,RELATED,ESTABLISHED -j ACCEPT
- -A OUTPUT -m state --state INVALID -j DROP
- -A OUTPUT -p udp -m state --state NEW -m udp --dport 53 -j ACCEPT
- -A OUTPUT -p tcp -m state --state NEW -m tcp --dport 53 -j ACCEPT
- -A OUTPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT
- -A OUTPUT -p tcp -m state --state NEW -m tcp --dport 443 -j ACCEPT
- -A OUTPUT -p tcp -m state --state NEW -m tcp --dport 587 -j ACCEPT
- -A OUTPUT -p tcp -m state --state NEW -m tcp --dport 995 -j ACCEPT
- -A OUTPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT
- -A OUTPUT -p tcp -m state --state NEW -m tcp --dport 21 -j ACCEPT
- -A OUTPUT -p udp -m state --state NEW -m udp --sport 67:68 --dport 67:68 -j ACCEPT
- -A OUTPUT -p udp -m state --state NEW -m udp --dport 1194 -j ACCEPT
- -A OUTPUT -j REJECTLOG
- -A ACCEPTLOG -m limit --limit 3/sec --limit-burst 8 -j LOG --log-prefix "ACCEPT " --log-level 7 --log-tcp-sequence --log-tcp-options --log-ip-options
- -A ACCEPTLOG -j ACCEPT
- -A DROPLOG -m limit --limit 3/sec --limit-burst 8 -j LOG --log-prefix "DROP " --log-level 7 --log-tcp-sequence --log-tcp-options --log-ip-options
- -A DROPLOG -j DROP
- -A REJECTLOG -m limit --limit 3/sec --limit-burst 8 -j LOG --log-prefix "REJECT " --log-level 7 --log-tcp-sequence --log-tcp-options --log-ip-options
- -A REJECTLOG -p tcp -j REJECT --reject-with tcp-reset
- -A REJECTLOG -j REJECT --reject-with icmp-port-unreachable
- -A RELATED_ICMP -p icmp -m icmp --icmp-type 3 -j ACCEPT
- -A RELATED_ICMP -p icmp -m icmp --icmp-type 11 -j ACCEPT
- -A RELATED_ICMP -p icmp -m icmp --icmp-type 12 -j ACCEPT
- -A RELATED_ICMP -j DROPLOG
- -A SYN_FLOOD -m limit --limit 2/sec --limit-burst 6 -j RETURN
- -A SYN_FLOOD -j DROP
- COMMIT
- # Completed on Wed Jun 27 21:17:17 2012
复制代码 另外,脚本用的是这个 http://forums.digitalpoint.com/showthread.php?t=1031456
|
|