{"id":1523,"date":"2018-09-12T20:59:18","date_gmt":"2018-09-12T12:59:18","guid":{"rendered":"http:\/\/www.eumz.com\/?p=1523"},"modified":"2018-09-12T20:59:18","modified_gmt":"2018-09-12T12:59:18","slug":"rp_filter%e5%8f%8alinux%e4%b8%8b%e5%a4%9a%e7%bd%91%e5%8d%a1%e6%8e%a5%e6%94%b6%e5%a4%9a%e6%92%ad%e7%9a%84%e9%97%ae%e9%a2%98","status":"publish","type":"post","link":"https:\/\/www.wxcn.com\/?p=1523","title":{"rendered":"rp_filter\u53caLinux\u4e0b\u591a\u7f51\u5361\u63a5\u6536\u591a\u64ad\u7684\u95ee\u9898"},"content":{"rendered":"\n<p>\u6709\u4e00\u53f0\u53cc\u7f51\u5361\u7684\u673a\u5668\uff0c\u4e0a\u9762\u88c5\u6709Fedora8\uff0c\u8fd0\u884c\u4e00\u4e2a\u7a0b\u5e8f\u3002\u8be5\u7a0b\u5e8f\u5206\u522b\u5728\u4e24\u4e2a\u7f51\u53e3\u4e0a\u90fd\u63a5\u6536\u591a\u64ad\u6570\u636e\uff0c\u7a0b\u5e8f\u8fd0\u884c\u662f\u6b63\u5e38\u7684\u3002\u4f46\u662f\uff0c\u540e\u6765\u5347\u7ea7\u7cfb\u7edf\u5230Fedora13\uff0c\u53d1\u73b0\u5c31\u51fa\u95ee\u9898\u4e86\uff1a\u5728\u8fd0\u884c\u51e0\u79d2\u949f\u540e\uff0c\u7b2c2\u4e2a\u7f51\u53e3\u4e0a\u5c31\u63a5\u6536\u4e0d\u5230\u591a\u64ad\u6570\u636e\u4e86\u3002<\/p>\n\n\n\n<p>\u80fd\u4e0d\u80fd\u6536\u5230\u591a\u64ad\uff0c\u53d6\u51b3\u4e8e\u4ea4\u6362\u673a\u662f\u4e0d\u662f\u5f80\u8fd9\u4e2a\u7f51\u53e3\u4e0a\u8f6c\u53d1\u591a\u64ad\u6570\u636e\u3002\u7a0b\u5e8f\u5728\u8d77\u52a8\u7684\u65f6\u5019\uff0c\u4f1a\u53d1\u4e00\u4e2aIGMP\u7684AddMembership\u7684\u6d88\u606f\uff0c\u4ea4\u6362\u673a\u5c06\u628a\u8fd9\u4e2a\u7f51\u53e3\u52a0\u5165\u591a\u64ad\u7ec4\u3002\u5f53\u5728\u5176\u4ed6\u7f51\u53e3\u4e0a\u6536\u5230\u8be5\u5730\u5740\u7684\u591a\u64ad\u5305\u540e\uff0c\u4f1a\u8f6c\u81f3\u8fd9\u4e2a\u7f51\u53e3\u3002\u5176\u540e\uff0c\u4e3a\u4e86\u786e\u8ba4\u8be5\u63a5\u6536\u8005\u4e00\u76f4\u5728\u7ebf\uff0c\u4ea4\u6362\u673a\u4f1a\u53d1\u9001\u4e00\u4e2aIGMPQuery\u6d88\u606f\uff0c\u63a5\u6536\u8005\u53cd\u9988\u4e00\u4e2aIGMP Report\u6d88\u606f\uff0c\u4ee5\u786e\u8ba4\u81ea\u5df1\u7684\u5b58\u5728\u3002\u5982\u679c\u4ea4\u6362\u673a\u6ca1\u6709\u6536\u5230IGMPReport\uff0c\u5219\u8ba4\u4e3a\u8be5\u63a5\u6536\u8005\u5df2\u7ecf\u65ad\u7ebf\uff0c\u5c31\u4e0d\u518d\u5f80\u8be5\u7f51\u53e3\u4e0a\u8f6c\u53d1\u591a\u64ad\u5305\u4e86\u3002<\/p>\n\n\n\n<p>\u7528\u6293\u5305\u5de5\u5177\u5b9a\u4f4d\u4e86\u4e00\u4e0b\uff0c\u53d1\u73b0\u7a0b\u5e8f\u5728\u542f\u52a8\u65f6\u786e\u5b9e\u53d1\u4e86AddMembership\u6d88\u606f\uff0c\u8fd9\u662f\u6b63\u5e38\u7684\u3002\u5728\u63a5\u6536\u4e0b\u6765\u76845\u79d2\u65f6\u95f4\u5185\uff0c\u7a0b\u5e8f\u80fd\u591f\u6536\u5230\u591a\u64ad\u6570\u636e\u3002\u63a5\u7740\uff0c\u4ea4\u6362\u673a\u53d1\u6765\u4e86\u4e00\u6761IGMPQuery\uff0c\u95ee\u9898\u6765\u4e86\uff0c\u8fd9\u4e2aFedora13\u7cfb\u7edf\u5374\u6ca1\u6709\u53cd\u9988Report\u3002\u8fd9\u662f\u5f88\u5947\u602a\u7684\u3002\u6309\u7406\u8bf4\uff0cIGMP\u5c5e\u4e8e\u7cfb\u7edf\u81ea\u52a8\u5b8c\u6210\u7684\u534f\u8bae\uff0c\u65e0\u9700\u7528\u6237\u5e72\u9884\uff1b\u90a3\u4e48\u6309\u7167\u9884\u671f\uff0cLinux\u4f1a\u81ea\u52a8\u53cd\u9988IGMPReport\u7684\u3002\u4e8b\u5b9e\u4e0a\uff0cFeodra8\u548cWinXP\u7cfb\u7edf\u5c31\u662f\u8fd9\u4e48\u505a\u7684\uff0c\u90fd\u5f88\u6b63\u5e38\u3002\u4e3a\u4ec0\u4e48\u5230\u4e86Fedora13\u53cd\u800c\u4e0d\u6b63\u5e38\u4e86\u5462\uff1f<\/p>\n\n\n\n<p>\u5728\u8c03\u67e5\u201c\u4e3a\u4ec0\u4e48\u4e0d\u53cd\u9988IGMPReport\u201d\u7684\u4e8b\u60c5\u4e0a\uff0c\u82b1\u4e86\u4e00\u5468\u65f6\u95f4\u90fd\u6ca1\u6709\u8fdb\u5c55\uff0c\u540e\u6765\u53d1\u73b0\u5176\u5b9e\u4e0d\u81f3Fedora13\uff0c\u5176\u4ed6\u7684\u4e3b\u6d41linux\u5982Ubuntu10,SUSE14\u4e5f\u5b58\u5728\u540c\u6837\u7684\u95ee\u9898\u3002<\/p>\n\n\n\n<p>\u67e5\u4e86\u4f17\u591a\u8bba\u575b\u90fd\u6ca1\u6709\u4e00\u70b9\u63d0\u793a\u4fe1\u606f\u3002\u540e\u6765\uff0c\u7ec8\u4e8e\u5728\u4e00\u4e2a\u82f1\u6587\u7f51\u7ad9\u4e0a\u626b\u5230\u4e86\u4e00\u4e2a\u4fe1\u606f:rp_filter\u3002\u540e\u6765\u8bc1\u660e\uff0c\u8fd9\u4e2a\u5173\u952e\u8bcd\u662f\u89e3\u51b3\u95ee\u9898\u7684\u5173\u952e\u3002reverse-pathfiltering\uff0c\u53cd\u5411\u8fc7\u6ee4\u6280\u672f\uff0c\u7cfb\u7edf\u5728\u63a5\u6536\u5230\u4e00\u4e2aIP\u5305\u540e\uff0c\u68c0\u67e5\u8be5IP\u662f\u4e0d\u662f\u5408\u4e4e\u8981\u6c42\uff0c\u4e0d\u5408\u8981\u6c42\u7684IP\u5305\u4f1a\u88ab\u7cfb\u7edf\u4e22\u5f03\u3002\u8be5\u6280\u672f\u5c31\u79f0\u4e3arpfilter\u3002\u600e\u4e48\u6837\u7684\u5305\u624d\u7b97\u4e0d\u5408\u8981\u6c42\u5462\uff1f\u4f8b\u5982\uff0c\u7528\u6237\u5728A\u7f51\u53e3\u4e0a\u6536\u5230\u4e00\u4e2aIP\u5305\uff0c\u68c0\u67e5\u5176IP\u4e3aB\u3002\u7136\u540e\u8003\u67e5\uff1a\u5bf9\u4e8eB\u8fd9\u4e2aIP\uff0c\u5728\u53d1\u9001\u65f6\u5e94\u8be5\u7528\u54ea\u4e2a\u7f51\u53e3\uff0c\u201c\u5982\u679c\u5728\u4e0d\u5e94\u8be5\u63a5\u6536\u5230\u8be5\u5305\u7684\u7f51\u53e3\u4e0a\u63a5\u6536\u5230\u8be5IP\u5305\uff0c\u5219\u8ba4\u4e3a\u8be5IP\u5305\u662fhacker\u884c\u4e3a\u201d\u3002<\/p>\n\n\n\n<p>\u4f8b\u5982\uff1a<\/p>\n\n\n\n<p>A: 192.168.8.100<\/p>\n\n\n\n<p>B: (IGMP Query) 10.0.0.1 \u6765\u81ea\u8def\u7531\u5668<\/p>\n\n\n\n<p>\u67e5\u627e\u8def\u7531\u8868<\/p>\n\n\n\n<p>\u7f51\u53611\u4e3a\u9ed8\u8ba4\u8def\u7531: 172.17.5.100&nbsp; 172.17.5.1<\/p>\n\n\n\n<p>\u7f51\u53612&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 192.168.8.100&nbsp; 192.168.8.1<\/p>\n\n\n\n<p>\u7cfb\u7edf\u6839\u636e\u8def\u7531\u8868\uff0c\u8ba4\u4e3a10.0.0.1\u8fd9\u4e2aIP\u5e94\u8be5\u5728\u7b2c\u4e00\u4e2a\u7f51\u5361172.17.5.100\u4e0a\u6536\u5230\uff0c\u73b0\u5b9e\u7684\u60c5\u51b5\u662f\u5728\u7b2c\u4e8c\u5f20\u7f51\u5361192.168.8.100\u4e0a\u6536\u5230\u4e86\u3002\u8ba4\u4e3a\u8fd9\u662f\u4e0d\u5408\u7406\u7684\uff0c\u4e22\u5f03\u8be5\u5305\u3002\u81f4\u547d\u7684\u95ee\u9898\u7684\uff0c\u8be5\u5305\u662f\u6765\u81ea\u8def\u7531\u5668\u7684IGMPQuery\u5305\u3002<\/p>\n\n\n\n<p>The rp_filter can reject incoming packets if their sourceaddress doesn\u2019t match the network interface that they\u2019re arrivingon, which helps to prevent IP spoofing. Turning this on, however,has its consequences: If your host has several IP addresses ondifferent interfaces, or if your single interface has multiple IPaddresses on it, you\u2019ll find that your kernel may end up rejectingvalid traffic. It\u2019s also important to note that even if you do notenable the rp_filter, protection against broadcast spoofing isalways on. Also, the protection it provides is only against spoofedinternal addresses; external addresses can still be spoofed.. Bydefault, it is disabled.<\/p>\n\n\n\n<p><strong>\u89e3\u51b3\u65b9\u6cd5\uff1a<\/strong><\/p>\n\n\n\n<p>\u7cfb\u7edf\u914d\u7f6e\u6587\u4ef6<br>1. \/etc\/sysctl.conf<br>\u628a net.ipv4.conf.all.rp_filter\u548cnet.ipv4.conf.default.rp_filter\u8bbe\u4e3a0\u5373\u53ef<br>net.ipv4.conf.default.rp_filter = 0<br>net.ipv4.conf.all.rp_filter = 0<br>\u7cfb\u7edf\u542f\u52a8\u540e\uff0c\u4f1a\u81ea\u52a8\u52a0\u8f7d\u8fd9\u4e2a\u914d\u7f6e\u6587\u4ef6\uff0c\u5185\u6838\u4f1a\u4f7f\u7528\u8fd9\u4e2a\u53d8\u91cf<\/p>\n\n\n\n<p>2. \u547d\u4ee4\u884c<br>\u663e\u793a\u4e00\u4e2a\u5185\u6838\u53d8\u91cf sysctl net.ipv4.conf.all.rp_filter<br>\u8bbe\u7f6e\u4e00\u4e2a\u5185\u6838\u53d8\u91cf sysctl -w net.ipv4.conf.all.rp_filter=0<br>\u8bbe\u7f6e\u5b8c\u540e\uff0c\u4f1a\u66f4\u65b0\u5185\u6838\uff08\u5b9e\u65f6\u7684\u5185\u5b58\uff09\u4e2d\u7684\u53d8\u91cf\u7684\u503c\uff0c\u4f46\u4e0d\u4f1a\u4fee\u6539sysctl.conf\u7684\u503c<\/p>\n\n\n\n<p>3. \u4f7f\u7528\/proc\u6587\u4ef6\u7cfb\u7edf<br>\u67e5\u770b cat \/proc\/sys\/net\/ipv4\/conf\/all\/rp_filter<br>\u8bbe\u7f6e echo &#8220;0&#8221;&gt;\/proc\/sys\/net\/ipv4\/conf\/all\/rp_filter<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6709\u4e00\u53f0\u53cc\u7f51\u5361\u7684\u673a\u5668\uff0c\u4e0a\u9762\u88c5\u6709Fedora8\uff0c\u8fd0\u884c\u4e00\u4e2a\u7a0b\u5e8f\u3002\u8be5\u7a0b\u5e8f\u5206\u522b\u5728\u4e24\u4e2a\u7f51\u53e3\u4e0a\u90fd\u63a5\u6536\u591a\u64ad\u6570\u636e\uff0c\u7a0b\u5e8f\u8fd0\u884c\u662f\u6b63\u5e38 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[247,542],"class_list":["post-1523","post","type-post","status-publish","format-standard","hentry","category-operating-system","tag-rp_filter","tag-542"],"_links":{"self":[{"href":"https:\/\/www.wxcn.com\/index.php?rest_route=\/wp\/v2\/posts\/1523","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wxcn.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wxcn.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wxcn.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wxcn.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1523"}],"version-history":[{"count":0,"href":"https:\/\/www.wxcn.com\/index.php?rest_route=\/wp\/v2\/posts\/1523\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wxcn.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1523"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wxcn.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1523"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wxcn.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1523"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}