{"id":178043,"date":"2020-05-02T12:00:17","date_gmt":"2020-05-02T04:00:17","guid":{"rendered":"https:\/\/gulass.cn\/?p=178043"},"modified":"2020-04-26T09:22:49","modified_gmt":"2020-04-26T01:22:49","slug":"linux-forbid-ping","status":"publish","type":"post","link":"https:\/\/gulass.cn\/linux-forbid-ping.html","title":{"rendered":"\u5b9e\u6218\uff1aLinux \u7981\u6b62\u548c\u5f00\u542f ping \u7684\u65b9\u6cd5"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\n\u672c\u6587\u6863\u4ee5\u5b9e\u6218\u7684\u5f62\u5f0f\u4ecb\u7ecd RHEL7 \u7981\u6b62\u548c\u5f00\u542f ping \u7684\u65b9\u6cd5<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n
\u4e00\u3001\u5185\u6838\u53c2\u6570\u8bbe\u7f6e<\/strong><\/div>\n
1\u3001\u5141\u8bb8ping\u8bbe\u7f6e<\/strong><\/span><\/div>\n

\u4e34\u65f6<\/p>\n

echo 0 >\/proc\/sys\/net\/ipv4\/icmp_echo_ignore_all\r\n<\/pre>\n

\u6c38\u4e45<\/p>\n

echo net.ipv4.icmp_echo_ignore_all=0 >> \/etc\/sysctl.conf\r\nsysctl -p # \u6267\u884c\u8fd9\u6761\u547d\u4ee4\u4f7f\u66f4\u6539\u540e\u7684 \/etc\/sysctl.conf \u914d\u7f6e\u6587\u4ef6\u751f\u6548\r\n<\/pre>\n

\u6ce8\u610f\uff1a\u5982\u679c \/etc\/sysctl.conf \u914d\u7f6e\u6587\u4ef6\u91cc\u5df2\u7ecf\u6709 net.ipv4.icmp_echo_ignore_all \u5b57\u6bb5\u4e86\uff0c\u90a3\u4e48\u76f4\u63a5\u7528 vim \u8fdb\u53bb\u66f4\u6539\u5bf9\u5e94\u7684\u503c\u5373\u53ef\u3002<\/p>\n

2\u3001\u7981\u6b62ping\u8bbe\u7f6e<\/strong><\/span><\/div>\n

\u4e34\u65f6<\/p>\n

echo 1 >\/proc\/sys\/net\/ipv4\/icmp_echo_ignore_all\r\n<\/pre>\n

\u6c38\u4e45<\/p>\n

echo net.ipv4.icmp_echo_ignore_all=1 >> \/etc\/sysctl.conf\r\nsysctl -p  # \u6267\u884c\u8fd9\u6761\u547d\u4ee4\u4f7f\u66f4\u6539\u540e\u7684 \/etc\/sysctl.conf \u914d\u7f6e\u6587\u4ef6\u751f\u6548\r\n<\/pre>\n

\u6ce8\u610f\uff1a\u5982\u679c \/etc\/sysctl.conf \u914d\u7f6e\u6587\u4ef6\u91cc\u5df2\u7ecf\u6709 net.ipv4.icmp_echo_ignore_all \u5b57\u6bb5\u4e86\uff0c\u90a3\u4e48\u76f4\u63a5\u7528 vim \u8fdb\u53bb\u66f4\u6539\u5bf9\u5e94\u7684\u503c\u5373\u53ef\u3002<\/p>\n

\u4e8c\u3001\u9632\u706b\u5899\u8bbe\u7f6e<\/strong><\/div>\n

\u6ce8\uff1a\u4f7f\u7528\u4ee5\u4e0b\u65b9\u6cd5\u7684\u524d\u63d0\u662f\u5185\u6838\u914d\u7f6e\u662f\u9ed8\u8ba4\u503c\uff0c\u4e5f\u5c31\u662f\u5185\u6838\u6ca1\u6709\u7981ping<\/p>\n

1\u3001\u5141\u8bb8PING\u8bbe\u7f6e\u00a0 \u00a0<\/strong><\/span><\/div>\n
\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0iptables -A INPUT -p icmp --icmp-type echo-request -j ACCEPT\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0iptables -A OUTPUT -p icmp --icmp-type echo-reply -j ACCEPT\r\n<\/pre>\n
2\u3001\u7981\u6b62PING\u8bbe\u7f6e<\/strong><\/span><\/div>\n
\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0iptables -A INPUT -p icmp --icmp-type 8 -s 0\/0 -j DROP\r\n\r\n      --icmp-type 8 echo request  \u8868\u793a\u56de\u663e\u8bf7\u6c42\uff08ping\u8bf7\u6c42\uff09\r\n\r\n      0\/0 \u8868\u793a\u6240\u6709 IP\r\n<\/pre>\n
\u603b\u7ed3<\/strong><\/div>\n

\u4ee5\u4e0a\u65b9\u6cd5\u9009\u62e9\u5176\u4e2d\u4e00\u79cd\u5373\u53ef\uff0c\u5e0c\u671b\u80fd\u7ed9\u5927\u5bb6\u5e26\u6765\u5e2e\u52a9\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"

\u4e34\u65f6 echo 0 >\/proc\/sys\/net\/ipv4\/icmp_echo_ignore_all \u6c38 […]<\/p>\n","protected":false},"author":63,"featured_media":178044,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-178043","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/posts\/178043","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/users\/63"}],"replies":[{"embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/comments?post=178043"}],"version-history":[{"count":5,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/posts\/178043\/revisions"}],"predecessor-version":[{"id":180811,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/posts\/178043\/revisions\/180811"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/media\/178044"}],"wp:attachment":[{"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/media?parent=178043"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/categories?post=178043"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/tags?post=178043"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}