{"id":814,"date":"2018-10-09T11:55:02","date_gmt":"2018-10-09T02:55:02","guid":{"rendered":"https:\/\/vongg.com\/?p=814"},"modified":"2018-10-09T11:55:15","modified_gmt":"2018-10-09T02:55:15","slug":"ebtables%e4%b8%8eiptables%e7%9a%84%e5%8c%ba%e5%88%ab%ef%bc%88ebtables%e7%9a%84%e7%ae%80%e5%8d%95%e5%ba%94%e7%94%a8%ef%bc%89","status":"publish","type":"post","link":"https:\/\/vongg.com\/?p=814","title":{"rendered":"ebtables\u4e0eiptables\u7684\u533a\u522b\uff08ebtables\u7684\u7b80\u5355\u5e94\u7528\uff09"},"content":{"rendered":"<p>https:\/\/blog.csdn.net\/u013485792\/article\/details\/76522551<\/p>\n<p>ebtables\u548ciptables\u7c7b\u4f3c\uff0c\u90fd\u662fLinux\u7cfb\u7edf\u4e0b\u7f51\u7edc\u6570\u636e\u5305\u8fc7\u6ee4\u7684\u914d\u7f6e\u5de5\u5177\u3002\u65e2\u7136\u79f0\u4e4b\u4e3a\u914d\u7f6e\u5de5\u5177\uff0c\u5c31\u662f\u8bf4\u8fc7\u6ee4\u529f\u80fd\u662f\u7531\u5185\u6838\u5e95\u5c42\u63d0\u4f9b\u652f\u6301\u7684\uff0c\u8fd9\u4e24\u4e2a\u5de5\u5177\u53ea\u662f\u8d1f\u8d23\u5236\u5b9a\u8fc7\u6ee4\u7684rules.<br \/>\nebtables\u5373\u662f\u4ee5\u592a\u7f51\u6865\u9632\u706b\u5899\uff0c\u4ee5\u592a\u7f51\u6865\u5de5\u4f5c\u5728\u6570\u636e\u94fe\u8def\u5c42\uff0cebtables\u6765\u8fc7\u6ee4\u6570\u636e\u94fe\u8def\u5c42\u6570\u636e\u5305\u3002 2.6\u5185\u6838\u5185\u7f6e\u4e86ebtables\uff0c\u8981\u4f7f\u7528\u5b83\u5fc5\u987b\u5148\u5b89\u88c5ebtables\u7684\u7528\u6237\u7a7a\u95f4\u5de5\u5177\uff08ebtables-v2.0.6\uff09\uff0c\u5b89\u88c5\u5b8c\u6210\u540e\u5c31\u53ef\u4ee5\u4f7f\u7528ebtables\u6765\u8fc7\u6ee4\u7f51\u6865\u7684\u6570\u636e\u5305\u3002 \u53c2\u7167\u7528\u6237\u5b9e\u9645\u8981\u6c42\uff0c\u8bbe\u7f6eebtables\u89c4\u5219\u5982\u4e0b\uff1a<br \/>\n1:\u5bf9\u6240\u6709\u7684\u6570\u636e\u5305\u9ed8\u8ba4\u901a\u8fc7 2:\u5206\u6e05\u695a\u6e90\u5730\u5740\u548c\u76ee\u7684\u5730\u5740\u548c\u6e90\u7aef\u53e3\u548c\u76ee\u7684\u7aef\u53e3 3:\u5bf9TCP,UDPP\u6570\u636e\u5305\u5206\u522b\u8fc7\u6ee4<br \/>\nebtables \u662f\u4e3b\u8981\u662f\u63a7\u5236\u6570\u636e\u94fe\u8def\u5c42\u7684,\u5728\u5185\u6838\u4e2d\uff0cebtables \u7684\u6570\u636e\u622a\u83b7\u70b9\u6bd4 iptables \u66f4\u201c\u9760\u524d\u201d\uff0c\u5b83\u83b7\u5f97\u7684\u6570\u636e\u66f4\u201c\u539f\u59cb\u201d\uff0cebtables \u591a\u7528\u4e8e\u6865\u6a21\u5f0f\uff0c\u6bd4\u5982\u63a7\u5236 VLAN ID \u7b49\u3002<br \/>\nebtables \u5c31\u50cf\u4ee5\u592a\u7f51\u6865\u7684 iptables\u3002iptables \u4e0d\u80fd\u8fc7\u6ee4\u6865\u63a5\u6d41\u91cf\uff0c\u800c ebtables \u53ef\u4ee5\u3002ebtables \u4e0d\u9002\u5408\u4f5c\u4e3a Internet \u9632\u706b\u5899\u3002<\/p>\n<p>\u4e00\u3001\u8fc7\u6ee4\u65f6\u673a<br \/>\n\u8981\u4e86\u89e3\u8fc7\u6ee4\u65f6\u673a\uff0c\u9996\u5148\u5f97\u4e86\u89e3\u7f51\u7edc\u6570\u636e\u5305\u8fdb\u5165\u7f51\u5361\u540e\uff0c\u5728\u7cfb\u7edf\u4e2d\u7684\u8f6c\u6362\u6d41\u7a0b\uff0c\u89c1\u4e0b\u56fe\uff1a<\/p>\n<p>&nbsp;<\/p>\n<p>\u4ece\u4e0a\u56fe\u53ef\u4ee5\u770b\u5230\u6570\u636e\u5305\u4ece\u8fdb\u5165\u5230\u79bb\u5f00\u7cfb\u7edf\uff0c\u8981\u7ecf\u8fc7PreRoute\uff0cInput\uff0cForward\uff0cOutput\uff0cPostRoute\u8fd9\u4e94\u4e2a\u9636\u6bb5\u3002\u6bcf\u4e2a\u9636\u6bb5\u4e2d\u5305\u62ec\u4e86\u4e00\u4e9b\u8282\u70b9\uff0c\u6bcf\u4e2a\u8282\u70b9\u5c31\u662f\u4e00\u4e2a\u8fc7\u6ee4\u65f6\u673a\u3002\u5f53\u6570\u636e\u5305\u884c\u8fdb\u5230\u67d0\u4e2a\u8282\u70b9\u65f6\uff0c\u7cfb\u7edf\u5c31\u662f\u68c0\u6d4b\u5bf9\u5e94\u8282\u70b9\u7684\u8fc7\u6ee4\u89c4\u5219\u5e76\u8fdb\u884c\u8fc7\u6ee4\u3002\u4ece\u56fe\u4e2d\u8fd8\u53ef\u4ee5\u53d1\u73b0\uff0c\u5bf9\u4e8e\u6bcf\u4e2a\u9636\u6bb5\uff0cebtables\u7684\u8fc7\u6ee4\u65f6\u673a\u90fd\u6bd4iptables\u8981\u65e9\u3002<br \/>\n\u4e8c\u3001ebtables\u914d\u7f6eebtables\u7684\u914d\u7f6e\u5206\u4e3a\u8868\u3001\u94fe\u548c\u89c4\u5219\u4e09\u7ea7\u30021. \u8868\u8868\u662f\u5185\u7f6e\u4e14\u56fa\u5b9a\u7684\uff0c\u5171\u6709\u4e09\u79cd: filter, nat, broute\uff0c\u7528-t\u9009\u9879\u6307\u5b9a\u3002\u6700\u5e38\u7528\u7684\u5c31\u662ffilter\u4e86\uff0c\u6240\u4ee5\u4e0d\u8bbe-t\u65f6\u9ed8\u8ba4\u5c31\u662f\u8fd9\u4e2a\u8868\u3002nat\u7528\u4e8e\u5730\u5740\u8f6c\u6362\uff0cbroute\u7528\u4e8e\u4ee5\u592a\u7f51\u6865\u30022.\u00a0 \u94fe\u94fe\u6709\u5185\u7f6e\u548c\u81ea\u5b9a\u4e49\u4e24\u79cd \u3002\u4e0d\u540c\u7684\u8868\u5185\u7f6e\u7684\u94fe\u4e0d\u540c\uff0c\u8fd9\u4e2a\u4ece\u6570\u636e\u5305\u7684\u6d41\u7a0b\u56fe\u4e2d\u5c31\u53ef\u4ee5\u770b\u51fa\u6765\u3002\u6240\u8c13\u81ea\u5b9a\u4e49\u7684\u94fe\u4e5f\u662f\u6302\u63a5\u5728\u5bf9\u5e94\u7684\u5185\u7f6e\u94fe\u5185\u7684\uff0c\u4f7f\u7528-j\u8ba9\u5176\u8df3\u8f6c\u5230\u65b0\u7684\u94fe\u4e2d\u30023. \u89c4\u5219\u6bcf\u4e2a\u94fe\u4e2d\u6709\u4e00\u7cfb\u5217\u89c4\u5219\uff0c\u6bcf\u4e2a\u89c4\u5219\u5b9a\u4e49\u4e86\u4e00\u4e9b\u8fc7\u6ee4\u9009\u9879\u3002\u6bcf\u4e2a\u6570\u636e\u5305\u90fd\u4f1a\u5339\u914d\u8fd9\u4e9b\u9879\uff0c\u4e00\u4f46\u5339\u914d\u6210\u529f\u5c31\u4f1a\u6267\u884c\u5bf9\u5e94\u7684\u52a8\u4f5c\u3002<br \/>\n\u6240\u8c13\u52a8\u4f5c\uff0c\u5c31\u662f\u8fc7\u6ee4\u7684\u884c\u4e3a\u4e86\u3002\u6709\u56db\u79cd\uff0cACCEPT\uff0cDROP\uff0cRETURN\u548cCONTINUE\u3002\u5e38\u7528\u7684\u5c31\u662fACCEPT\u548cDROP\uff0c\u53e6\u4e24\u79cd\u5c31\u4e0d\u7ec6\u8ff0\u4e86\u3002<br \/>\nEbtables\u4f7f\u7528\u89c4\u5219\u5982\u4e0b\uff1a<br \/>\nebtables [-t table] -[ADI] chain rule-specification [match-extensions] [watcher-extensions]<br \/>\n-t table :\u4e00\u822c\u4e3aFORWARD\u94fe\u3002<br \/>\n\uff0dADI\uff1aA\u6dfb\u52a0\u5230\u73b0\u6709\u94fe\u7684\u672b\u5c3e\uff1bD\u5220\u9664\u89c4\u5219\u94fe\uff08\u5fc5\u987b\u6307\u660e\u89c4\u5219\u94fe\u53f7\uff09\uff1bI\u63d2\u5165\u65b0\u7684\u89c4\u5219\u94fe\uff08\u5fc5\u987b\u6307\u660e\u89c4\u5219\u94fe\u53f7\uff09\u3002<br \/>\n-P:\u89c4\u5219\u8868\u7684\u9ed8\u8ba4\u89c4\u5219\u7684\u8bbe\u7f6e\u3002\u53ef\u4ee5DROP,ACCEPT,RETURN\u3002<br \/>\n-F:\u5bf9\u6240\u6709\u7684\u89c4\u5219\u8868\u7684\u89c4\u5219\u94fe\u6e05\u7a7a\u3002<br \/>\n-L:\u6307\u660e\u89c4\u5219\u8868\u3002\u53ef\u52a0\u53c2\u6570\uff0c&#8211;Lc,&#8211;Ln<br \/>\n-p:\u6307\u660e\u4f7f\u7528\u7684\u534f\u8bae\u7c7b\u578b\uff0cipv4,arp\u7b49\u53ef\u9009\uff08\u4f7f\u7528\u65f6\u5fc5\u9009\uff09\u8be6\u60c5\u89c1\/etc\/ethertypes<br \/>\n&#8211;ip-proto:IP\u5305\u7684\u7c7b\u578b\uff0c1\u4e3aICMP\u5305\uff0c6\u4e3aTCP\u5305\uff0c17\u4e3aUDP\u5305\uff0c\u5728\/etc\/protocols\u4e0b\u6709\u8be6\u7ec6\u8bf4\u660e<br \/>\n&#8211;ip-src:IP\u5305\u7684\u6e90\u5730\u5740<br \/>\n&#8211;ip-dst:IP\u5305\u7684\u76ee\u7684\u5730\u5740<br \/>\n&#8211;ip-sport:IP\u5305\u7684\u6e90\u7aef\u53e3<br \/>\n&#8211;ip-dport:IP\u5305\u7684\u76ee\u7684\u7aef\u53e3<br \/>\n-i:\u6307\u660e\u4ece\u90a3\u7247\u7f51\u5361\u8fdb\u5165<br \/>\n-o:\u6307\u660e\u4ece\u90a3\u7247\u7f51\u5361\u51fa\u53bb<br \/>\n\u4e09\u3001ebtables\u57fa\u672c\u547d\u4ee4\u00a0\u00a0\u00a0 \u6709\u4e86\u4e0a\u9762\u7684\u7b80\u5355\u4ecb\u7ecd\uff0c\u518d\u719f\u6089\u4e00\u4e9b\u57fa\u672c\u547d\u4ee4\u5c31\u53ef\u4ee5\u4f7f\u7528\u4e86\u30021. \u5217\u8868\uff1aebtables -Lebtables -L \u2013Lc , \u67e5\u770b\u5404rule\u7684\u5339\u914d\u6b21\u6570\u4ee5\u53ca\u5b57\u8282\u65702. \u65b0\u5efa\/\u5220\u9664\u94feebtables -N &lt;chain_name&gt;ebtables -X &lt;chain_name&gt;3. \u65b0\u5efa\u89c4\u5219ebtables -A &lt;chain_name&gt; [ rules ][rules]\u6709\u51e0\u79cd-s \u6e90MAC -d \u76ee\u6807MAC -i \u5165\u63a5\u53e3 -o \u51fa\u63a5\u53e3<br \/>\n\u547d\u4ee4\u793a\u4f8b\uff1a<br \/>\nebtables -P FORWARD ACCEPT<br \/>\nebtables -P INPUT ACCEPT<br \/>\nebtables -P OUTPUT ACCEPT<br \/>\nebtables -F<br \/>\nebtables -A FORWARD -p ipv4 -i eth0\/eth1 &#8211;ip-proto (6\/17) &#8211;ip-dst(\u76ee\u7684IP)\u00a0 &#8211;ip-dport(\u76ee\u7684\u7aef\u53e3) -j DROP<br \/>\nebtables -A FPRWARD -p ipv4 -i eth0\/eth1 &#8211;ip-proto (7\/17) &#8211;ip-src(\u6e90IP) &#8211;ip-sport(\u6e90\u7aef\u53e3) -j DROP<\/p>\n<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<\/p>\n<p>\u672c\u6587\u6765\u81ea satellite13 \u7684CSDN \u535a\u5ba2 \uff0c\u5168\u6587\u5730\u5740\u8bf7\u70b9\u51fb\uff1ahttps:\/\/blog.csdn.net\/u013485792\/article\/details\/76522551?utm_source=copy<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>https:\/\/blog.csdn.net\/u013485792\/article\/details\/765225 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[27],"tags":[],"_links":{"self":[{"href":"https:\/\/vongg.com\/index.php?rest_route=\/wp\/v2\/posts\/814"}],"collection":[{"href":"https:\/\/vongg.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/vongg.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/vongg.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/vongg.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=814"}],"version-history":[{"count":1,"href":"https:\/\/vongg.com\/index.php?rest_route=\/wp\/v2\/posts\/814\/revisions"}],"predecessor-version":[{"id":815,"href":"https:\/\/vongg.com\/index.php?rest_route=\/wp\/v2\/posts\/814\/revisions\/815"}],"wp:attachment":[{"href":"https:\/\/vongg.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=814"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/vongg.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=814"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/vongg.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=814"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}