{"id":576,"date":"2022-05-25T09:18:08","date_gmt":"2022-05-25T01:18:08","guid":{"rendered":"http:\/\/lrxjmw.cn\/?p=576"},"modified":"2022-05-25T12:56:38","modified_gmt":"2022-05-25T04:56:38","slug":"chapter-08","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/chapter-08.html","title":{"rendered":"\u7b2c8\u7ae0 Iptables\u4e0eFirewalld\u9632\u706b\u5899\u3002"},"content":{"rendered":"

👇\u672c\u7ae0\u8282\u5185\u5bb9\u5df2\u66f4\u65b0\uff0c\u8bf7\u5728\u7ebf\u9605\u8bfb\u6700\u65b0RHEL 8\u7248\u672c\u4e66\u7c4d 👇<\/span><\/strong><\/span><\/p>\n

https:\/\/lrxjmw.cn\/basic-learning-08.html<\/span><\/strong><\/span><\/b><\/p>\n

\u7ae0\u8282\u7b80\u8ff0\uff1a<\/strong><\/span><\/p>\n

\u4fdd\u969c\u6570\u636e\u7684\u5b89\u5168\u6027\u662f\u7ee7\u4fdd\u969c\u6570\u636e\u7684\u53ef\u7528\u6027\u4e4b\u540e\u6700\u4e3a\u91cd\u8981\u7684\u4e00\u9879\u5de5\u4f5c\u3002\u9632\u706b\u5899\u4f5c\u4e3a\u516c\u7f51\u4e0e\u5185\u7f51\u4e4b\u95f4\u7684\u4fdd\u62a4\u5c4f\u969c\uff0c\u5728\u4fdd\u969c\u6570\u636e\u7684\u5b89\u5168\u6027\u65b9\u9762\u8d77\u7740\u81f3\u5173\u91cd\u8981\u7684\u4f5c\u7528\u3002\u8003\u8651\u5230\u5927\u5bb6\u8fd8\u4e0d\u4e86\u89e3RHEL 7\u4e2d\u65b0\u589e\u7684firewalld\u9632\u706b\u5899\u4e0e\u5148\u524d\u7248\u672c\u4e2diptables\u9632\u706b\u5899\u4e4b\u95f4\u7684\u533a\u522b\uff0c\u5218\u9044\u8001\u5e08\u51b3\u5b9a\u5148\u5e26\u9886\u8bfb\u8005\u4ece\u7406\u8bba\u5c42\u9762\u548c\u5b9e\u9645\u5c42\u9762\u6b63\u786e\u5730\u8ba4\u8bc6\u5728\u8fd9\u4e24\u6b3e\u9632\u706b\u5899\u4e4b\u95f4\u7684\u5173\u7cfb\u3002<\/p>\n

\u672c\u7ae0\u5c06\u5206\u522b\u4f7f\u7528iptables\u3001firewall-cmd\u3001firewall-config\u548cTCP Wrappers\u7b49\u9632\u706b\u5899\u7b56\u7565\u914d\u7f6e\u670d\u52a1\u6765\u5b8c\u6210\u6570\u5341\u4e2a\u6839\u636e\u771f\u5b9e\u5de5\u4f5c\u9700\u6c42\u800c\u8bbe\u8ba1\u7684\u9632\u706b\u5899\u7b56\u7565\u914d\u7f6e\u5b9e\u9a8c\u3002\u5728\u5b66\u4e60\u5b8c\u8fd9\u4e9b\u5b9e\u9a8c\u4e4b\u540e\uff0c\u5404\u4f4d\u8bfb\u8005\u4e0d\u4ec5\u53ef\u4ee5\u719f\u7ec3\u5730\u8fc7\u6ee4\u8bf7\u6c42\u7684\u6d41\u91cf\uff0c\u8fd8\u53ef\u4ee5\u57fa\u4e8e\u670d\u52a1\u7a0b\u5e8f\u7684\u540d\u79f0\u5bf9\u6d41\u91cf\u8fdb\u884c\u5141\u8bb8\u548c\u62d2\u7edd\u64cd\u4f5c\uff0c\u786e\u4fddLinux\u7cfb\u7edf\u7684\u5b89\u5168\u6027\u4e07\u65e0\u4e00\u5931\u3002<\/p>\n

8.1 \u9632\u706b\u5899\u7ba1\u7406\u5de5\u5177<\/strong><\/span><\/h5>\n

\u4f17\u6240\u5468\u77e5\uff0c\u76f8\u8f83\u4e8e\u4f01\u4e1a\u5185\u7f51\uff0c\u5916\u90e8\u7684\u516c\u7f51\u73af\u5883\u66f4\u52a0\u6076\u52a3\uff0c\u7f6a\u6076\u4e1b\u751f\u3002\u5728\u516c\u7f51\u4e0e\u4f01\u4e1a\u5185\u7f51\u4e4b\u95f4\u5145\u5f53\u4fdd\u62a4\u5c4f\u969c\u7684\u9632\u706b\u5899\uff08\u89c1\u56fe8-1\uff09\u867d\u7136\u6709\u8f6f\u4ef6\u6216\u786c\u4ef6\u4e4b\u5206\uff0c\u4f46\u4e3b\u8981\u529f\u80fd\u90fd\u662f\u4f9d\u636e\u7b56\u7565\u5bf9\u7a7f\u8d8a\u9632\u706b\u5899\u81ea\u8eab\u7684\u6d41\u91cf\u8fdb\u884c\u8fc7\u6ee4\u3002\u9632\u706b\u5899\u7b56\u7565\u53ef\u4ee5\u57fa\u4e8e\u6d41\u91cf\u7684\u6e90\u76ee\u5730\u5740\u3001\u7aef\u53e3\u53f7\u3001\u534f\u8bae\u3001\u5e94\u7528\u7b49\u4fe1\u606f\u6765\u5b9a\u5236\uff0c\u7136\u540e\u9632\u706b\u5899\u4f7f\u7528\u9884\u5148\u5b9a\u5236\u7684\u7b56\u7565\u89c4\u5219\u76d1\u63a7\u51fa\u5165\u7684\u6d41\u91cf\uff0c\u82e5\u6d41\u91cf\u4e0e\u67d0\u4e00\u6761\u7b56\u7565\u89c4\u5219\u76f8\u5339\u914d\uff0c\u5219\u6267\u884c\u76f8\u5e94\u7684\u5904\u7406\uff0c\u53cd\u4e4b\u5219\u4e22\u5f03\u3002\u8fd9\u6837\u4e00\u6765\uff0c\u5c31\u53ef\u4ee5\u4fdd\u8bc1\u4ec5\u6709\u5408\u6cd5\u7684\u6d41\u91cf\u5728\u4f01\u4e1a\u5185\u7f51\u548c\u5916\u90e8\u516c\u7f51\u4e4b\u95f4\u6d41\u52a8\u4e86\u3002<\/p>\n

\"\u9632\u706b\u5899\u62d3\u6251\"<\/p>\n

\u56fe8-1\u00a0 \u9632\u706b\u5899\u4f5c\u4e3a\u516c\u7f51\u4e0e\u5185\u7f51\u4e4b\u95f4\u7684\u4fdd\u62a4\u5c4f\u969c<\/p>\n

\u5728RHEL 7\u7cfb\u7edf\u4e2d\uff0cfirewalld\u9632\u706b\u5899\u53d6\u4ee3\u4e86iptables\u9632\u706b\u5899\u3002\u5bf9\u4e8e\u63a5\u89e6Linux\u7cfb\u7edf<\/a>\u6bd4\u8f83\u65e9\u6216\u5b66\u4e60\u8fc7RHEL 6\u7cfb\u7edf\u7684\u8bfb\u8005\u6765\u8bf4\uff0c\u5f53\u4ed6\u4eec\u53d1\u73b0\u66fe\u7ecf\u638c\u63e1\u7684\u77e5\u8bc6\u5728RHEL 7\u4e2d\u4e0d\u518d\u9002\u7528\uff0c\u9700\u8981\u5168\u65b0\u5b66\u4e60firewalld\u65f6\uff0c\u96be\u514d\u4f1a\u6709\u62b5\u89e6\u5fc3\u7406\u3002\u5176\u5b9e\uff0ciptables\u4e0efirewalld\u90fd\u4e0d\u662f\u771f\u6b63\u7684\u9632\u706b\u5899\uff0c\u5b83\u4eec\u90fd\u53ea\u662f\u7528\u6765\u5b9a\u4e49\u9632\u706b\u5899\u7b56\u7565\u7684\u9632\u706b\u5899\u7ba1\u7406\u5de5\u5177\u800c\u5df2\uff0c\u6216\u8005\u8bf4\uff0c\u5b83\u4eec\u53ea\u662f\u4e00\u79cd\u670d\u52a1\u3002iptables\u670d\u52a1\u4f1a\u628a\u914d\u7f6e\u597d\u7684\u9632\u706b\u5899\u7b56\u7565\u4ea4\u7531\u5185\u6838\u5c42\u9762\u7684netfilter\u7f51\u7edc\u8fc7\u6ee4\u5668\u6765\u5904\u7406\uff0c\u800cfirewalld\u670d\u52a1\u5219\u662f\u628a\u914d\u7f6e\u597d\u7684\u9632\u706b\u5899\u7b56\u7565\u4ea4\u7531\u5185\u6838\u5c42\u9762\u7684nftables\u5305\u8fc7\u6ee4\u6846\u67b6\u6765\u5904\u7406\u3002\u6362\u53e5\u8bdd\u8bf4\uff0c\u5f53\u524d\u5728Linux\u7cfb\u7edf\u4e2d\u5176\u5b9e\u5b58\u5728\u591a\u4e2a\u9632\u706b\u5899\u7ba1\u7406\u5de5\u5177\uff0c\u65e8\u5728\u65b9\u4fbf\u8fd0\u7ef4\u4eba\u5458\u7ba1\u7406Linux\u7cfb\u7edf\u4e2d\u7684\u9632\u706b\u5899\u7b56\u7565\uff0c\u6211\u4eec\u53ea\u9700\u8981\u914d\u7f6e\u59a5\u5f53\u5176\u4e2d\u7684\u4e00\u4e2a\u5c31\u8db3\u591f\u4e86\u3002\u867d\u7136\u8fd9\u4e9b\u5de5\u5177\u5404\u6709\u4f18\u52a3\uff0c\u4f46\u5b83\u4eec\u5728\u9632\u706b\u5899\u7b56\u7565\u7684\u914d\u7f6e\u601d\u8def\u4e0a\u662f\u4fdd\u6301\u4e00\u81f4\u7684\u3002\u5927\u5bb6\u751a\u81f3\u53ef\u4ee5\u4e0d\u7528\u5b8c\u5168\u638c\u63e1\u672c\u7ae0\u4ecb\u7ecd\u7684\u5185\u5bb9\uff0c\u53ea\u8981\u5728\u8fd9\u591a\u4e2a\u9632\u706b\u5899\u7ba1\u7406\u5de5\u5177\u4e2d\u4efb\u9009\u4e00\u6b3e\u5e76\u5c06\u5176\u5b66\u900f\uff0c\u5c31\u8db3\u4ee5\u6ee1\u8db3\u65e5\u5e38\u7684\u5de5\u4f5c\u9700\u6c42\u4e86\u3002<\/p>\n

8.2 Iptables<\/strong><\/span><\/h5>\n

\u5728\u65e9\u671f\u7684Linux\u7cfb\u7edf\u4e2d\uff0c\u9ed8\u8ba4\u4f7f\u7528\u7684\u662fiptables\u9632\u706b\u5899\u7ba1\u7406\u670d\u52a1\u6765\u914d\u7f6e\u9632\u706b\u5899\u3002\u5c3d\u7ba1\u65b0\u578b\u7684firewalld\u9632\u706b\u5899\u7ba1\u7406\u670d\u52a1\u5df2\u7ecf\u88ab\u6295\u5165\u4f7f\u7528\u591a\u5e74\uff0c\u4f46\u662f\u5927\u91cf\u7684\u4f01\u4e1a\u5728\u751f\u4ea7\u73af\u5883\u4e2d\u4f9d\u7136\u51fa\u4e8e\u5404\u79cd\u539f\u56e0\u800c\u7ee7\u7eed\u4f7f\u7528iptables\u3002\u8003\u8651\u5230iptables\u5728\u5f53\u524d\u751f\u4ea7\u73af\u5883\u4e2d\u8fd8\u5177\u6709\u987d\u5f3a\u7684\u751f\u547d\u529b\uff0c\u4ee5\u53ca\u4e3a\u4e86\u4f7f\u5927\u5bb6\u5728\u6c42\u804c\u9762\u8bd5\u8fc7\u7a0b\u4e2d\u88ab\u95ee\u5230iptables\u7684\u76f8\u5173\u77e5\u8bc6\u65f6\u80fd\u80f8\u6709\u6210\u7af9\uff0c\u5218\u9044\u8001\u5e08\u89c9\u5f97\u8fd8\u662f\u6709\u5fc5\u8981\u5728\u672c\u4e66\u4e2d\u597d\u597d\u5730\u8bb2\u89e3\u4e00\u4e0b\u8fd9\u9879\u6280\u672f\u3002\u66f4\u4f55\u51b5\u524d\u6587\u4e5f\u63d0\u5230\uff0c\u5404\u4e2a\u9632\u706b\u5899\u7ba1\u7406\u5de5\u5177\u7684\u914d\u7f6e\u601d\u8def\u662f\u4e00\u81f4\u7684\uff0c\u5728\u638c\u63e1\u4e86iptables\u540e\u518d\u5b66\u4e60\u5176\u4ed6\u9632\u706b\u5899\u7ba1\u7406\u5de5\u5177\u65f6\uff0c\u4e5f\u6709\u501f\u9274\u610f\u4e49\u3002<\/p>\n

8.2.1 \u7b56\u7565\u4e0e\u89c4\u5219\u94fe<\/strong><\/span><\/h6>\n

\u9632\u706b\u5899\u4f1a\u4ece\u4e0a\u81f3\u4e0b\u7684\u987a\u5e8f\u6765\u8bfb\u53d6\u914d\u7f6e\u7684\u7b56\u7565\u89c4\u5219\uff0c\u5728\u627e\u5230\u5339\u914d\u9879\u540e\u5c31\u7acb\u5373\u7ed3\u675f\u5339\u914d\u5de5\u4f5c\u5e76\u53bb\u6267\u884c\u5339\u914d\u9879\u4e2d\u5b9a\u4e49\u7684\u884c\u4e3a\uff08\u5373\u653e\u884c\u6216\u963b\u6b62\uff09\u3002\u5982\u679c\u5728\u8bfb\u53d6\u5b8c\u6240\u6709\u7684\u7b56\u7565\u89c4\u5219\u4e4b\u540e\u6ca1\u6709\u5339\u914d\u9879\uff0c\u5c31\u53bb\u6267\u884c\u9ed8\u8ba4\u7684\u7b56\u7565\u3002\u4e00\u822c\u800c\u8a00\uff0c\u9632\u706b\u5899\u7b56\u7565\u89c4\u5219\u7684\u8bbe\u7f6e\u6709\u4e24\u79cd\uff1a\u4e00\u79cd\u662f\u201c\u901a\u201d\uff08\u5373\u653e\u884c\uff09\uff0c\u4e00\u79cd\u662f\u201c\u5835\u201d\uff08\u5373\u963b\u6b62\uff09\u3002\u5f53\u9632\u706b\u5899\u7684\u9ed8\u8ba4\u7b56\u7565\u4e3a\u62d2\u7edd\u65f6\uff08\u5835\uff09\uff0c\u5c31\u8981\u8bbe\u7f6e\u5141\u8bb8\u89c4\u5219\uff08\u901a\uff09\uff0c\u5426\u5219\u8c01\u90fd\u8fdb\u4e0d\u6765\uff1b\u5982\u679c\u9632\u706b\u5899\u7684\u9ed8\u8ba4\u7b56\u7565\u4e3a\u5141\u8bb8\u65f6\uff0c\u5c31\u8981\u8bbe\u7f6e\u62d2\u7edd\u89c4\u5219\uff0c\u5426\u5219\u8c01\u90fd\u80fd\u8fdb\u6765\uff0c\u9632\u706b\u5899\u4e5f\u5c31\u5931\u53bb\u4e86\u9632\u8303\u7684\u4f5c\u7528\u3002<\/p>\n

iptables\u670d\u52a1\u628a\u7528\u4e8e\u5904\u7406\u6216\u8fc7\u6ee4\u6d41\u91cf\u7684\u7b56\u7565\u6761\u76ee\u79f0\u4e4b\u4e3a\u89c4\u5219\uff0c\u591a\u6761\u89c4\u5219\u53ef\u4ee5\u7ec4\u6210\u4e00\u4e2a\u89c4\u5219\u94fe\uff0c\u800c\u89c4\u5219\u94fe\u5219\u4f9d\u636e\u6570\u636e\u5305\u5904\u7406\u4f4d\u7f6e\u7684\u4e0d\u540c\u8fdb\u884c\u5206\u7c7b\uff0c\u5177\u4f53\u5982\u4e0b\uff1a<\/p>\n

\u5728\u8fdb\u884c\u8def\u7531\u9009\u62e9\u524d\u5904\u7406\u6570\u636e\u5305\uff08PREROUTING\uff09\uff1b<\/p>\n

\u5904\u7406\u6d41\u5165\u7684\u6570\u636e\u5305\uff08INPUT\uff09\uff1b<\/p>\n

\u5904\u7406\u6d41\u51fa\u7684\u6570\u636e\u5305\uff08OUTPUT\uff09\uff1b<\/p>\n

\u5904\u7406\u8f6c\u53d1\u7684\u6570\u636e\u5305\uff08FORWARD\uff09\uff1b<\/p>\n

\u5728\u8fdb\u884c\u8def\u7531\u9009\u62e9\u540e\u5904\u7406\u6570\u636e\u5305\uff08POSTROUTING\uff09\u3002<\/p><\/blockquote>\n

\u4e00\u822c\u6765\u8bf4\uff0c\u4ece\u5185\u7f51\u5411\u5916\u7f51\u53d1\u9001\u7684\u6d41\u91cf\u4e00\u822c\u90fd\u662f\u53ef\u63a7\u4e14\u826f\u6027\u7684\uff0c\u56e0\u6b64\u6211\u4eec\u4f7f\u7528\u6700\u591a\u7684\u5c31\u662fINPUT\u89c4\u5219\u94fe\uff0c\u8be5\u89c4\u5219\u94fe\u53ef\u4ee5\u589e\u5927\u9ed1\u5ba2\u4eba\u5458\u4ece\u5916\u7f51\u5165\u4fb5\u5185\u7f51\u7684\u96be\u5ea6\u3002<\/p>\n

\u6bd4\u5982\u5728\u60a8\u5c45\u4f4f\u7684\u793e\u533a\u5185\uff0c\u7269\u4e1a\u7ba1\u7406\u516c\u53f8\u6709\u4e24\u6761\u89c4\u5b9a\uff1a\u7981\u6b62\u5c0f\u5546\u5c0f\u8d29\u8fdb\u5165\u793e\u533a\uff1b\u5404\u79cd\u8f66\u8f86\u5728\u8fdb\u5165\u793e\u533a\u65f6\u90fd\u8981\u767b\u8bb0\u3002\u663e\u800c\u6613\u89c1\uff0c\u8fd9\u4e24\u6761\u89c4\u5b9a\u5e94\u8be5\u662f\u7528\u4e8e\u793e\u533a\u7684\u6b63\u95e8\u7684\uff08\u6d41\u91cf\u5fc5\u987b\u7ecf\u8fc7\u7684\u5730\u65b9\uff09\uff0c\u800c\u4e0d\u662f\u6bcf\u5bb6\u6bcf\u6237\u7684\u9632\u76d7\u95e8\u4e0a\u3002\u6839\u636e\u524d\u9762\u63d0\u5230\u7684\u9632\u706b\u5899\u7b56\u7565\u7684\u5339\u914d\u987a\u5e8f\uff0c\u53ef\u80fd\u4f1a\u5b58\u5728\u591a\u79cd\u60c5\u51b5\u3002\u6bd4\u5982\uff0c\u6765\u8bbf\u4eba\u5458\u662f\u5c0f\u5546\u5c0f\u8d29\uff0c\u5219\u76f4\u63a5\u4f1a\u88ab\u7269\u4e1a\u516c\u53f8\u7684\u4fdd\u5b89\u62d2\u4e4b\u95e8\u5916\uff0c\u4e5f\u5c31\u65e0\u9700\u518d\u5bf9\u8f66\u8f86\u8fdb\u884c\u767b\u8bb0\u3002\u5982\u679c\u6765\u8bbf\u4eba\u5458\u4e58\u5750\u4e00\u8f86\u6c7d\u8f66\u8fdb\u5165\u793e\u533a\u6b63\u95e8\uff0c\u5219\u201c\u7981\u6b62\u5c0f\u5546\u5c0f\u8d29\u8fdb\u5165\u793e\u533a\u201d\u7684\u7b2c\u4e00\u6761\u89c4\u5219\u5c31\u6ca1\u6709\u88ab\u5339\u914d\u5230\uff0c\u56e0\u6b64\u6309\u7167\u987a\u5e8f\u5339\u914d\u7b2c\u4e8c\u6761\u7b56\u7565\uff0c\u5373\u9700\u8981\u5bf9\u8f66\u8f86\u8fdb\u884c\u767b\u8bb0\u3002\u5982\u679c\u662f\u793e\u533a\u5c45\u6c11\u8981\u8fdb\u5165\u6b63\u95e8\uff0c\u5219\u8fd9\u4e24\u6761\u89c4\u5b9a\u90fd\u4e0d\u4f1a\u5339\u914d\u5230\uff0c\u56e0\u6b64\u4f1a\u6267\u884c\u9ed8\u8ba4\u7684\u653e\u884c\u7b56\u7565\u3002<\/p>\n

\u4f46\u662f\uff0c\u4ec5\u6709\u7b56\u7565\u89c4\u5219\u8fd8\u4e0d\u80fd\u4fdd\u8bc1\u793e\u533a\u7684\u5b89\u5168\uff0c\u4fdd\u5b89\u8fd8\u5e94\u8be5\u77e5\u9053\u91c7\u7528\u4ec0\u4e48\u6837\u7684\u52a8\u4f5c\u6765\u5904\u7406\u8fd9\u4e9b\u5339\u914d\u7684\u6d41\u91cf\uff0c\u6bd4\u5982\u201c\u5141\u8bb8\u201d\u3001\u201c\u62d2\u7edd\u201d\u3001\u201c\u767b\u8bb0\u201d\u3001\u201c\u4e0d\u7406\u5b83\u201d\u3002\u8fd9\u4e9b\u52a8\u4f5c\u5bf9\u5e94\u5230iptables\u670d\u52a1\u7684\u672f\u8bed\u4e2d\u5206\u522b\u662fACCEPT\uff08\u5141\u8bb8\u6d41\u91cf\u901a\u8fc7\uff09\u3001REJECT\uff08\u62d2\u7edd\u6d41\u91cf\u901a\u8fc7\uff09\u3001LOG\uff08\u8bb0\u5f55\u65e5\u5fd7\u4fe1\u606f\uff09\u3001DROP\uff08\u62d2\u7edd\u6d41\u91cf\u901a\u8fc7\uff09\u3002\u201c\u5141\u8bb8\u6d41\u91cf\u901a\u8fc7\u201d\u548c\u201c\u8bb0\u5f55\u65e5\u5fd7\u4fe1\u606f\u201d\u90fd\u6bd4\u8f83\u597d\u7406\u89e3\uff0c\u8fd9\u91cc\u9700\u8981\u7740\u91cd\u8bb2\u89e3\u7684\u662fREJECT\u548cDROP\u7684\u4e0d\u540c\u70b9\u3002\u5c31DROP\u6765\u8bf4\uff0c\u5b83\u662f\u76f4\u63a5\u5c06\u6d41\u91cf\u4e22\u5f03\u800c\u4e14\u4e0d\u54cd\u5e94\uff1bREJECT\u5219\u4f1a\u5728\u62d2\u7edd\u6d41\u91cf\u540e\u518d\u56de\u590d\u4e00\u6761\u201c\u60a8\u7684\u4fe1\u606f\u5df2\u7ecf\u6536\u5230\uff0c\u4f46\u662f\u88ab\u6254\u6389\u4e86\u201d\u4fe1\u606f\uff0c\u4ece\u800c\u8ba9\u6d41\u91cf\u53d1\u9001\u65b9\u6e05\u6670\u5730\u770b\u5230\u6570\u636e\u88ab\u62d2\u7edd\u7684\u54cd\u5e94\u4fe1\u606f\u3002<\/p>\n

\u6211\u4eec\u6765\u4e3e\u4e00\u4e2a\u4f8b\u5b50\uff0c\u8ba9\u5404\u4f4d\u8bfb\u8005\u66f4\u76f4\u89c2\u5730\u7406\u89e3\u8fd9\u4e24\u4e2a\u62d2\u7edd\u52a8\u4f5c\u7684\u4e0d\u540c\u4e4b\u5904\u3002\u6bd4\u5982\u6709\u4e00\u5929\u60a8\u6b63\u5728\u5bb6\u91cc\u770b\u7535\u89c6\uff0c\u7a81\u7136\u542c\u5230\u6709\u4eba\u6572\u95e8\uff0c\u60a8\u900f\u8fc7\u9632\u76d7\u95e8\u7684\u732b\u773c\u4e00\u770b\u662f\u63a8\u9500\u5546\u54c1\u7684\uff0c\u4fbf\u4f1a\u5728\u4e0d\u9700\u8981\u7684\u60c5\u51b5\u4e0b\u5f00\u95e8\u5e76\u62d2\u7edd\u4ed6\u4eec\uff08REJECT\uff09\u3002\u4f46\u5982\u679c\u60a8\u770b\u5230\u7684\u662f\u503a\u4e3b\u5e26\u4e86\u5341\u51e0\u4e2a\u5c0f\u5f1f\u6765\u8ba8\u503a\uff0c\u6b64\u65f6\u4e0d\u4ec5\u8981\u62d2\u7edd\u5f00\u95e8\uff0c\u8fd8\u8981\u9ed8\u4e0d\u4f5c\u58f0\uff0c\u4f2a\u88c5\u6210\u81ea\u5df1\u4e0d\u5728\u5bb6\u7684\u6837\u5b50\uff08DROP\uff09\u3002<\/p>\n

\u5f53\u628aLinux\u7cfb\u7edf\u4e2d\u7684\u9632\u706b\u5899\u7b56\u7565\u8bbe\u7f6e\u4e3aREJECT\u62d2\u7edd\u52a8\u4f5c\u540e\uff0c\u6d41\u91cf\u53d1\u9001\u65b9\u4f1a\u770b\u5230\u7aef\u53e3\u4e0d\u53ef\u8fbe\u7684\u54cd\u5e94\uff1a<\/p>\n

[root@linuxprobe ~]# ping -c 4 192.168.10.10\r\nPING 192.168.10.10 (192.168.10.10) 56(84) bytes of data.\r\nFrom 192.168.10.10 icmp_seq=1 Destination Port Unreachable\r\nFrom 192.168.10.10 icmp_seq=2 Destination Port Unreachable\r\nFrom 192.168.10.10 icmp_seq=3 Destination Port Unreachable\r\nFrom 192.168.10.10 icmp_seq=4 Destination Port Unreachable\r\n--- 192.168.10.10 ping statistics ---\r\n4 packets transmitted, 0 received, +4 errors, 100% packet loss, time 3002ms\r\n<\/pre>\n

\u800c\u628aLinux\u7cfb\u7edf\u4e2d\u7684\u9632\u706b\u5899\u7b56\u7565\u4fee\u6539\u6210DROP\u62d2\u7edd\u52a8\u4f5c\u540e\uff0c\u6d41\u91cf\u53d1\u9001\u65b9\u4f1a\u770b\u5230\u54cd\u5e94\u8d85\u65f6\u7684\u63d0\u9192\u3002\u4f46\u662f\u6d41\u91cf\u53d1\u9001\u65b9\u65e0\u6cd5\u5224\u65ad\u6d41\u91cf\u662f\u88ab\u62d2\u7edd\uff0c\u8fd8\u662f\u63a5\u6536\u65b9\u4e3b\u673a\u5f53\u524d\u4e0d\u5728\u7ebf\uff1a<\/p>\n

[root@linuxprobe ~]# ping -c 4 192.168.10.10\r\nPING 192.168.10.10 (192.168.10.10) 56(84) bytes of data.\r\n\r\n--- 192.168.10.10 ping statistics ---\r\n4 packets transmitted, 0 received, 100% packet loss, time 3000ms\r\n<\/pre>\n
8.2.2 \u57fa\u672c\u7684\u547d\u4ee4\u53c2\u6570<\/strong><\/span><\/h6>\n

iptables\u662f\u4e00\u6b3e\u57fa\u4e8e\u547d\u4ee4\u884c\u7684\u9632\u706b\u5899\u7b56\u7565\u7ba1\u7406\u5de5\u5177\uff0c\u5177\u6709\u5927\u91cf\u53c2\u6570\uff0c\u5b66\u4e60\u96be\u5ea6\u8f83\u5927\u3002\u597d\u5728\u5bf9\u4e8e\u65e5\u5e38\u7684\u9632\u706b\u5899\u7b56\u7565\u914d\u7f6e\u6765\u8bb2\uff0c\u5927\u5bb6\u65e0\u9700\u6df1\u5165\u4e86\u89e3\u8bf8\u5982\u201c\u56db\u8868\u4e94\u94fe\u201d\u7684\u7406\u8bba\u6982\u5ff5\uff0c\u53ea\u9700\u8981\u638c\u63e1\u5e38\u7528\u7684\u53c2\u6570\u5e76\u505a\u5230\u7075\u6d3b\u642d\u914d\u5373\u53ef\uff0c\u8fd9\u5c31\u8db3\u4ee5\u5e94\u5bf9\u65e5\u5e38\u5de5\u4f5c\u4e86\u3002<\/p>\n

iptables\u547d\u4ee4\u53ef\u4ee5\u6839\u636e\u6d41\u91cf\u7684\u6e90\u5730\u5740\u3001\u76ee\u7684\u5730\u5740\u3001\u4f20\u8f93\u534f\u8bae\u3001\u670d\u52a1\u7c7b\u578b\u7b49\u4fe1\u606f\u8fdb\u884c\u5339\u914d\uff0c\u4e00\u65e6\u5339\u914d\u6210\u529f\uff0ciptables\u5c31\u4f1a\u6839\u636e\u7b56\u7565\u89c4\u5219\u6240\u9884\u8bbe\u7684\u52a8\u4f5c\u6765\u5904\u7406\u8fd9\u4e9b\u6d41\u91cf\u3002\u53e6\u5916\uff0c\u518d\u6b21\u63d0\u9192\u4e00\u4e0b\uff0c\u9632\u706b\u5899\u7b56\u7565\u89c4\u5219\u7684\u5339\u914d\u987a\u5e8f\u662f\u4ece\u4e0a\u81f3\u4e0b\u7684\uff0c\u56e0\u6b64\u8981\u628a\u8f83\u4e3a\u4e25\u683c\u3001\u4f18\u5148\u7ea7\u8f83\u9ad8\u7684\u7b56\u7565\u89c4\u5219\u653e\u5230\u524d\u9762\uff0c\u4ee5\u514d\u53d1\u751f\u9519\u8bef\u3002\u88688-1\u603b\u7ed3\u5f52\u7eb3\u4e86\u5e38\u7528\u7684iptables\u547d\u4ee4\u53c2\u6570\u3002\u518d\u6b21\u5f3a\u8c03\uff0c\u6211\u4eec\u65e0\u9700\u6b7b\u8bb0\u786c\u80cc\u8fd9\u4e9b\u53c2\u6570\uff0c\u53ea\u9700\u501f\u52a9\u4e0b\u9762\u7684\u5b9e\u9a8c\u6765\u7406\u89e3\u638c\u63e1\u5373\u53ef\u3002<\/p>\n

\u88688-1\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 iptables\u4e2d\u5e38\u7528\u7684\u53c2\u6570\u4ee5\u53ca\u4f5c\u7528<\/p>\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
\u53c2\u6570<\/td>\n\u4f5c\u7528<\/td>\n<\/tr>\n
-P<\/td>\n\u8bbe\u7f6e\u9ed8\u8ba4\u7b56\u7565<\/td>\n<\/tr>\n
-F<\/td>\n\u6e05\u7a7a\u89c4\u5219\u94fe<\/td>\n<\/tr>\n
-L<\/td>\n\u67e5\u770b\u89c4\u5219\u94fe<\/td>\n<\/tr>\n
-A<\/td>\n\u5728\u89c4\u5219\u94fe\u7684\u672b\u5c3e\u6dfb\u52a0\u65b0\u89c4\u5219<\/td>\n<\/tr>\n
-I num<\/td>\n\u5728\u89c4\u5219\u94fe\u7684\u5934\u90e8\u6dfb\u52a0\u65b0\u89c4\u5219<\/td>\n<\/tr>\n
-D num<\/td>\n\u5220\u9664\u6307\u5b9a\u89c4\u5219<\/td>\n<\/tr>\n
-s<\/td>\n\u5339\u914d\u6765\u6e90\u5730\u5740\uff08IP\/MASK\uff09\uff0c\u52a0\u53f9\u53f7\u201c!\u201d\u8868\u793a\u6392\u9664\u8be5IP<\/td>\n<\/tr>\n
-d<\/td>\n\u5339\u914d\u76ee\u6807\u5730\u5740<\/td>\n<\/tr>\n
-i \u7f51\u5361\u540d\u79f0<\/td>\n\u5339\u914d\u4ece\u6307\u5b9a\u7f51\u5361\u6d41\u5165\u7684\u6570\u636e<\/td>\n<\/tr>\n
-o \u7f51\u5361\u540d\u79f0<\/td>\n\u5339\u914d\u4ece\u6307\u5b9a\u7f51\u5361\u6d41\u51fa\u7684\u6570\u636e<\/td>\n<\/tr>\n
-p<\/td>\n\u5339\u914d\u534f\u8bae\uff0c\u5982\uff1aTCP\u3001UDP\u3001ICMP<\/td>\n<\/tr>\n
--dport num<\/td>\n\u5339\u914d\u76ee\u6807\u7aef\u53e3\u53f7<\/td>\n<\/tr>\n
--sport num<\/td>\n\u5339\u914d\u6765\u6e90\u7aef\u53e3\u53f7<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

<\/p>\n

\u5728iptables\u547d\u4ee4\u540e\u6dfb\u52a0-L\u53c2\u6570\u67e5\u770b\u5df2\u6709\u7684\u9632\u706b\u5899\u89c4\u5219\u94fe\uff1a<\/strong><\/p>\n

[root@linuxprobe ~]# iptables -L\r\nChain INPUT (policy ACCEPT)\r\ntarget prot opt source destination \r\nACCEPT all -- anywhere anywhere ctstate RELATED,ESTABLISHED\r\nACCEPT all -- anywhere anywhere \r\nINPUT_direct all -- anywhere anywhere \r\nINPUT_ZONES_SOURCE all -- anywhere anywhere \r\nINPUT_ZONES all -- anywhere anywhere \r\nACCEPT icmp -- anywhere anywhere \r\nREJECT all -- anywhere anywhere reject-with icmp-host-prohibited\r\n\u2026\u2026\u2026\u2026\u2026\u2026\u7701\u7565\u90e8\u5206\u8f93\u51fa\u4fe1\u606f\u2026\u2026\u2026\u2026\u2026\u2026<\/pre>\n

\u5728iptables\u547d\u4ee4\u540e\u6dfb\u52a0-F\u53c2\u6570\u6e05\u7a7a\u5df2\u6709\u7684\u9632\u706b\u5899\u89c4\u5219\u94fe\uff1a<\/strong><\/p>\n

[root@linuxprobe ~]# iptables -F\r\n[root@linuxprobe ~]# iptables -L\r\nChain INPUT (policy ACCEPT)\r\ntarget prot opt source destination \r\n\u2026\u2026\u2026\u2026\u2026\u2026\u7701\u7565\u90e8\u5206\u8f93\u51fa\u4fe1\u606f\u2026\u2026\u2026\u2026\u2026\u2026<\/pre>\n

\u628aINPUT\u89c4\u5219\u94fe\u7684\u9ed8\u8ba4\u7b56\u7565\u8bbe\u7f6e\u4e3a\u62d2\u7edd\uff1a<\/strong><\/p>\n

[root@linuxprobe ~]# iptables -P INPUT DROP\r\n[root@linuxprobe\u00a0~]# iptables -L\r\nChain INPUT (policy DROP<\/strong>)\r\ntarget prot opt source destination \r\n\u2026\u2026\u2026\u2026\u7701\u7565\u90e8\u5206\u8f93\u51fa\u4fe1\u606f\u2026\u2026\u2026\u2026\u2026\u2026<\/pre>\n

\u5982\u524d\u9762\u6240\u63d0\u5230\u7684\u9632\u706b\u5899\u7b56\u7565\u8bbe\u7f6e\u65e0\u975e\u6709\u4e24\u79cd\u65b9\u5f0f\uff0c\u4e00\u79cd\u662f\u201c\u901a\u201d\uff0c\u4e00\u79cd\u662f\u201c\u5835\u201d\uff0c\u5f53\u628aINPUT\u94fe\u8bbe\u7f6e\u4e3a\u9ed8\u8ba4\u62d2\u7edd\u540e\uff0c\u5c31\u8981\u5f80\u91cc\u9762\u5199\u5165\u5141\u8bb8\u7b56\u7565\u4e86\uff0c\u5426\u5219\u6240\u6709\u6d41\u5165\u7684\u6570\u636e\u5305\u90fd\u4f1a\u88ab\u9ed8\u8ba4\u62d2\u7edd\u6389\uff0c\u540c\u5b66\u4eec\u9700\u8981\u7559\u610f\u89c4\u5219\u94fe\u7684\u9ed8\u8ba4\u7b56\u7565\u62d2\u7edd\u52a8\u4f5c\u53ea\u80fd\u662fDROP\uff0c\u800c\u4e0d\u80fd\u662fREJECT\u3002<\/p>\n

\u5411INPUT\u94fe\u4e2d\u6dfb\u52a0\u5141\u8bb8ICMP\u6d41\u91cf\u8fdb\u5165\u7684\u7b56\u7565\u89c4\u5219\uff1a<\/strong><\/p>\n

\u5728\u65e5\u5e38\u8fd0\u7ef4\u5de5\u4f5c\u4e2d\uff0c\u7ecf\u5e38\u4f1a\u4f7f\u7528ping\u547d\u4ee4\u6765\u68c0\u67e5\u5bf9\u65b9\u4e3b\u673a\u662f\u5426\u5728\u7ebf\uff0c\u800c\u5411\u9632\u706b\u5899\u7684INPUT\u89c4\u5219\u94fe\u4e2d\u6dfb\u52a0\u4e00\u6761\u5141\u8bb8ICMP\u6d41\u91cf\u8fdb\u5165\u7684\u7b56\u7565\u89c4\u5219\u5c31\u9ed8\u8ba4\u5141\u8bb8\u4e86\u8fd9\u79cdping\u547d\u4ee4\u68c0\u6d4b\u884c\u4e3a\u3002<\/p>\n

[root@linuxprobe\u00a0~]#\u00a0iptables\u00a0-I\u00a0INPUT\u00a0-p\u00a0icmp\u00a0-j\u00a0ACCEPT\r\n[root@linuxprobe\u00a0~]#\u00a0ping\u00a0-c\u00a04\u00a0192.168.10.10\r\nPING\u00a0192.168.10.10\u00a0(192.168.10.10)\u00a056(84)\u00a0bytes\u00a0of\u00a0data.\r\n64\u00a0bytes\u00a0from\u00a0192.168.10.10:\u00a0icmp_seq=1\u00a0ttl=64\u00a0time=0.156\u00a0ms\r\n64\u00a0bytes\u00a0from\u00a0192.168.10.10:\u00a0icmp_seq=2\u00a0ttl=64\u00a0time=0.117\u00a0ms\r\n64\u00a0bytes\u00a0from\u00a0192.168.10.10:\u00a0icmp_seq=3\u00a0ttl=64\u00a0time=0.099\u00a0ms\r\n64\u00a0bytes\u00a0from\u00a0192.168.10.10:\u00a0icmp_seq=4\u00a0ttl=64\u00a0time=0.090\u00a0ms\r\n---\u00a0192.168.10.10\u00a0ping\u00a0statistics\u00a0---\r\n4\u00a0packets\u00a0transmitted,\u00a04\u00a0received,\u00a00%\u00a0packet\u00a0loss,\u00a0time\u00a02999ms\r\nrtt\u00a0min\/avg\/max\/mdev\u00a0=\u00a00.090\/0.115\/0.156\/0.027\u00a0ms<\/pre>\n

\u5220\u9664INPUT\u89c4\u5219\u94fe\u4e2d\u521a\u521a\u52a0\u5165\u7684\u90a3\u6761\u7b56\u7565\uff08\u5141\u8bb8ICMP\u6d41\u91cf\uff09\uff0c\u5e76\u628a\u9ed8\u8ba4\u7b56\u7565\u8bbe\u7f6e\u4e3a\u5141\u8bb8\uff1a<\/strong><\/p>\n

[root@linuxprobe ~]# iptables -D INPUT 1\r\n[root@linuxprobe ~]# iptables -P INPUT ACCEPT\r\n[root@linuxprobe ~]# iptables -L\r\nChain INPUT (policy ACCEPT<\/strong>)\r\ntarget prot opt source destination\r\n\u2026\u2026\u2026\u2026\u2026\u2026\u7701\u7565\u90e8\u5206\u8f93\u51fa\u4fe1\u606f\u2026\u2026\u2026\u2026\u2026\u2026<\/pre>\n

\u5c06INPUT\u89c4\u5219\u94fe\u8bbe\u7f6e\u4e3a\u53ea\u5141\u8bb8\u6307\u5b9a\u7f51\u6bb5\u7684\u4e3b\u673a\u8bbf\u95ee\u672c\u673a\u768422\u7aef\u53e3\uff0c\u62d2\u7edd\u6765\u81ea\u5176\u4ed6\u6240\u6709\u4e3b\u673a\u7684\u6d41\u91cf<\/strong>\uff1a<\/p>\n

[root@linuxprobe ~]# iptables -I INPUT -s 192.168.10.0\/24 -p tcp --dport 22 -j ACCEPT\r\n[root@linuxprobe ~]# iptables -A INPUT -p tcp --dport 22 -j REJECT\r\n[root@linuxprobe\u00a0~]# iptables -L\r\nChain INPUT (policy ACCEPT)\r\ntarget prot opt source destination \r\nACCEPT tcp -- 192.168.10.0\/24 anywhere tcp dpt:ssh\r\nREJECT tcp -- anywhere anywhere tcp dpt:ssh reject-with icmp-port-unreachable\r\n\u2026\u2026\u2026\u2026\u2026\u2026\u7701\u7565\u90e8\u5206\u8f93\u51fa\u4fe1\u606f\u2026\u2026\u2026\u2026\u2026\u2026<\/pre>\n

\u518d\u6b21\u91cd\u7533\uff0c\u9632\u706b\u5899\u7b56\u7565\u89c4\u5219\u662f\u6309\u7167\u4ece\u4e0a\u5230\u4e0b\u7684\u987a\u5e8f\u5339\u914d\u7684\uff0c\u56e0\u6b64\u4e00\u5b9a\u8981\u628a\u5141\u8bb8\u52a8\u4f5c\u653e\u5230\u62d2\u7edd\u52a8\u4f5c\u524d\u9762\uff0c\u5426\u5219\u6240\u6709\u7684\u6d41\u91cf\u5c31\u5c06\u88ab\u62d2\u7edd\u6389\uff0c\u4ece\u800c\u5bfc\u81f4\u4efb\u4f55\u4e3b\u673a\u90fd\u65e0\u6cd5\u8bbf\u95ee\u6211\u4eec\u7684\u670d\u52a1\u3002\u53e6\u5916\uff0c\u8fd9\u91cc\u63d0\u5230\u768422\u53f7\u7aef\u53e3\u662fssh\u670d\u52a1\u4f7f\u7528\u7684\uff08\u6709\u5173ssh\u670d\u52a1\uff0c\u8bf7\u89c1\u4e0b\u4e00\u7ae0\uff09\uff0c\u5218\u9044\u8001\u5e08\u5148\u5728\u8fd9\u91cc\u6316\u5751\uff0c\u7b49\u5927\u5bb6\u5b66\u5b8c\u7b2c9\u7ae0\u540e\u53ef\u518d\u9a8c\u8bc1\u8fd9\u4e2a\u5b9e\u9a8c\u7684\u6548\u679c\u3002<\/p>\n

\u5728\u8bbe\u7f6e\u5b8c\u4e0a\u8ff0INPUT\u89c4\u5219\u94fe\u4e4b\u540e\uff0c\u6211\u4eec\u4f7f\u7528IP\u5730\u5740\u5728192.168.10.0\/24\u7f51\u6bb5\u5185\u7684\u4e3b\u673a\u8bbf\u95ee\u670d\u52a1\u5668\uff08\u5373\u524d\u9762\u63d0\u5230\u7684\u8bbe\u7f6e\u4e86INPUT\u89c4\u5219\u94fe\u7684\u4e3b\u673a\uff09\u768422\u7aef\u53e3\uff0c\u6548\u679c\u5982\u4e0b\uff1a<\/p>\n

[root@Client A ~]# ssh 192.168.10.10\r\nThe authenticity of host '192.168.10.10 (192.168.10.10)' can't be established.\r\nECDSA key fingerprint is 70:3b:5d:37:96:7b:2e:a5:28:0d:7e:dc:47:6a:fe:5c.\r\nAre you sure you want to continue connecting (yes\/no)? yes\r\nWarning: Permanently added '192.168.10.10' (ECDSA) to the list of known hosts.\r\nroot@192.168.10.10's password: \r\nLast login: Sun Feb 12 01:50:25 2017\r\n[root@Client A ~]#<\/pre>\n

\u7136\u540e\uff0c\u6211\u4eec\u518d\u4f7f\u7528IP\u5730\u5740\u5728192.168.20.0\/24\u7f51\u6bb5\u5185\u7684\u4e3b\u673a\u8bbf\u95ee\u670d\u52a1\u5668\u768422\u7aef\u53e3\uff08\u867d\u7f51\u6bb5\u4e0d\u540c\uff0c\u4f46\u5df2\u786e\u8ba4\u53ef\u4ee5\u76f8\u4e92\u901a\u4fe1\uff09\uff0c\u6548\u679c\u5982\u4e0b\uff0c\u5c31\u4f1a\u63d0\u793a\u8fde\u63a5\u8bf7\u6c42\u88ab\u62d2\u7edd\u4e86\uff08Connection\u00a0failed\uff09\uff1a<\/p>\n

[root@Client B ~]# ssh 192.168.10.10\r\nConnecting to 192.168.10.10:22...\r\nCould not connect to '192.168.10.10' (port 22): Connection failed.<\/pre>\n

\u5411INPUT\u89c4\u5219\u94fe\u4e2d\u6dfb\u52a0\u62d2\u7edd\u6240\u6709\u4eba\u8bbf\u95ee\u672c\u673a12345\u7aef\u53e3\u7684\u7b56\u7565\u89c4\u5219<\/strong>\uff1a<\/p>\n

[root@linuxprobe ~]# iptables -I INPUT -p tcp --dport 12345 -j REJECT\r\n[root@linuxprobe ~]# iptables -I INPUT -p udp --dport 12345 -j REJECT\r\n[root@linuxprobe ~]# iptables -L\r\nChain INPUT (policy ACCEPT)\r\ntarget prot opt source destination \r\nREJECT udp -- anywhere anywhere udp dpt:italk reject-with icmp-port-unreachable\r\nREJECT tcp -- anywhere anywhere tcp dpt:italk reject-with icmp-port-unreachable\r\nACCEPT tcp -- 192.168.10.0\/24 anywhere tcp dpt:ssh\r\nREJECT tcp -- anywhere anywhere tcp dpt:ssh reject-with icmp-port-unreachable\r\n\u2026\u2026\u2026\u2026\u2026\u2026\u7701\u7565\u90e8\u5206\u8f93\u51fa\u4fe1\u606f\u2026\u2026\u2026\u2026\u2026\u2026<\/pre>\n

\u5411INPUT\u89c4\u5219\u94fe\u4e2d\u6dfb\u52a0\u62d2\u7edd192.168.10.5\u4e3b\u673a\u8bbf\u95ee\u672c\u673a80\u7aef\u53e3\uff08Web\u670d\u52a1\uff09\u7684\u7b56\u7565\u89c4\u5219<\/strong>\uff1a<\/p>\n

[root@linuxprobe ~]# iptables -I INPUT -p tcp -s 192.168.10.5 --dport 80 -j REJECT\r\n[root@linuxprobe ~]# iptables -L\r\nChain INPUT (policy ACCEPT)\r\ntarget prot opt source destination \r\nREJECT tcp -- 192.168.10.5 anywhere tcp dpt:http reject-with icmp-port-unreachable\r\nREJECT udp -- anywhere anywhere udp dpt:italk reject-with icmp-port-unreachable\r\nREJECT tcp -- anywhere anywhere tcp dpt:italk reject-with icmp-port-unreachable\r\nACCEPT tcp -- 192.168.10.0\/24 anywhere tcp dpt:ssh\r\nREJECT tcp -- anywhere anywhere tcp dpt:ssh reject-with icmp-port-unreachable\r\n\u2026\u2026\u2026\u2026\u2026\u2026\u7701\u7565\u90e8\u5206\u8f93\u51fa\u4fe1\u606f\u2026\u2026\u2026\u2026\u2026\u2026<\/pre>\n

\u5411INPUT\u89c4\u5219\u94fe\u4e2d\u6dfb\u52a0\u62d2\u7edd\u6240\u6709\u4e3b\u673a\u8bbf\u95ee\u672c\u673a1000<\/strong>\uff5e<\/strong>1024<\/strong>\u7aef\u53e3\u7684\u7b56\u7565\u89c4\u5219<\/strong>\uff1a<\/p>\n

[root@linuxprobe ~]# iptables -A INPUT -p tcp --dport 1000:1024 -j REJECT\r\n[root@linuxprobe ~]# iptables -A INPUT -p udp --dport 1000:1024 -j REJECT\r\n[root@linuxprobe ~]# iptables -L\r\nChain INPUT (policy ACCEPT)\r\ntarget prot opt source destination \r\nREJECT tcp -- 192.168.10.5 anywhere tcp dpt:http reject-with icmp-port-unreachable\r\nREJECT udp -- anywhere anywhere udp dpt:italk reject-with icmp-port-unreachable\r\nREJECT tcp -- anywhere anywhere tcp dpt:italk reject-with icmp-port-unreachable\r\nACCEPT tcp -- 192.168.10.0\/24 anywhere tcp dpt:ssh\r\nREJECT tcp -- anywhere anywhere tcp dpt:ssh reject-with icmp-port-unreachable\r\nREJECT tcp -- anywhere anywhere tcp dpts:cadlock2:1024 reject-with icmp-port-unreachable\r\nREJECT udp -- anywhere anywhere udp dpts:cadlock2:1024 reject-with icmp-port-unreachable\r\n\u2026\u2026\u2026\u2026\u2026\u2026\u7701\u7565\u90e8\u5206\u8f93\u51fa\u4fe1\u606f\u2026\u2026\u2026\u2026\u2026\u2026<\/pre>\n

\u6709\u5173iptables\u547d\u4ee4\u7684\u77e5\u8bc6\u8bb2\u89e3\u5230\u6b64\u5c31\u7ed3\u675f\u4e86\uff0c\u5927\u5bb6\u662f\u4e0d\u662f\u610f\u72b9\u672a\u5c3d\uff1f\u8003\u8651\u5230Linux\u9632\u706b\u5899\u7684\u53d1\u5c55\u8d8b\u52bf\uff0c\u5927\u5bb6\u53ea\u8981\u80fd\u628a\u4e0a\u9762\u7684\u5b9e\u4f8b\u5438\u6536\u6d88\u5316\uff0c\u5c31\u53ef\u4ee5\u5b8c\u5168\u641e\u5b9a\u65e5\u5e38\u7684iptables\u914d\u7f6e\u5de5\u4f5c\u4e86\u3002\u4f46\u662f\u8bf7\u7279\u522b\u6ce8\u610f\uff0c\u4f7f\u7528iptables\u547d\u4ee4\u914d\u7f6e\u7684\u9632\u706b\u5899\u89c4\u5219\u9ed8\u8ba4\u4f1a\u5728\u7cfb\u7edf\u4e0b\u4e00\u6b21\u91cd\u542f\u65f6\u5931\u6548\uff0c\u5982\u679c\u60f3\u8ba9\u914d\u7f6e\u7684\u9632\u706b\u5899\u7b56\u7565\u6c38\u4e45\u751f\u6548\uff0c\u8fd8\u8981\u6267\u884c\u4fdd\u5b58\u547d\u4ee4\uff1a<\/p>\n

[root@linuxprobe ~]# service iptables save\r\niptables: Saving firewall rules to \/etc\/sysconfig\/iptables: [ OK ]<\/strong><\/pre>\n

\u51fa\u73b0\u95ee\u9898?\u5927\u80c6\u63d0\u95ee!<\/strong><\/span><\/p>\n

\u56e0\u8bfb\u8005\u4eec\u786c\u4ef6\u4e0d\u540c\u6216\u64cd\u4f5c\u9519\u8bef\u90fd\u53ef\u80fd\u5bfc\u81f4\u5b9e\u9a8c\u914d\u7f6e\u51fa\u9519\uff0c\u8bf7\u8010\u5fc3\u518d\u4ed4\u7ec6\u770b\u770b\u64cd\u4f5c\u6b65\u9aa4\u5427\uff0c\u4e0d\u8981\u6c14\u9981~<\/p>\n

Linux\u6280\u672f\u4ea4\u6d41\u8bf7\u52a0A\u7fa4\uff1a560843(\u6ee1<\/span><\/strong>)\uff0cB\u7fa4\uff1a340829(\u63a8\u8350<\/span><\/strong>)\uff0cC\u7fa4\uff1a463590\uff08\u63a8\u8350<\/span><\/strong>\uff09\uff0c\u70b9\u6b64\u67e5\u770b\u5168\u56fd\u7fa4<\/a>\u3002<\/p>\n

*\u672c\u7fa4\u7279\u8272\uff1a\u901a\u8fc7\u53e3\u4ee4\u9a8c\u8bc1\u786e\u4fdd\u6bcf\u4e00\u4e2a\u7fa4\u5458\u90fd\u662f\u300aLinux\u5c31\u8be5\u8fd9\u4e48\u5b66\u300b\u7684\u8bfb\u8005\uff0c\u7b54\u7591\u66f4\u6709\u9488\u5bf9\u6027\uff0c\u4e0d\u5b9a\u671f\u514d\u8d39\u9886\u53d6\u5b9a\u5236\u793c\u54c1\u3002<\/p><\/blockquote>\n

8.3 Firewalld<\/span><\/strong><\/h5>\n

RHEL 7\u7cfb\u7edf\u4e2d\u96c6\u6210\u4e86\u591a\u6b3e\u9632\u706b\u5899\u7ba1\u7406\u5de5\u5177\uff0c\u5176\u4e2dfirewalld\uff08Dynamic Firewall Manager of Linux systems\uff0cLinux\u7cfb\u7edf\u7684\u52a8\u6001\u9632\u706b\u5899\u7ba1\u7406\u5668\uff09\u670d\u52a1\u662f\u9ed8\u8ba4\u7684\u9632\u706b\u5899\u914d\u7f6e\u7ba1\u7406\u5de5\u5177\uff0c\u5b83\u62e5\u6709\u57fa\u4e8eCLI\uff08\u547d\u4ee4\u884c\u754c\u9762\uff09\u548c\u57fa\u4e8eGUI\uff08\u56fe\u5f62\u7528\u6237\u754c\u9762\uff09\u7684\u4e24\u79cd\u7ba1\u7406\u65b9\u5f0f\u3002<\/p>\n

\u76f8\u8f83\u4e8e\u4f20\u7edf\u7684\u9632\u706b\u5899\u7ba1\u7406\u914d\u7f6e\u5de5\u5177\uff0cfirewalld\u652f\u6301\u52a8\u6001\u66f4\u65b0\u6280\u672f\u5e76\u52a0\u5165\u4e86\u533a\u57df\uff08zone\uff09\u7684\u6982\u5ff5\u3002\u7b80\u5355\u6765\u8bf4\uff0c\u533a\u57df\u5c31\u662ffirewalld\u9884\u5148\u51c6\u5907\u4e86\u51e0\u5957\u9632\u706b\u5899\u7b56\u7565\u96c6\u5408\uff08\u7b56\u7565\u6a21\u677f\uff09\uff0c\u7528\u6237\u53ef\u4ee5\u6839\u636e\u751f\u4ea7\u573a\u666f\u7684\u4e0d\u540c\u800c\u9009\u62e9\u5408\u9002\u7684\u7b56\u7565\u96c6\u5408\uff0c\u4ece\u800c\u5b9e\u73b0\u9632\u706b\u5899\u7b56\u7565\u4e4b\u95f4\u7684\u5feb\u901f\u5207\u6362\u3002\u4f8b\u5982\uff0c\u6211\u4eec\u6709\u4e00\u53f0\u7b14\u8bb0\u672c\u7535\u8111\uff0c\u6bcf\u5929\u90fd\u8981\u5728\u529e\u516c\u5ba4\u3001\u5496\u5561\u5385\u548c\u5bb6\u91cc\u4f7f\u7528\u3002\u6309\u5e38\u7406\u6765\u8bb2\uff0c\u8fd9\u4e09\u8005\u7684\u5b89\u5168\u6027\u6309\u7167\u7531\u9ad8\u5230\u4f4e\u7684\u987a\u5e8f\u6765\u6392\u5217\uff0c\u5e94\u8be5\u662f\u5bb6\u5ead\u3001\u516c\u53f8\u529e\u516c\u5ba4\u3001\u5496\u5561\u5385\u3002\u5f53\u524d\uff0c\u6211\u4eec\u5e0c\u671b\u4e3a\u8fd9\u53f0\u7b14\u8bb0\u672c\u7535\u8111\u6307\u5b9a\u5982\u4e0b\u9632\u706b\u5899\u7b56\u7565\u89c4\u5219\uff1a\u5728\u5bb6\u4e2d\u5141\u8bb8\u8bbf\u95ee\u6240\u6709\u670d\u52a1\uff1b\u5728\u529e\u516c\u5ba4\u5185\u4ec5\u5141\u8bb8\u8bbf\u95ee\u6587\u4ef6\u5171\u4eab\u670d\u52a1\uff1b\u5728\u5496\u5561\u5385\u4ec5\u5141\u8bb8\u4e0a\u7f51\u6d4f\u89c8\u3002\u5728\u4ee5\u5f80\uff0c\u6211\u4eec\u9700\u8981\u9891\u7e41\u5730\u624b\u52a8\u8bbe\u7f6e\u9632\u706b\u5899\u7b56\u7565\u89c4\u5219\uff0c\u800c\u73b0\u5728\u53ea\u9700\u8981\u9884\u8bbe\u597d\u533a\u57df\u96c6\u5408\uff0c\u7136\u540e\u53ea\u9700\u8f7b\u70b9\u9f20\u6807\u5c31\u53ef\u4ee5\u81ea\u52a8\u5207\u6362\u4e86\uff0c\u4ece\u800c\u6781\u5927\u5730\u63d0\u5347\u4e86\u9632\u706b\u5899\u7b56\u7565\u7684\u5e94\u7528\u6548\u7387\u3002firewalld\u4e2d\u5e38\u89c1\u7684\u533a\u57df\u540d\u79f0\uff08\u9ed8\u8ba4\u4e3apublic\uff09\u4ee5\u53ca\u76f8\u5e94\u7684\u7b56\u7565\u89c4\u5219\u5982\u88688-2\u6240\u793a\u3002<\/p>\n

\u88688-2\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 firewalld\u4e2d\u5e38\u7528\u7684\u533a\u57df\u540d\u79f0\u53ca\u7b56\u7565\u89c4\u5219<\/p>\n\n\n\n\n\n\n\n\n\n\n\n\n
\u533a\u57df<\/td>\n\u9ed8\u8ba4\u89c4\u5219\u7b56\u7565<\/td>\n<\/tr>\n
trusted<\/td>\n\u5141\u8bb8\u6240\u6709\u7684\u6570\u636e\u5305<\/td>\n<\/tr>\n
home<\/td>\n\u62d2\u7edd\u6d41\u5165\u7684\u6d41\u91cf\uff0c\u9664\u975e\u4e0e\u6d41\u51fa\u7684\u6d41\u91cf\u76f8\u5173\uff1b\u800c\u5982\u679c\u6d41\u91cf\u4e0essh\u3001mdns\u3001ipp-client\u3001amba-client\u4e0edhcpv6-client\u670d\u52a1\u76f8\u5173\uff0c\u5219\u5141\u8bb8\u6d41\u91cf<\/td>\n<\/tr>\n
internal<\/td>\n\u7b49\u540c\u4e8ehome\u533a\u57df<\/td>\n<\/tr>\n
work<\/td>\n\u62d2\u7edd\u6d41\u5165\u7684\u6d41\u91cf\uff0c\u9664\u975e\u4e0e\u6d41\u51fa\u7684\u6d41\u91cf\u76f8\u5173\uff1b\u800c\u5982\u679c\u6d41\u91cf\u4e0essh\u3001ipp-client\u4e0edhcpv6-client\u670d\u52a1\u76f8\u5173\uff0c\u5219\u5141\u8bb8\u6d41\u91cf<\/td>\n<\/tr>\n
public<\/td>\n\u62d2\u7edd\u6d41\u5165\u7684\u6d41\u91cf\uff0c\u9664\u975e\u4e0e\u6d41\u51fa\u7684\u6d41\u91cf\u76f8\u5173\uff1b\u800c\u5982\u679c\u6d41\u91cf\u4e0essh\u3001dhcpv6-client\u670d\u52a1\u76f8\u5173\uff0c\u5219\u5141\u8bb8\u6d41\u91cf<\/td>\n<\/tr>\n
external<\/td>\n\u62d2\u7edd\u6d41\u5165\u7684\u6d41\u91cf\uff0c\u9664\u975e\u4e0e\u6d41\u51fa\u7684\u6d41\u91cf\u76f8\u5173\uff1b\u800c\u5982\u679c\u6d41\u91cf\u4e0essh\u670d\u52a1\u76f8\u5173\uff0c\u5219\u5141\u8bb8\u6d41\u91cf<\/td>\n<\/tr>\n
dmz<\/td>\n\u62d2\u7edd\u6d41\u5165\u7684\u6d41\u91cf\uff0c\u9664\u975e\u4e0e\u6d41\u51fa\u7684\u6d41\u91cf\u76f8\u5173\uff1b\u800c\u5982\u679c\u6d41\u91cf\u4e0essh\u670d\u52a1\u76f8\u5173\uff0c\u5219\u5141\u8bb8\u6d41\u91cf<\/td>\n<\/tr>\n
block<\/td>\n\u62d2\u7edd\u6d41\u5165\u7684\u6d41\u91cf\uff0c\u9664\u975e\u4e0e\u6d41\u51fa\u7684\u6d41\u91cf\u76f8\u5173<\/td>\n<\/tr>\n
drop<\/td>\n\u62d2\u7edd\u6d41\u5165\u7684\u6d41\u91cf\uff0c\u9664\u975e\u4e0e\u6d41\u51fa\u7684\u6d41\u91cf\u76f8\u5173<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

<\/p>\n

8.3.1 \u7ec8\u7aef\u7ba1\u7406\u5de5\u5177<\/strong><\/span><\/h6>\n

\u7b2c2\u7ae0\u5728\u8bb2\u89e3Linux\u547d\u4ee4<\/a>\u65f6\u66fe\u7ecf\u542c\u5230\uff0c\u547d\u4ee4\u884c\u7ec8\u7aef\u662f\u4e00\u79cd\u6781\u5bcc\u6548\u7387\u7684\u5de5\u4f5c\u65b9\u5f0f\uff0cfirewall-cmd\u662ffirewalld\u9632\u706b\u5899\u914d\u7f6e\u7ba1\u7406\u5de5\u5177\u7684CLI\uff08\u547d\u4ee4\u884c\u754c\u9762\uff09\u7248\u672c\u3002\u5b83\u7684\u53c2\u6570\u4e00\u822c\u90fd\u662f\u4ee5\u201c\u957f\u683c\u5f0f\u201d\u6765\u63d0\u4f9b\u7684\uff0c\u5927\u5bb6\u4e0d\u8981\u4e00\u542c\u5230\u957f\u683c\u5f0f\u5c31\u5934\u5927\uff0c\u56e0\u4e3aRHEL 7\u7cfb\u7edf\u652f\u6301\u90e8\u5206\u547d\u4ee4\u7684\u53c2\u6570\u8865\u9f50\uff0c\u5176\u4e2d\u5c31\u5305\u542b\u8fd9\u6761\u547d\u4ee4\uff08\u5f88\u9177\u5427\uff09\u3002\u4e5f\u5c31\u662f\u8bf4\uff0c\u73b0\u5728\u9664\u4e86\u80fd\u7528Tab\u952e\u81ea\u52a8\u8865\u9f50\u547d\u4ee4\u6216\u6587\u4ef6\u540d\u7b49\u5185\u5bb9\u4e4b\u5916\uff0c\u8fd8\u53ef\u4ee5\u7528Tab\u952e\u6765\u8865\u9f50\u88688-3\u4e2d\u6240\u793a\u7684\u957f\u683c\u5f0f\u53c2\u6570\u4e86\uff08\u8fd9\u592a\u68d2\u4e86\uff09\u3002<\/p>\n

\u88688-3\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 firewall-cmd\u547d\u4ee4\u4e2d\u4f7f\u7528\u7684\u53c2\u6570\u4ee5\u53ca\u4f5c\u7528<\/p>\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
\u53c2\u6570<\/td>\n\u4f5c\u7528<\/td>\n<\/tr>\n
--get-zones<\/td>\n\u663e\u793a\u6240\u6709\u53ef\u7528\u7684\u533a\u57df<\/td>\n<\/tr>\n
--get-services<\/td>\n\u663e\u793a\u6240\u6709\u9884\u5148\u5b9a\u4e49\u7684\u670d\u52a1<\/td>\n<\/tr>\n
--get-active-zones<\/td>\n\u663e\u793a\u5f53\u524d\u6b63\u5728\u4f7f\u7528\u7684\u533a\u57df\u53ca\u5176\u5bf9\u5e94\u7684\u7f51\u5361\u540d\u79f0<\/td>\n<\/tr>\n
--get-default-zone<\/td>\n\u67e5\u8be2\u9ed8\u8ba4\u7684\u533a\u57df\u540d\u79f0<\/td>\n<\/tr>\n
--set-default-zone=<\u533a\u57df\u540d\u79f0><\/td>\n\u8bbe\u7f6e\u9ed8\u8ba4\u7684\u533a\u57df\uff0c\u5e76\u4f7f\u5176\u6c38\u4e45\u751f\u6548<\/td>\n<\/tr>\n
--add-source=<\/td>\n\u5c06\u6e90\u81ea\u6307\u5b9aIP\u6216\u5b50\u7f51\u7684\u6d41\u91cf\u5bfc\u5411\u6307\u5b9a\u7684\u533a\u57df<\/td>\n<\/tr>\n
--remove-source=<\/td>\n\u53d6\u6d88\u5c06\u6e90\u81ea\u6307\u5b9aIP\u6216\u5b50\u7f51\u7684\u6d41\u91cf\u5bfc\u5411\u67d0\u4e2a\u533a\u57df<\/td>\n<\/tr>\n
--add-interface=<\u7f51\u5361\u540d\u79f0><\/td>\n\u5c06\u6e90\u81ea\u6307\u5b9a\u7f51\u5361\u7684\u6240\u6709\u6d41\u91cf\u5bfc\u5411\u6307\u5b9a\u7684\u533a\u57df<\/td>\n<\/tr>\n
--change-interface=<\u7f51\u5361\u540d\u79f0><\/td>\n\u5c06\u6307\u5b9a\u7f51\u5361\u4e0e\u6307\u5b9a\u533a\u57df\u8fdb\u884c\u5173\u8054<\/td>\n<\/tr>\n
--list-services<\/td>\n\u5217\u51fa\u5f53\u524d\u533a\u57df\u5141\u8bb8\u7684\u670d\u52a1<\/td>\n<\/tr>\n
--list-ports<\/td>\n\u5217\u51fa\u5f53\u524d\u533a\u57df\u5141\u8bb8\u7684\u7aef\u53e3<\/td>\n<\/tr>\n
--list-all<\/td>\n\u663e\u793a\u5f53\u524d\u533a\u57df\u7684\u6240\u6709\u914d\u7f6e\u53c2\u6570\u3001\u8d44\u6e90\u3001\u7aef\u53e3\u53ca\u670d\u52a1\u4fe1\u606f<\/td>\n<\/tr>\n
--list-all-zones<\/td>\n\u663e\u793a\u6240\u6709\u533a\u57df\u7684\u914d\u7f6e\u53c2\u6570\u3001\u8d44\u6e90\u3001\u7aef\u53e3\u53ca\u670d\u52a1\u4fe1\u606f<\/td>\n<\/tr>\n
--add-service=<\u670d\u52a1\u540d><\/td>\n\u5141\u8bb8\u9ed8\u8ba4\u533a\u57df\u7684\u6307\u5b9a\u670d\u52a1\u6d41\u91cf<\/td>\n<\/tr>\n
--remove-service=<\u670d\u52a1\u540d><\/td>\n\u7981\u6b62\u9ed8\u8ba4\u533a\u57df\u7684\u6307\u5b9a\u670d\u52a1\u6d41\u91cf<\/td>\n<\/tr>\n
--add-port=<\u7aef\u53e3\u53f7\/\u534f\u8bae><\/td>\n\u5141\u8bb8\u9ed8\u8ba4\u533a\u57df\u7684\u6307\u5b9a\u7aef\u53e3\u6d41\u91cf<\/td>\n<\/tr>\n
--remove-port=<\u7aef\u53e3\u53f7\/\u534f\u8bae><\/td>\n\u7981\u6b62\u9ed8\u8ba4\u533a\u57df\u7684\u6307\u5b9a\u7aef\u53e3\u6d41\u91cf<\/td>\n<\/tr>\n
--query-service=<\u670d\u52a1\u540d><\/td>\n\u67e5\u8be2\u6307\u5b9a\u670d\u52a1\u662f\u5426\u88ab\u5141\u8bb8<\/td>\n<\/tr>\n
--query-port=<\u7aef\u53e3\u53f7\/\u534f\u8bae><\/td>\n\u67e5\u8be2\u6307\u5b9a\u7aef\u53e3\u662f\u5426\u88ab\u5141\u8bb8<\/td>\n<\/tr>\n
--add-rich-rule='<\u89c4\u5219>'<\/td>\n\u6dfb\u52a0\u4e00\u6761\u590d\u6742\u7684\u89c4\u5219<\/td>\n<\/tr>\n
--remove-rich-rule='<\u89c4\u5219>'<\/td>\n\u5220\u9664\u4e00\u6761\u590d\u6742\u7684\u89c4\u5219<\/td>\n<\/tr>\n
--reload<\/td>\n\u91cd\u65b0\u52a0\u8f7d\u914d\u7f6e\uff0c\u8ba9\u6c38\u4e45\u751f\u6548\u7684\u89c4\u5219\u7acb\u5373\u751f\u6548\uff0c\u8986\u76d6\u5f53\u524d\u914d\u7f6e<\/td>\n<\/tr>\n
--panic-on<\/td>\n\u5f00\u542f\u5e94\u6025\u6a21\u5f0f\uff0c\u62d2\u7edd\u6240\u6709\u6d41\u91cf<\/td>\n<\/tr>\n
--panic-off<\/td>\n\u5173\u95ed\u5e94\u6025\u6a21\u5f0f\uff0c\u6062\u590d\u6b63\u5e38\u6d41\u91cf\u5904\u7406<\/td>\n<\/tr>\n
--permanent<\/td>\n\u5c06\u89c4\u5219\u8bbe\u7f6e\u4e3a\u6c38\u4e45\u751f\u6548\uff08\u91cd\u542f\u540e\u4f9d\u7136\u6709\u6548\uff09<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

<\/p>\n

\u4e0eLinux\u7cfb\u7edf\u4e2d\u5176\u4ed6\u7684\u9632\u706b\u5899\u7b56\u7565\u914d\u7f6e\u5de5\u5177\u4e00\u6837\uff0c\u4f7f\u7528firewalld\u914d\u7f6e\u7684\u9632\u706b\u5899\u7b56\u7565\u9ed8\u8ba4\u4e3a\u8fd0\u884c\u65f6\uff08Runtime\uff09\u6a21\u5f0f\uff0c\u53c8\u79f0\u4e3a\u5f53\u524d\u751f\u6548\u6a21\u5f0f\uff0c\u800c\u4e14\u968f\u7740\u7cfb\u7edf\u7684\u91cd\u542f\u4f1a\u5931\u6548\u3002\u5982\u679c\u60f3\u8ba9\u914d\u7f6e\u7b56\u7565\u4e00\u76f4\u5b58\u5728\uff0c\u5c31\u9700\u8981\u4f7f\u7528\u6c38\u4e45\uff08Permanent\uff09\u6a21\u5f0f\u4e86\uff0c\u65b9\u6cd5\u5c31\u662f\u5728\u7528firewall-cmd\u547d\u4ee4\u6b63\u5e38\u8bbe\u7f6e\u9632\u706b\u5899\u7b56\u7565\u65f6\u6dfb\u52a0--permanent\u53c2\u6570\uff0c\u8fd9\u6837\u914d\u7f6e\u7684\u9632\u706b\u5899\u7b56\u7565\u5c31\u53ef\u4ee5\u6c38\u4e45\u751f\u6548\u4e86\u3002\u4f46\u662f\uff0c\u6c38\u4e45\u751f\u6548\u6a21\u5f0f\u6709\u4e00\u4e2a\u201c\u4e0d\u8fd1\u4eba\u60c5\u201d\u7684\u7279\u70b9\uff0c\u5c31\u662f\u4f7f\u7528\u5b83\u8bbe\u7f6e\u7684\u7b56\u7565\u53ea\u6709\u5728\u7cfb\u7edf\u91cd\u542f\u4e4b\u540e\u624d\u80fd\u81ea\u52a8\u751f\u6548\u3002\u5982\u679c\u60f3\u8ba9\u914d\u7f6e\u7684\u7b56\u7565\u7acb\u5373\u751f\u6548\uff0c\u9700\u8981\u624b\u52a8\u6267\u884cfirewall-cmd --reload\u547d\u4ee4\u3002<\/p>\n

\u63a5\u4e0b\u6765\u7684\u5b9e\u9a8c\u90fd\u5f88\u7b80\u5355\uff0c\u4f46\u662f\u63d0\u9192\u5927\u5bb6\u4e00\u5b9a\u8981\u4ed4\u7ec6\u67e5\u770b\u5218\u9044\u8001\u5e08\u4f7f\u7528\u7684\u662fRuntime\u6a21\u5f0f\u8fd8\u662fPermanent\u6a21\u5f0f\u3002\u5982\u679c\u4e0d\u5173\u6ce8\u8fd9\u4e2a\u7ec6\u8282\uff0c\u5c31\u7b97\u662f\u6b63\u786e\u914d\u7f6e\u4e86\u9632\u706b\u5899\u7b56\u7565\uff0c\u4e5f\u53ef\u80fd\u65e0\u6cd5\u8fbe\u5230\u9884\u671f\u7684\u6548\u679c\u3002<\/p>\n

\u67e5\u770bfirewalld\u670d\u52a1\u5f53\u524d\u6240\u4f7f\u7528\u7684\u533a\u57df\uff1a<\/p>\n

[root@linuxprobe ~]#\u00a0firewall-cmd --get-default-zone\r\npublic<\/pre>\n

\u67e5\u8be2eno16777728\u7f51\u5361\u5728firewalld\u670d\u52a1\u4e2d\u7684\u533a\u57df\uff1a<\/p>\n

[root@linuxprobe ~]# firewall-cmd --get-zone-of-interface=eno16777728\r\npublic<\/pre>\n

\u628afirewalld\u670d\u52a1\u4e2deno16777728\u7f51\u5361\u7684\u9ed8\u8ba4\u533a\u57df\u4fee\u6539\u4e3aexternal\uff0c\u5e76\u5728\u7cfb\u7edf\u91cd\u542f\u540e\u751f\u6548\u3002\u5206\u522b\u67e5\u770b\u5f53\u524d\u4e0e\u6c38\u4e45\u6a21\u5f0f\u4e0b\u7684\u533a\u57df\u540d\u79f0\uff1a<\/p>\n

[root@linuxprobe ~]# firewall-cmd --permanent --zone=external --change-interface=eno16777728\r\nsuccess\r\n[root@linuxprobe ~]# firewall-cmd --get-zone-of-interface=eno16777728\r\npublic\r\n[root@linuxprobe ~]# firewall-cmd --permanent --get-zone-of-interface=eno16777728\r\nexternal<\/pre>\n

\u628afirewalld\u670d\u52a1\u7684\u5f53\u524d\u9ed8\u8ba4\u533a\u57df\u8bbe\u7f6e\u4e3apublic\uff1a<\/p>\n

[root@linuxprobe ~]#\u00a0firewall-cmd --set-default-zone=public\r\nsuccess\r\n[root@linuxprobe ~]# firewall-cmd --get-default-zone \r\npublic<\/pre>\n

\u542f\u52a8\/\u5173\u95edfirewalld\u9632\u706b\u5899\u670d\u52a1\u7684\u5e94\u6025\u72b6\u51b5\u6a21\u5f0f\uff0c\u963b\u65ad\u4e00\u5207\u7f51\u7edc\u8fde\u63a5\uff08\u5f53\u8fdc\u7a0b\u63a7\u5236\u670d\u52a1\u5668\u65f6\u8bf7\u614e\u7528\uff09\uff1a<\/p>\n

[root@linuxprobe ~]# firewall-cmd --panic-on\r\nsuccess\r\n[root@linuxprobe ~]# firewall-cmd --panic-off\r\nsuccess<\/pre>\n

\u67e5\u8be2public\u533a\u57df\u662f\u5426\u5141\u8bb8\u8bf7\u6c42SSH\u548cHTTPS\u534f\u8bae\u7684\u6d41\u91cf\uff1a<\/p>\n

[root@linuxprobe ~]# firewall-cmd --zone=public --query-service=ssh\r\nyes\r\n[root@linuxprobe ~]# firewall-cmd --zone=public --query-service=https\r\nno<\/pre>\n

\u628afirewalld\u670d\u52a1\u4e2d\u8bf7\u6c42HTTPS\u534f\u8bae\u7684\u6d41\u91cf\u8bbe\u7f6e\u4e3a\u6c38\u4e45\u5141\u8bb8\uff0c\u5e76\u7acb\u5373\u751f\u6548\uff1a<\/p>\n

[root@linuxprobe ~]# firewall-cmd --zone=public --add-service=https\r\nsuccess\r\n[root@linuxprobe ~]# firewall-cmd --permanent --zone=public --add-service=https\r\nsuccess\r\n[root@linuxprobe ~]# firewall-cmd --reload\r\nsuccess<\/pre>\n

\u628afirewalld\u670d\u52a1\u4e2d\u8bf7\u6c42HTTP\u534f\u8bae\u7684\u6d41\u91cf\u8bbe\u7f6e\u4e3a\u6c38\u4e45\u62d2\u7edd\uff0c\u5e76\u7acb\u5373\u751f\u6548\uff1a<\/p>\n

[root@linuxprobe ~]# firewall-cmd --permanent --zone=public --remove-service=http \r\nsuccess\r\n[root@linuxprobe ~]# firewall-cmd --reload \r\nsuccess<\/pre>\n

\u628a\u5728firewalld\u670d\u52a1\u4e2d\u8bbf\u95ee8080\u548c8081\u7aef\u53e3\u7684\u6d41\u91cf\u7b56\u7565\u8bbe\u7f6e\u4e3a\u5141\u8bb8\uff0c\u4f46\u4ec5\u9650\u5f53\u524d\u751f\u6548\uff1a<\/p>\n

[root@linuxprobe ~]#\u00a0firewall-cmd --zone=public --add-port=8080-8081\/tcp\r\nsuccess\r\n[root@linuxprobe ~]# firewall-cmd --zone=public --list-ports \r\n8080-8081\/tcp<\/pre>\n
\n

\u628a\u539f\u672c\u8bbf\u95ee\u672c\u673a888\u7aef\u53e3\u7684\u6d41\u91cf\u8f6c\u53d1\u523022\u7aef\u53e3\uff0c\u8981\u4e14\u6c42\u5f53\u524d\u548c\u957f\u671f\u5747\u6709\u6548\uff1a<\/p>\n

\u6d41\u91cf\u8f6c\u53d1\u547d\u4ee4\u683c\u5f0f\u4e3afirewall-cmd --permanent --zone=<\u533a\u57df><\/strong> --add-forward-port=port=<\u6e90\u7aef\u53e3\u53f7><\/strong>:proto=<\u534f\u8bae><\/strong>:toport=<\u76ee\u6807\u7aef\u53e3\u53f7><\/strong>:toaddr=<\u76ee\u6807IP\u5730\u5740><\/strong><\/p><\/blockquote>\n

[root@linuxprobe ~]# firewall-cmd --permanent --zone=public<\/strong> --add-forward-port=port=888<\/strong>:proto=tcp<\/strong>:toport=22<\/strong>:toaddr=192.168.10.10<\/strong>\r\nsuccess\r\n[root@linuxprobe ~]# firewall-cmd --reload\r\nsuccess<\/pre>\n

\u5728\u5ba2\u6237\u7aef\u4f7f\u7528ssh\u547d\u4ee4\u5c1d\u8bd5\u8bbf\u95ee192.168.10.10\u4e3b\u673a\u7684888\u7aef\u53e3\uff1a<\/p>\n

[root@client A ~]# ssh -p 888 192.168.10.10\r\nThe authenticity of host '[192.168.10.10]:888 ([192.168.10.10]:888)' can't be established.\r\nECDSA key fingerprint is b8:25:88:89:5c:05:b6:dd:ef:76:63:ff:1a:54:02:1a.\r\nAre you sure you want to continue connecting (yes\/no)? yes<\/strong>\r\nWarning: Permanently added '[192.168.10.10]:888' (ECDSA) to the list of known hosts.\r\nroot@192.168.10.10's password:\u6b64\u5904\u8f93\u5165\u8fdc\u7a0broot\u7ba1\u7406\u5458\u7684\u5bc6\u7801<\/strong>\r\nLast login: Sun Jul 19 21:43:48 2017 from 192.168.10.10\r\n<\/pre>\n

firewalld\u4e2d\u7684\u5bcc\u89c4\u5219\u8868\u793a\u66f4\u7ec6\u81f4\u3001\u66f4\u8be6\u7ec6\u7684\u9632\u706b\u5899\u7b56\u7565\u914d\u7f6e\uff0c\u5b83\u53ef\u4ee5\u9488\u5bf9\u7cfb\u7edf\u670d\u52a1\u3001\u7aef\u53e3\u53f7\u3001\u6e90\u5730\u5740\u548c\u76ee\u6807\u5730\u5740\u7b49\u8bf8\u591a\u4fe1\u606f\u8fdb\u884c\u66f4\u6709\u9488\u5bf9\u6027\u7684\u7b56\u7565\u914d\u7f6e\u3002\u5b83\u7684\u4f18\u5148\u7ea7\u5728\u6240\u6709\u7684\u9632\u706b\u5899\u7b56\u7565\u4e2d\u4e5f\u662f\u6700\u9ad8\u7684\u3002\u6bd4\u5982\uff0c\u6211\u4eec\u53ef\u4ee5\u5728firewalld\u670d\u52a1\u4e2d\u914d\u7f6e\u4e00\u6761\u5bcc\u89c4\u5219\uff0c\u4f7f\u5176\u62d2\u7edd192.168.10.0\/24\u7f51\u6bb5\u7684\u6240\u6709\u7528\u6237\u8bbf\u95ee\u672c\u673a\u7684ssh\u670d\u52a1\uff0822\u7aef\u53e3\uff09\uff1a<\/p>\n

[root@linuxprobe ~]# firewall-cmd --permanent --zone=public --add-rich-rule=\"rule family=\"ipv4\" source address=\"192.168.10.0\/24\" service name=\"ssh\" reject\"\r\nsuccess\r\n[root@linuxprobe ~]# firewall-cmd --reload\r\nsuccess\r\n<\/pre>\n

\u5728\u5ba2\u6237\u7aef\u4f7f\u7528ssh\u547d\u4ee4\u5c1d\u8bd5\u8bbf\u95ee192.168.10.10\u4e3b\u673a\u7684ssh\u670d\u52a1\uff0822\u7aef\u53e3\uff09\uff1a<\/p>\n

[root@client A ~]# ssh 192.168.10.10\r\nConnecting to 192.168.10.10:22...\r\nCould not connect to '192.168.10.10' (port 22): Connection failed.<\/pre>\n
8.3.2 \u56fe\u5f62\u7ba1\u7406\u5de5\u5177<\/strong><\/span><\/h6>\n

\u5728\u5404\u79cd\u7248\u672c\u7684Linux\u7cfb\u7edf\u4e2d\uff0c\u51e0\u4e4e\u6ca1\u6709\u80fd\u8ba9\u5218\u9044\u8001\u5e08\u6b23\u6170\u5e76\u63a8\u8350\u7684\u56fe\u5f62\u5316\u5de5\u5177\uff0c\u4f46\u662ffirewall-config\u505a\u5230\u4e86\u3002\u5b83\u662ffirewalld\u9632\u706b\u5899\u914d\u7f6e\u7ba1\u7406\u5de5\u5177\u7684GUI\uff08\u56fe\u5f62\u7528\u6237\u754c\u9762\uff09\u7248\u672c\uff0c\u51e0\u4e4e\u53ef\u4ee5\u5b9e\u73b0\u6240\u6709\u4ee5\u547d\u4ee4\u884c\u6765\u6267\u884c\u7684\u64cd\u4f5c\u3002\u6beb\u4e0d\u5938\u5f20\u7684\u8bf4\uff0c\u5373\u4f7f\u8bfb\u8005\u6ca1\u6709\u624e\u5b9e\u7684Linux\u547d\u4ee4\u57fa\u7840\uff0c\u4e5f\u5b8c\u5168\u53ef\u4ee5\u901a\u8fc7\u5b83\u6765\u59a5\u5584\u914d\u7f6eRHEL 7\u4e2d\u7684\u9632\u706b\u5899\u7b56\u7565\u3002firewall-config\u7684\u754c\u9762\u5982\u56fe8-2\u6240\u793a\uff0c\u5176\u529f\u80fd\u5177\u4f53\u5982\u4e0b\u3002<\/p>\n

1\uff1a<\/strong>\u9009\u62e9\u8fd0\u884c\u65f6\uff08Runtime\uff09\u6a21\u5f0f\u6216\u6c38\u4e45\uff08Permanent\uff09\u6a21\u5f0f\u7684\u914d\u7f6e\u3002<\/p>\n

2<\/strong>\uff1a\u53ef\u9009\u7684\u7b56\u7565\u96c6\u5408\u533a\u57df\u5217\u8868\u3002<\/p>\n

3<\/strong>\uff1a\u5e38\u7528\u7684\u7cfb\u7edf\u670d\u52a1\u5217\u8868\u3002<\/p>\n

4<\/strong>\uff1a\u5f53\u524d\u6b63\u5728\u4f7f\u7528\u7684\u533a\u57df\u3002<\/p>\n

5<\/strong>\uff1a\u7ba1\u7406\u5f53\u524d\u88ab\u9009\u4e2d\u533a\u57df\u4e2d\u7684\u670d\u52a1\u3002<\/p>\n

6<\/strong>\uff1a\u7ba1\u7406\u5f53\u524d\u88ab\u9009\u4e2d\u533a\u57df\u4e2d\u7684\u7aef\u53e3\u3002<\/p>\n

7<\/strong>\uff1a\u5f00\u542f\u6216\u5173\u95edSNAT\uff08\u6e90\u5730\u5740\u8f6c\u6362\u534f\u8bae\uff09\u6280\u672f\u3002<\/p>\n

8<\/strong>\uff1a\u8bbe\u7f6e\u7aef\u53e3\u8f6c\u53d1\u7b56\u7565\u3002<\/p>\n

9<\/strong>\uff1a\u63a7\u5236\u8bf7\u6c42icmp\u670d\u52a1\u7684\u6d41\u91cf\u3002<\/p>\n

10<\/strong>\uff1a\u7ba1\u7406\u9632\u706b\u5899\u7684\u5bcc\u89c4\u5219\u3002<\/p>\n

11<\/strong>\uff1a\u7ba1\u7406\u7f51\u5361\u8bbe\u5907\u3002<\/p>\n

12<\/strong>\uff1a\u88ab\u9009\u4e2d\u533a\u57df\u7684\u670d\u52a1\uff0c\u82e5\u52fe\u9009\u4e86\u76f8\u5e94\u670d\u52a1\u524d\u9762\u7684\u590d\u9009\u6846\uff0c\u5219\u8868\u793a\u5141\u8bb8\u4e0e\u4e4b\u76f8\u5173\u7684\u6d41\u91cf\u3002<\/p>\n

13<\/strong>\uff1afirewall-config\u5de5\u5177\u7684\u8fd0\u884c\u72b6\u6001\u3002<\/p><\/blockquote>\n<\/div>\n

\"firewall-config\u754c\u9762\"<\/div>\n

\u56fe8-2\u00a0 firewall-config\u7684\u754c\u9762<\/p>\n

\u5218\u9044\u8001\u5e08\u518d\u5570\u55e6\u51e0\u53e5\u3002\u5728\u4f7f\u7528firewall-config\u5de5\u5177\u914d\u7f6e\u5b8c\u9632\u706b\u5899\u7b56\u7565\u4e4b\u540e\uff0c\u65e0\u987b\u8fdb\u884c\u4e8c\u6b21\u786e\u8ba4\uff0c\u56e0\u4e3a\u53ea\u8981\u6709\u4fee\u6539\u5185\u5bb9\uff0c\u5b83\u5c31\u81ea\u52a8\u8fdb\u884c\u4fdd\u5b58\u3002\u4e0b\u9762\u8fdb\u884c\u52a8\u624b\u5b9e\u8df5\u73af\u8282\u3002<\/p>\n

\u6211\u4eec\u5148\u5c06\u5f53\u524d\u533a\u57df\u4e2d\u8bf7\u6c42http\u670d\u52a1\u7684\u6d41\u91cf\u8bbe\u7f6e\u4e3a\u5141\u8bb8\uff0c\u4f46\u4ec5\u9650\u5f53\u524d\u751f\u6548\u3002\u5177\u4f53\u914d\u7f6e\u5982\u56fe8-3\u6240\u793a\u3002<\/p>\n

\"\u5141\u8bb8\u5176\u4ed6\u4e3b\u673a\u8bbf\u95eehttp\u670d\u52a1\"<\/div>\n

\u56fe8-3\u00a0 \u653e\u884c\u8bf7\u6c42http\u670d\u52a1\u7684\u6d41\u91cf<\/p>\n

\u5c1d\u8bd5\u6dfb\u52a0\u4e00\u6761\u9632\u706b\u5899\u7b56\u7565\u89c4\u5219\uff0c\u4f7f\u5176\u653e\u884c\u8bbf\u95ee8080\uff5e8088\u7aef\u53e3\uff08TCP\u534f\u8bae\uff09\u7684\u6d41\u91cf\uff0c\u5e76\u5c06\u5176\u8bbe\u7f6e\u4e3a\u6c38\u4e45\u751f\u6548\uff0c\u4ee5\u8fbe\u5230\u7cfb\u7edf\u91cd\u542f\u540e\u9632\u706b\u5899\u7b56\u7565\u4f9d\u7136\u751f\u6548\u7684\u76ee\u7684\u3002\u5728\u6309\u7167\u56fe8-4\u6240\u793a\u7684\u754c\u9762\u914d\u7f6e\u5b8c\u6bd5\u4e4b\u540e\uff0c\u8fd8\u9700\u8981\u5728Options\u83dc\u5355\u4e2d\u5355\u51fbReload Firewalld\u547d\u4ee4\uff0c\u8ba9\u914d\u7f6e\u7684\u9632\u706b\u5899\u7b56\u7565\u7acb\u5373\u751f\u6548\uff08\u89c1\u56fe8-5\uff09\u3002\u8fd9\u4e0e\u5728\u547d\u4ee4\u884c\u4e2d\u6267\u884c--reload\u53c2\u6570\u7684\u6548\u679c\u4e00\u6837\u3002<\/p>\n

\"\u5141\u8bb8\u5176\u4ed6\u4e3b\u673a\u8bbf\u95ee8080-8088\u7aef\u53e3\"<\/p>\n

\u56fe8-4\u00a0 \u653e\u884c\u8bbf\u95ee8080\uff5e8088\u7aef\u53e3\u7684\u6d41\u91cf<\/p>\n

\"\u91cd\u542f\u540e\u4f9d\u7136\u6709\u6548\"<\/div>\n

\u56fe8-5\u00a0 \u8ba9\u914d\u7f6e\u7684\u9632\u706b\u5899\u7b56\u7565\u89c4\u5219\u7acb\u5373\u751f\u6548<\/p>\n

\u524d\u9762\u5728\u8bb2\u89e3firewall-config\u5de5\u5177\u7684\u529f\u80fd\u65f6\uff0c\u66fe\u7ecf\u63d0\u5230\u4e86SNAT\uff08Source Network Address Translation\uff0c\u6e90\u7f51\u7edc\u5730\u5740\u8f6c\u6362\uff09\u6280\u672f\u3002SNAT\u662f\u4e00\u79cd\u4e3a\u4e86\u89e3\u51b3IP\u5730\u5740\u532e\u4e4f\u800c\u8bbe\u8ba1\u7684\u6280\u672f\uff0c\u5b83\u53ef\u4ee5\u4f7f\u5f97\u591a\u4e2a\u5185\u7f51\u4e2d\u7684\u7528\u6237\u901a\u8fc7\u540c\u4e00\u4e2a\u5916\u7f51IP\u63a5\u5165Internet\u3002\u8be5\u6280\u672f\u7684\u5e94\u7528\u975e\u5e38\u5e7f\u6cdb\uff0c\u751a\u81f3\u53ef\u4ee5\u8bf4\u6211\u4eec\u6bcf\u5929\u90fd\u5728\u4f7f\u7528\uff0c\u53ea\u4e0d\u8fc7\u6ca1\u6709\u5bdf\u89c9\u5230\u7f62\u4e86\u3002\u6bd4\u5982\uff0c\u5f53\u6211\u4eec\u901a\u8fc7\u5bb6\u4e2d\u7684\u7f51\u5173\u8bbe\u5907\uff08\u6bd4\u5982\u65e0\u7ebf\u8def\u7531\u5668\uff09\u8bbf\u95ee\u672c\u4e66\u914d\u5957\u7ad9\u70b9lrxjmw.cn<\/a>\u65f6\uff0c\u5c31\u7528\u5230\u4e86SNAT\u6280\u672f\u3002<\/p>\n

\u5927\u5bb6\u53ef\u4ee5\u770b\u4e00\u4e0b\u5728\u7f51\u7edc\u4e2d\u4e0d\u4f7f\u7528SNAT\u6280\u672f\uff08\u89c1\u56fe8-6\uff09\u548c\u4f7f\u7528SNAT\u6280\u672f\uff08\u89c1\u56fe8-7\uff09\u65f6\u7684\u60c5\u51b5\u3002\u5728\u56fe8-6\u6240\u793a\u7684\u5c40\u57df\u7f51\u4e2d\u6709\u591a\u53f0PC\uff0c\u5982\u679c\u7f51\u5173\u670d\u52a1\u5668\u6ca1\u6709\u5e94\u7528SNAT\u6280\u672f\uff0c\u5219\u4e92\u8054\u7f51\u4e2d\u7684\u7f51\u7ad9\u670d\u52a1\u5668\u5728\u6536\u5230PC\u7684\u8bf7\u6c42\u6570\u636e\u5305\uff0c\u5e76\u56de\u9001\u54cd\u5e94\u6570\u636e\u5305\u65f6\uff0c\u5c06\u65e0\u6cd5\u5728\u7f51\u7edc\u4e2d\u627e\u5230\u8fd9\u4e2a\u79c1\u6709\u7f51\u7edc\u7684IP\u5730\u5740\uff0c\u6240\u4ee5PC\u4e5f\u5c31\u6536\u4e0d\u5230\u54cd\u5e94\u6570\u636e\u5305\u4e86\u3002\u5728\u56fe8-7\u6240\u793a\u7684\u5c40\u57df\u7f51\u4e2d\uff0c\u7531\u4e8e\u7f51\u5173\u670d\u52a1\u5668\u5e94\u7528\u4e86SNAT\u6280\u672f\uff0c\u6240\u4ee5\u4e92\u8054\u7f51\u4e2d\u7684\u7f51\u7ad9\u670d\u52a1\u5668\u4f1a\u5c06\u54cd\u5e94\u6570\u636e\u5305\u53d1\u7ed9\u7f51\u5173\u670d\u52a1\u5668\uff0c\u518d\u7531\u540e\u8005\u8f6c\u53d1\u7ed9\u5c40\u57df\u7f51\u4e2d\u7684PC\u3002<\/p>\n

\n
\"\"<\/div>\n

\u56fe8-6\u00a0 \u6ca1\u6709\u4f7f\u7528SNAT\u6280\u672f\u7684\u7f51\u7edc<\/p>\n

\"\"<\/div>\n

\u56fe8-7\u00a0 \u4f7f\u7528SNAT\u6280\u672f\u5904\u7406\u8fc7\u7684\u7f51\u7edc<\/p>\n

\u4f7f\u7528iptables\u547d\u4ee4\u5b9e\u73b0SNAT\u6280\u672f\u662f\u4e00\u4ef6\u5f88\u9ebb\u70e6\u7684\u4e8b\u60c5\uff0c\u4f46\u662f\u5728firewall-config\u4e2d\u5374\u662f\u5c0f\u83dc\u4e00\u789f\u4e86\u3002\u7528\u6237\u53ea\u9700\u6309\u7167\u56fe8-8\u8fdb\u884c\u914d\u7f6e\uff0c\u5e76\u9009\u4e2dMasquerade zone\u590d\u9009\u6846\uff0c\u5c31\u81ea\u52a8\u5f00\u542f\u4e86SNAT\u6280\u672f\u3002<\/p>\n<\/div>\n

\"\u5f00\u542f\u4f2a\u88c5\u529f\u80fd\"<\/div>\n

\u56fe8-8\u00a0 \u5f00\u542f\u9632\u706b\u5899\u7684SNAT\u6280\u672f<\/p>\n

\u4e3a\u4e86\u8ba9\u5927\u5bb6\u76f4\u89c2\u67e5\u770b\u4e0d\u540c\u5de5\u5177\u5728\u5b9e\u73b0\u76f8\u540c\u529f\u80fd\u7684\u533a\u522b\uff0c\u8fd9\u91cc\u4f7f\u7528firewall-config\u5de5\u5177\u91cd\u65b0\u6f14\u793a\u4e86\u524d\u9762\u4f7f\u7528firewall-cmd\u6765\u914d\u7f6e\u9632\u706b\u5899\u7b56\u7565\u89c4\u5219\uff0c\u5c06\u672c\u673a888\u7aef\u53e3\u7684\u6d41\u91cf\u8f6c\u53d1\u523022\u7aef\u53e3\uff0c\u4e14\u8981\u6c42\u5f53\u524d\u548c\u957f\u671f\u5747\u6709\u6548\uff0c\u5177\u4f53\u5982\u56fe8-9\u548c\u56fe8-10\u6240\u793a\u3002<\/p>\n

\n

\"\u5c06\u5411\u672c\u673a888\u7aef\u53e3\u7684\u8bf7\u6c42\u8f6c\u53d1\u81f3\u672c\u673a\u768422\u7aef\u53e3\"<\/p>\n

\u56fe8-9\u00a0 \u914d\u7f6e\u672c\u5730\u7684\u7aef\u53e3\u8f6c\u53d1<\/p>\n

\"\"<\/p>\n

\u56fe8-10\u00a0 \u8ba9\u9632\u706b\u5899\u6548\u7b56\u7565\u89c4\u5219\u7acb\u5373\u751f\u6548<\/p>\n

\u914d\u7f6e\u5bcc\u89c4\u5219\uff0c\u8ba9192.168.10.20\u4e3b\u673a\u8bbf\u95ee\u5230\u672c\u673a\u76841234\u7aef\u53e3\u53f7\uff0c\u5982\u56fe8-11\u6240\u793a\u3002<\/p>\n

\"\u4ec5\u5141\u8bb8192.168.10.20\u4e3b\u673a\u8bbf\u95ee\u672c\u673a\u76841234\u7aef\u53e3\"<\/div>\n

\u56fe8-11 \u914d\u7f6e\u9632\u706b\u5899\u5bcc\u89c4\u5219\u7b56\u7565<\/p>\n

\u5982\u679c\u751f\u4ea7\u73af\u5883\u4e2d\u7684\u670d\u52a1\u5668\u6709\u591a\u5757\u7f51\u5361\u5728\u540c\u65f6\u63d0\u4f9b\u670d\u52a1\uff08\u8fd9\u79cd\u60c5\u51b5\u5f88\u5e38\u89c1\uff09\uff0c\u5219\u5bf9\u5185\u7f51\u548c\u5bf9\u5916\u7f51\u63d0\u4f9b\u670d\u52a1\u7684\u7f51\u5361\u8981\u9009\u62e9\u7684\u9632\u706b\u5899\u7b56\u7565\u533a\u57df\u4e5f\u662f\u4e0d\u4e00\u6837\u7684\u3002\u4e5f\u5c31\u662f\u8bf4\uff0c\u53ef\u4ee5\u628a\u7f51\u5361\u4e0e\u9632\u706b\u5899\u7b56\u7565\u533a\u57df\u8fdb\u884c\u7ed1\u5b9a\uff08\u89c1\u56fe8-12\uff09\uff0c\u8fd9\u6837\u5c31\u53ef\u4ee5\u4f7f\u7528\u4e0d\u540c\u7684\u9632\u706b\u5899\u533a\u57df\u7b56\u7565\uff0c\u5bf9\u6e90\u81ea\u4e0d\u540c\u7f51\u5361\u7684\u6d41\u91cf\u8fdb\u884c\u9488\u5bf9\u6027\u7684\u76d1\u63a7\uff0c\u6548\u679c\u4f1a\u66f4\u597d\u3002<\/p>\n

\u6700\u540e\uff0c\u5218\u9044\u8001\u5e08\u60f3\u8bf4\u7684\u662f\uff0cfirewall-config\u5de5\u5177\u771f\u7684\u975e\u5e38\u5b9e\u7528\uff0c\u5f88\u591a\u539f\u672c\u590d\u6742\u7684\u957f\u547d\u4ee4\u88ab\u7528\u56fe\u5f62\u5316\u6309\u94ae\u66ff\u4ee3\uff0c\u8bbe\u7f6e\u89c4\u5219\u4e5f\u7b80\u5355\u660e\u4e86\uff0c\u8db3\u4ee5\u5e94\u5bf9\u65e5\u5e38\u5de5\u4f5c\u3002\u6240\u4ee5\u518d\u6b21\u5411\u5927\u5bb6\u5f3a\u8c03\u914d\u7f6e\u9632\u706b\u5899\u7b56\u7565\u7684\u539f\u5219\u2014\u53ea\u8981\u80fd\u5b9e\u73b0\u6240\u9700\u7684\u529f\u80fd\uff0c\u7528\u4ec0\u4e48\u5de5\u5177\u8bf7\u968f\u541b\u4fbf\u3002<\/p>\n

\"\u67e5\u770b\u7f51\u5361\u8bbe\u5907\u4fe1\u606f\"<\/div>\n
\n

\u56fe8-12\u00a0 \u628a\u7f51\u5361\u4e0e\u9632\u706b\u5899\u7b56\u7565\u533a\u57df\u8fdb\u884c\u7ed1\u5b9a<\/p>\n<\/div>\n

8.4 \u670d\u52a1\u7684\u8bbf\u95ee\u63a7\u5236\u5217\u8868<\/strong><\/span><\/h5>\n

TCP Wrappers\u662fRHEL 7\u7cfb\u7edf\u4e2d\u9ed8\u8ba4\u542f\u7528\u7684\u4e00\u6b3e\u6d41\u91cf\u76d1\u63a7\u7a0b\u5e8f\uff0c\u5b83\u80fd\u591f\u6839\u636e\u6765\u8bbf\u4e3b\u673a\u7684\u5730\u5740\u4e0e\u672c\u673a\u7684\u76ee\u6807\u670d\u52a1\u7a0b\u5e8f\u4f5c\u51fa\u5141\u8bb8\u6216\u62d2\u7edd\u7684\u64cd\u4f5c\u3002\u6362\u53e5\u8bdd\u8bf4\uff0cLinux\u7cfb\u7edf\u4e2d\u5176\u5b9e\u6709\u4e24\u4e2a\u5c42\u9762\u7684\u9632\u706b\u5899\uff0c\u7b2c\u4e00\u79cd\u662f\u524d\u9762\u8bb2\u5230\u7684\u57fa\u4e8eTCP\/IP\u534f\u8bae\u7684\u6d41\u91cf\u8fc7\u6ee4\u5de5\u5177\uff0c\u800cTCP Wrappers\u670d\u52a1\u5219\u662f\u80fd\u5141\u8bb8\u6216\u7981\u6b62Linux\u7cfb\u7edf\u63d0\u4f9b\u670d\u52a1\u7684\u9632\u706b\u5899\uff0c\u4ece\u800c\u5728\u66f4\u9ad8\u5c42\u9762\u4fdd\u62a4\u4e86Linux\u7cfb\u7edf\u7684\u5b89\u5168\u8fd0\u884c\u3002<\/p>\n

TCP Wrappers\u670d\u52a1\u7684\u9632\u706b\u5899\u7b56\u7565\u7531\u4e24\u4e2a\u63a7\u5236\u5217\u8868\u6587\u4ef6\u6240\u63a7\u5236\uff0c\u7528\u6237\u53ef\u4ee5\u7f16\u8f91\u5141\u8bb8\u63a7\u5236\u5217\u8868\u6587\u4ef6\u6765\u653e\u884c\u5bf9\u670d\u52a1\u7684\u8bf7\u6c42\u6d41\u91cf\uff0c\u4e5f\u53ef\u4ee5\u7f16\u8f91\u62d2\u7edd\u63a7\u5236\u5217\u8868\u6587\u4ef6\u6765\u963b\u6b62\u5bf9\u670d\u52a1\u7684\u8bf7\u6c42\u6d41\u91cf\u3002\u63a7\u5236\u5217\u8868\u6587\u4ef6\u4fee\u6539\u540e\u4f1a\u7acb\u5373\u751f\u6548\uff0c\u7cfb\u7edf\u5c06\u4f1a\u5148\u68c0\u67e5\u5141\u8bb8\u63a7\u5236\u5217\u8868\u6587\u4ef6\uff08\/etc\/hosts.allow\uff09\uff0c\u5982\u679c\u5339\u914d\u5230\u76f8\u5e94\u7684\u5141\u8bb8\u7b56\u7565\u5219\u653e\u884c\u6d41\u91cf\uff1b\u5982\u679c\u6ca1\u6709\u5339\u914d\uff0c\u5219\u53bb\u8fdb\u4e00\u6b65\u5339\u914d\u62d2\u7edd\u63a7\u5236\u5217\u8868\u6587\u4ef6\uff08\/etc\/hosts.deny\uff09\uff0c\u82e5\u627e\u5230\u5339\u914d\u9879\u5219\u62d2\u7edd\u8be5\u6d41\u91cf\u3002\u5982\u679c\u8fd9\u4e24\u4e2a\u6587\u4ef6\u5168\u90fd\u6ca1\u6709\u5339\u914d\u5230\uff0c\u5219\u9ed8\u8ba4\u653e\u884c\u6d41\u91cf\u3002<\/p>\n

TCP Wrappers\u670d\u52a1\u7684\u63a7\u5236\u5217\u8868\u6587\u4ef6\u914d\u7f6e\u8d77\u6765\u5e76\u4e0d\u590d\u6742\uff0c\u5e38\u7528\u7684\u53c2\u6570\u5982\u88688-4\u6240\u793a\u3002<\/p>\n

\u88688-4\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 TCP Wrappers\u670d\u52a1\u7684\u63a7\u5236\u5217\u8868\u6587\u4ef6\u4e2d\u5e38\u7528\u7684\u53c2\u6570<\/p>\n\n\n\n\n\n\n\n\n\n
\u5ba2\u6237\u7aef\u7c7b\u578b<\/td>\n\u793a\u4f8b<\/td>\n\u6ee1\u8db3\u793a\u4f8b\u7684\u5ba2\u6237\u7aef\u5217\u8868<\/td>\n<\/tr>\n
\u5355\u4e00\u4e3b\u673a<\/td>\n192.168.10.10<\/td>\nIP\u5730\u5740\u4e3a192.168.10.10\u7684\u4e3b\u673a<\/td>\n<\/tr>\n
\u6307\u5b9a\u7f51\u6bb5<\/td>\n192.168.10.<\/td>\nIP\u6bb5\u4e3a192.168.10.0\/24\u7684\u4e3b\u673a<\/td>\n<\/tr>\n
\u6307\u5b9a\u7f51\u6bb5<\/td>\n192.168.10.0\/255.255.255.0<\/td>\nIP\u6bb5\u4e3a192.168.10.0\/24\u7684\u4e3b\u673a<\/td>\n<\/tr>\n
\u6307\u5b9aDNS\u540e\u7f00<\/td>\n.lrxjmw.cn<\/td>\n\u6240\u6709DNS\u540e\u7f00\u4e3a.lrxjmw.cn\u7684\u4e3b\u673a<\/td>\n<\/tr>\n
\u6307\u5b9a\u4e3b\u673a\u540d\u79f0<\/td>\nlrxjmw.cn<\/td>\n\u4e3b\u673a\u540d\u79f0\u4e3alrxjmw.cn\u7684\u4e3b\u673a<\/td>\n<\/tr>\n
\u6307\u5b9a\u6240\u6709\u5ba2\u6237\u7aef<\/td>\nALL<\/td>\n\u6240\u6709\u4e3b\u673a\u5168\u90e8\u5305\u62ec\u5728\u5185<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

<\/p>\n

\u5728\u914d\u7f6eTCP Wrappers\u670d\u52a1\u65f6\u9700\u8981\u9075\u5faa\u4e24\u4e2a\u539f\u5219\uff1a<\/p>\n

    \n
  1. \u7f16\u5199\u62d2\u7edd\u7b56\u7565\u89c4\u5219\u65f6\uff0c\u586b\u5199\u7684\u662f\u670d\u52a1\u540d\u79f0\uff0c\u800c\u975e\u534f\u8bae\u540d\u79f0\uff1b<\/li>\n
  2. \u5efa\u8bae\u5148\u7f16\u5199\u62d2\u7edd\u7b56\u7565\u89c4\u5219\uff0c\u518d\u7f16\u5199\u5141\u8bb8\u7b56\u7565\u89c4\u5219\uff0c\u4ee5\u4fbf\u76f4\u89c2\u5730\u770b\u5230\u76f8\u5e94\u7684\u6548\u679c\u3002<\/li>\n<\/ol>\n

    \u4e0b\u9762\u7f16\u5199\u62d2\u7edd\u7b56\u7565\u89c4\u5219\u6587\u4ef6\uff0c\u7981\u6b62\u8bbf\u95ee\u672c\u673asshd\u670d\u52a1\u7684\u6240\u6709\u6d41\u91cf\uff08\u65e0\u987b\/etc\/hosts.deny\u6587\u4ef6\u4e2d\u4fee\u6539\u539f\u6709\u7684\u6ce8\u91ca\u4fe1\u606f\uff09\uff1a<\/p>\n

    [root@linuxprobe ~]# vim \/etc\/hosts.deny\r\n#\r\n# hosts.deny This file contains access rules which are used to\r\n# deny connections to network services that either use\r\n# the tcp_wrappers library or that have been\r\n# started through a tcp_wrappers-enabled xinetd.\r\n#\r\n# The rules in this file can also be set up in\r\n# \/etc\/hosts.allow with a 'deny' option instead.\r\n#\r\n# See 'man 5 hosts_options' and 'man 5 hosts_access'\r\n# for information on rule syntax.\r\n# See 'man tcpd' for information on tcp_wrappers\r\nsshd:*\r\n<\/strong>[root@linuxprobe ~]# ssh 192.168.10.10\r\nssh_exchange_identification: read: Connection reset by peer\r\n<\/pre>\n

    \u63a5\u4e0b\u6765\uff0c\u5728\u5141\u8bb8\u7b56\u7565\u89c4\u5219\u6587\u4ef6\u4e2d\u6dfb\u52a0\u4e00\u6761\u89c4\u5219\uff0c\u4f7f\u5176\u653e\u884c\u6e90\u81ea192.168.10.0\/24\u7f51\u6bb5\uff0c\u8bbf\u95ee\u672c\u673asshd\u670d\u52a1\u7684\u6240\u6709\u6d41\u91cf\u3002\u53ef\u4ee5\u770b\u5230\uff0c\u670d\u52a1\u5668\u7acb\u523b\u5c31\u653e\u884c\u4e86\u8bbf\u95eesshd\u670d\u52a1\u7684\u6d41\u91cf\uff0c\u6548\u679c\u975e\u5e38\u76f4\u89c2\uff1a<\/p>\n

    [root@linuxprobe ~]# vim \/etc\/hosts.allow\r\n#\r\n# hosts.allow This file contains access rules which are used to\r\n# allow or deny connections to network services that\r\n# either use the tcp_wrappers library or that have been\r\n# started through a tcp_wrappers-enabled xinetd.\r\n#\r\n# See 'man 5 hosts_options' and 'man 5 hosts_access'\r\n# for information on rule syntax.\r\n# See 'man tcpd' for information on tcp_wrappers\r\nsshd:192.168.10.\r\n\r\n<\/strong>[root@linuxprobe ~]# ssh 192.168.10.10\r\nThe authenticity of host '192.168.10.10 (192.168.10.10)' can't be established.\r\nECDSA key fingerprint is 70:3b:5d:37:96:7b:2e:a5:28:0d:7e:dc:47:6a:fe:5c.\r\nAre you sure you want to continue connecting (yes\/no)? yes\r\nWarning: Permanently added '192.168.10.10' (ECDSA) to the list of known hosts.\r\nroot@192.168.10.10's password: \r\nLast login: Wed May 4 07:56:29 2017\r\n[root@linuxprobe\u00a0~]# \r\n<\/pre>\n

    \u51fa\u73b0\u95ee\u9898?\u5927\u80c6\u63d0\u95ee!<\/strong><\/span><\/p>\n

    \u56e0\u8bfb\u8005\u4eec\u786c\u4ef6\u4e0d\u540c\u6216\u64cd\u4f5c\u9519\u8bef\u90fd\u53ef\u80fd\u5bfc\u81f4\u5b9e\u9a8c\u914d\u7f6e\u51fa\u9519\uff0c\u8bf7\u8010\u5fc3\u518d\u4ed4\u7ec6\u770b\u770b\u64cd\u4f5c\u6b65\u9aa4\u5427\uff0c\u4e0d\u8981\u6c14\u9981~<\/p>\n

    Linux\u6280\u672f\u4ea4\u6d41\u8bf7\u52a0A\u7fa4\uff1a560843(\u6ee1<\/span><\/strong>)\uff0cB\u7fa4\uff1a340829(\u63a8\u8350<\/span><\/strong>)\uff0cC\u7fa4\uff1a463590\uff08\u63a8\u8350<\/span><\/strong>\uff09\uff0c\u70b9\u6b64\u67e5\u770b\u5168\u56fd\u7fa4<\/a>\u3002<\/p>\n

    *\u672c\u7fa4\u7279\u8272\uff1a\u901a\u8fc7\u53e3\u4ee4\u9a8c\u8bc1\u786e\u4fdd\u6bcf\u4e00\u4e2a\u7fa4\u5458\u90fd\u662f\u300aLinux\u5c31\u8be5\u8fd9\u4e48\u5b66\u300b\u7684\u8bfb\u8005\uff0c\u7b54\u7591\u66f4\u6709\u9488\u5bf9\u6027\uff0c\u4e0d\u5b9a\u671f\u514d\u8d39\u9886\u53d6\u5b9a\u5236\u793c\u54c1\u3002<\/p><\/blockquote>\n

    \u672c\u7ae0\u8282\u7684\u590d\u4e60\u4f5c\u4e1a<\/span>(\u7b54\u6848\u5c31\u5728\u95ee\u9898\u7684\u4e0b\u4e00\u884c\u54e6\uff0c\u7528\u9f20\u6807\u9009\u4e2d\u5373\u53ef\u770b\u5230\u7684~)<\/strong><\/span><\/div>\n<\/div>\n

     <\/p>\n

    1\uff0e\u5728RHEL 7\u7cfb\u7edf\u4e2d\uff0ciptables\u662f\u5426\u5df2\u7ecf\u88abfirewalld\u670d\u52a1\u5f7b\u5e95\u53d6\u4ee3\uff1f<\/p>\n

    \u7b54\uff1a<\/strong>\u6ca1\u6709\uff0ciptables\u548cfirewalld\u670d\u52a1\u5747\u53ef\u7528\u4e8eRHEL 7\u7cfb\u7edf\u3002<\/span><\/p>\n

    2\uff0e\u8bf7\u7b80\u8ff0\u9632\u706b\u5899\u7b56\u7565\u89c4\u5219\u4e2dDROP\u548cREJECT\u7684\u4e0d\u540c\u4e4b\u5904\u3002<\/p>\n

    \u7b54\uff1a<\/strong>DROP\u7684\u52a8\u4f5c\u662f\u4e22\u5305\uff0c\u4e0d\u54cd\u5e94\uff1bREJECT\u662f\u62d2\u7edd\u8bf7\u6c42\uff0c\u540c\u65f6\u5411\u53d1\u9001\u65b9\u56de\u9001\u62d2\u7edd\u4fe1\u606f\u3002<\/span><\/p>\n

    3\uff0e\u5982\u4f55\u628aiptables\u670d\u52a1\u7684INPUT\u89c4\u5219\u94fe\u9ed8\u8ba4\u7b56\u7565\u8bbe\u7f6e\u4e3aDROP\uff1f<\/p>\n

    \u7b54\uff1a<\/strong>\u6267\u884c\u547d\u4ee4iptables -P INPUT DROP\u5373\u53ef\u3002<\/span><\/p>\n

    4\uff0e\u600e\u6837\u7f16\u5199\u4e00\u6761\u9632\u706b\u5899\u7b56\u7565\u89c4\u5219\uff0c\u4f7f\u5f97iptables\u670d\u52a1\u53ef\u4ee5\u7981\u6b62\u6e90\u81ea192.168.10.0\/24\u7f51\u6bb5\u7684\u6d41\u91cf\u8bbf\u95ee\u672c\u673a\u7684sshd\u670d\u52a1\uff0822\u7aef\u53e3\uff09\uff1f<\/p>\n

    \u7b54\uff1a<\/strong>\u6267\u884c\u547d\u4ee4iptables -I INPUT -s 192.168.10.0\/24 -p tcp --dport 22 -j REJECT\u5373\u53ef\u3002<\/span><\/p>\n

    5\uff0e\u8bf7\u7b80\u8ff0firewalld\u4e2d\u533a\u57df\u7684\u4f5c\u7528\u3002<\/p>\n

    \u7b54\uff1a<\/strong>\u53ef\u4ee5\u4f9d\u636e\u4e0d\u540c\u7684\u5de5\u4f5c\u573a\u666f\u6765\u8c03\u7528\u4e0d\u540c\u7684firewalld\u533a\u57df\uff0c\u5b9e\u73b0\u5927\u91cf\u9632\u706b\u5899\u7b56\u7565\u89c4\u5219\u7684\u5feb\u901f\u5207\u6362\u3002<\/span><\/p>\n

    6\uff0e\u5982\u4f55\u5728firewalld\u4e2d\u628a\u9ed8\u8ba4\u7684\u533a\u57df\u8bbe\u7f6e\u4e3admz\uff1f<\/p>\n

    \u7b54\uff1a<\/strong>\u6267\u884c\u547d\u4ee4firewall-cmd --set-default-zone=dmz\u5373\u53ef\u3002<\/span><\/p>\n

    7\uff0e\u5982\u4f55\u8ba9firewalld\u4e2d\u4ee5\u6c38\u4e45\uff08Permanent\uff09\u6a21\u5f0f\u914d\u7f6e\u7684\u9632\u706b\u5899\u7b56\u7565\u89c4\u5219\u7acb\u5373\u751f\u6548\uff1f<\/p>\n

    \u7b54\uff1a<\/strong>\u6267\u884c\u547d\u4ee4firewall-cmd --reload\u3002<\/span><\/p>\n

    8\uff0e\u4f7f\u7528SNAT\u6280\u672f\u7684\u76ee\u7684\u662f\u4ec0\u4e48\uff1f<\/p>\n

    \u7b54\uff1a<\/strong>SNAT\u662f\u4e00\u79cd\u4e3a\u4e86\u89e3\u51b3IP\u5730\u5740\u532e\u4e4f\u800c\u8bbe\u8ba1\u7684\u6280\u672f\uff0c\u5b83\u53ef\u4ee5\u4f7f\u5f97\u591a\u4e2a\u5185\u7f51\u4e2d\u7684\u7528\u6237\u901a\u8fc7\u540c\u4e00\u4e2a\u5916\u7f51IP\u63a5\u5165Internet\uff08\u4e92\u8054\u7f51\uff09\u3002<\/span><\/p>\n

    9\uff0e\u00a0TCP Wrappers\u670d\u52a1\u5206\u522b\u6709\u5141\u8bb8\u7b56\u7565\u914d\u7f6e\u6587\u4ef6\u548c\u62d2\u7edd\u7b56\u7565\u914d\u7f6e\u6587\u4ef6\uff0c\u8bf7\u95ee\u5339\u914d\u987a\u5e8f\u662f\u600e\u4e48\u6837\u7684\uff1f<\/p>\n

    \u7b54\uff1a<\/strong>TCP Wrappers\u4f1a\u5148\u4f9d\u6b21\u5339\u914d\u5141\u8bb8\u7b56\u7565\u914d\u7f6e\u6587\u4ef6\uff0c\u7136\u540e\u518d\u4f9d\u6b21\u5339\u914d\u62d2\u7edd\u7b56\u7565\u914d\u7f6e\u6587\u4ef6\uff0c\u5982\u679c\u90fd\u6ca1\u6709\u5339\u914d\u5230\uff0c\u5219\u9ed8\u8ba4\u653e\u884c\u6d41\u91cf\u3002<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"

    \u7ea2\u5e3d\u67b6\u6784\u5e08\u6559\u60a8\u4f7f\u7528firewalld\u670d\u52a1\u7684\u9632\u706b\u5899\u7ba1\u7406\u547d\u4ee4firewall-cmd\u547d\u4ee4\u4e0e\u56fe\u5f62\u5316\u5de5\u5177firewall-config\uff0c\u57fa\u4e8e\u6570\u5341\u4e2a\u9632\u706b\u5899\u9700\u6c42\uff0c\u4f7f\u7528\u89c4\u5219\u7b56\u7565\u5b8c\u6574\u6f14\u793a\u5bf9\u6570\u636e\u5305\u7684\u8fc7\u6ee4\u3001SNAT\/SDAT\u6280\u672f\u3001\u7aef\u53e3\u8f6c\u53d1\u4ee5\u53ca\u8d1f\u8f7d\u5747\u8861\u7b49\u5b9e\u9a8c\uff0c\u8fd8\u65b0\u589e\u4e86Tcp_wrappers\u9632\u706b\u5899\u670d\u52a1\u5c0f\u8282\uff0c\u7b80\u5355\u914d\u7f6e\u5373\u53ef\u4fdd\u8bc1\u7cfb\u7edf\u4e0e\u670d\u52a1\u7684\u5b89\u5168\u3002<\/p>\n","protected":false},"author":1,"featured_media":17173,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[558],"tags":[],"class_list":["post-576","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-rhel7"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/576","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=576"}],"version-history":[{"count":175,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/576\/revisions"}],"predecessor-version":[{"id":218016,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/576\/revisions\/218016"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/17173"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=576"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=576"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=576"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}