icmp,tcp,traceroute,ping,iptables

有東莞的監控主機到北京BGP出問題了; 報警短信瘋狂發送; 找東莞IDC和北京BGP服務商協查;tcp

 

有個奇怪的問題;北京到東莞trcaceroute都有路由信息優化

東莞143段到北京全無路由信息;但,東莞151段到北京就有路由信息;spa

檢查143段和151段的iptables配置;發現有細微的差異:ip

143:路由

# Generated by iptables-save v1.3.5 on Fri Dec 19 17:00:58 2014
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [3815024465:25962152950339]table

......監控

-A INPUT -m conntrack --ctstate ESTABLISHED -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -j DROP
-A OUTPUT -m conntrack --ctstate NEW -j ACCEPT
COMMIT
# Completed on Fri Dec 19 17:00:58 2014配置

 

151:route

# Generated by iptables-save v1.4.7 on Fri Dec 19 17:01:18 2014
*filter
:INPUT ACCEPT [158253008:8885848717]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [108990300717:428153347609533]iptables

 

.................

-A INPUT -m conntrack --ctstate ESTABLISHED -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -p tcp -m tcp --dport 22 -j DROP
-A OUTPUT -m conntrack --ctstate NEW -j ACCEPT
COMMIT
# Completed on Fri Dec 19 17:01:18 2014

 

有注意到:

-A INPUT -j DROP --------------------------------------->ping的時候是output;traceroute的時候每一個路由節點回返回包;

而規則-A OUTPUT -m conntrack --ctstate NEW -j ACCEPT默認是TCP協議;而ping/traceroute使用的是icmp協議;

-A INPUT -p tcp -m tcp --dport 22 -j DROP----------------->這個僅僅drop了22端口,此外其餘都是放行的; 

 

====

優化143段配置如:

 

#-A INPUT -p icmp -j ACCEPT------------------------------------------>添加這一條規則 -A INPUT -m conntrack --ctstate ESTABLISHED -j ACCEPT -A INPUT -i lo -j ACCEPT -A INPUT -j DROP #-A INPUT -p tcp -m tcp --dport 22 -j DROP  -A OUTPUT -m conntrack --ctstate NEW -j ACCEPT COMMIT# Completed on Fri Dec 19 17:05:26 2014

相關文章
相關標籤/搜索