{"id":153,"date":"2021-05-06T10:49:08","date_gmt":"2021-05-06T02:49:08","guid":{"rendered":"http:\/\/blog.ppdd.vip\/?p=153"},"modified":"2021-05-06T10:49:08","modified_gmt":"2021-05-06T02:49:08","slug":"linux%e7%a6%81%e6%ad%a2ping%e7%9a%84%e4%b8%a4%e7%a7%8d%e6%96%b9%e6%b3%95","status":"publish","type":"post","link":"https:\/\/blog.ppdd.vip\/index.php\/2021\/05\/06\/linux%e7%a6%81%e6%ad%a2ping%e7%9a%84%e4%b8%a4%e7%a7%8d%e6%96%b9%e6%b3%95\/","title":{"rendered":"Linux\u7981\u6b62ping\u7684\u4e24\u79cd\u65b9\u6cd5"},"content":{"rendered":"<p>Linux\u9ed8\u8ba4\u662f\u5141\u8bb8Ping\u54cd\u5e94\u7684\uff0c\u7cfb\u7edf\u662f\u5426\u5141\u8bb8Ping\u75312\u4e2a\u56e0\u7d20\u51b3\u5b9a\u7684\uff1aA\u3001\u5185\u6838\u53c2\u6570\uff0cB\u3001\u9632\u706b\u5899\uff0c\u9700\u89812\u4e2a\u56e0\u7d20\u540c\u65f6\u5141\u8bb8\u624d\u80fd\u5141\u8bb8Ping\uff0c2\u4e2a\u56e0\u7d20\u6709\u4efb\u610f\u4e00\u4e2a\u7981Ping\u5c31\u65e0\u6cd5Ping\u3002<\/p>\n<p>&nbsp;<\/p>\n<p>\u5177\u4f53\u7684\u914d\u7f6e\u65b9\u6cd5\u5982\u4e0b\uff1a<\/p>\n<p>&nbsp;<\/p>\n<p><strong>A\u3001\u5185\u6838\u53c2\u6570\u8bbe\u7f6e<\/strong><\/p>\n<p>1\u3001\u5141\u8bb8PING\u8bbe\u7f6e<\/p>\n<p>A.\u4e34\u65f6\u5141\u8bb8PING\u64cd\u4f5c\u7684\u547d\u4ee4\u4e3a\uff1a#echo 0 &gt;\/proc\/sys\/net\/ipv4\/icmp_echo_ignore_all<\/p>\n<p>B.\u6c38\u4e45\u5141\u8bb8PING\u914d\u7f6e\u65b9\u6cd5\u3002<\/p>\n<p><strong>\/etc\/sysctl.conf<\/strong>\u00a0\u4e2d\u589e\u52a0\u4e00\u884c<\/p>\n<p><strong>net.ipv4.icmp_echo_ignore_all=1<\/strong><\/p>\n<p>\u5982\u679c\u5df2\u7ecf\u6709net.ipv4.icmp_echo_ignore_all\u8fd9\u4e00\u884c\u4e86\uff0c\u76f4\u63a5\u4fee\u6539=\u53f7\u540e\u9762\u7684\u503c\u5373\u53ef\u7684\uff080\u8868\u793a\u5141\u8bb8\uff0c1\u8868\u793a\u7981\u6b62\uff09\u3002<\/p>\n<p>\u4fee\u6539\u5b8c\u6210\u540e\u6267\u884c<strong>sysctl -p<\/strong>\u4f7f\u65b0\u914d\u7f6e\u751f\u6548\u3002<\/p>\n<p>&nbsp;<\/p>\n<p>2\u3001\u7981\u6b62Ping\u8bbe\u7f6e<\/p>\n<p>A.\u4e34\u65f6\u7981\u6b62PING\u7684\u547d\u4ee4\u4e3a\uff1a#echo 1 &gt;\/proc\/sys\/net\/ipv4\/icmp_echo_ignore_all<\/p>\n<p>B.\u6c38\u4e45\u5141\u8bb8PING\u914d\u7f6e\u65b9\u6cd5\u3002<\/p>\n<p><strong>\/etc\/sysctl.conf<\/strong>\u00a0\u4e2d\u589e\u52a0\u4e00\u884c<\/p>\n<p><strong>net.ipv4.icmp_echo_ignore_all=0<\/strong><\/p>\n<p>\u5982\u679c\u5df2\u7ecf\u6709net.ipv4.icmp_echo_ignore_all\u8fd9\u4e00\u884c\u4e86\uff0c\u76f4\u63a5\u4fee\u6539=\u53f7\u540e\u9762\u7684\u503c\u5373\u53ef\u7684\u3002\uff080\u8868\u793a\u5141\u8bb8\uff0c1\u8868\u793a\u7981\u6b62\uff09<\/p>\n<p>\u4fee\u6539\u5b8c\u6210\u540e\u6267\u884c<strong>sysctl -p<\/strong>\u4f7f\u65b0\u914d\u7f6e\u751f\u6548\u3002<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p><strong>B\u3001\u9632\u706b\u5899\u8bbe\u7f6e\uff08<\/strong>\u6ce8\uff1a\u6b64\u5904\u7684\u65b9\u6cd5\u7684\u524d\u63d0\u662f\u5185\u6838\u914d\u7f6e\u662f\u9ed8\u8ba4\u503c\uff0c\u4e5f\u5c31\u662f\u6ca1\u6709\u7981\u6b62Ping\uff09<\/p>\n<p>\u8fd9\u91cc\u4ee5Iptables\u9632\u706b\u5899\u4e3a\u4f8b\uff0c\u5176\u4ed6\u9632\u706b\u5899\u64cd\u4f5c\u65b9\u6cd5\u53ef\u53c2\u8003\u9632\u706b\u5899\u7684\u5b98\u65b9\u6587\u6863\u3002<\/p>\n<p>1\u3001\u5141\u8bb8PING\u8bbe\u7f6e<\/p>\n<p>iptables -A INPUT -p icmp &#8211;icmp-type echo-request -j ACCEPT<\/p>\n<p>iptables -A OUTPUT -p icmp &#8211;icmp-type echo-reply -j ACCEPT<\/p>\n<p>\u6216\u8005\u4e5f\u53ef\u4ee5\u4e34\u65f6\u505c\u6b62\u9632\u706b\u5899\u64cd\u4f5c\u7684\u3002<\/p>\n<p>service iptables stop<\/p>\n<p>&nbsp;<\/p>\n<p>2\u3001\u7981\u6b62PING\u8bbe\u7f6e<\/p>\n<p>iptables -A INPUT -p icmp &#8211;icmp-type 8 -s 0\/0 -j DROP<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Linux\u9ed8\u8ba4\u662f\u5141\u8bb8Ping\u54cd\u5e94\u7684\uff0c\u7cfb\u7edf\u662f\u5426\u5141\u8bb8Ping\u75312\u4e2a\u56e0\u7d20\u51b3\u5b9a\u7684\uff1aA\u3001\u5185\u6838\u53c2\u6570\uff0cB\u3001\u9632\u706b\u5899\uff0c\u9700\u89812\u4e2a\u56e0&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[],"class_list":["post-153","post","type-post","status-publish","format-standard","hentry","category-2"],"_links":{"self":[{"href":"https:\/\/blog.ppdd.vip\/index.php\/wp-json\/wp\/v2\/posts\/153","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.ppdd.vip\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.ppdd.vip\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.ppdd.vip\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.ppdd.vip\/index.php\/wp-json\/wp\/v2\/comments?post=153"}],"version-history":[{"count":0,"href":"https:\/\/blog.ppdd.vip\/index.php\/wp-json\/wp\/v2\/posts\/153\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.ppdd.vip\/index.php\/wp-json\/wp\/v2\/media?parent=153"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.ppdd.vip\/index.php\/wp-json\/wp\/v2\/categories?post=153"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.ppdd.vip\/index.php\/wp-json\/wp\/v2\/tags?post=153"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}