hidekiy blog: [linux] ping は通るのに No route to host と言われる http://blog.hidekiy.com/2012/09/linux-ping-no-route-to-host.html
の再現
設定
80番(http)がiptablesで許可されている。
# iptables -L -v --line-numbers
6 2 120 ACCEPT tcp -- any any anywhere anywhere state NEW tcp dpt:http
その手前にREJECT用のルールを追加する
# iptables -I INPUT 5 -p TCP --dport 80 -j REJECT --reject-with icmp-host-prohibited
結果
そうするとpingは通るのにhttpアクセスはNo route to hostとなる。
# ping xxx.xxx.xxx.xxx
PING xxx.xxx.xxx.xxx (xxx.xxx.xxx.xxx) 56(84) bytes of data.
64 bytes from xxx.xxx.xxx.xxx: icmp_seq=1 ttl=64 time=0.075 ms
64 bytes from xxx.xxx.xxx.xxx: icmp_seq=2 ttl=64 time=0.084 ms
64 bytes from xxx.xxx.xxx.xxx: icmp_seq=3 ttl=64 time=0.083 ms
# curl xxx.xxx.xxx.xxx
curl: (7) Failed connect to xxx.xxx.xxx.xxx:80; No route to host
参考
REJECTターゲット http://www.asahi-net.or.jp/~aa4t-nngk/ipttut/output/rejecttarget.html