{"id":181461,"date":"2020-05-06T00:43:56","date_gmt":"2020-05-05T16:43:56","guid":{"rendered":"https:\/\/gulass.cn\/?p=181461"},"modified":"2023-04-23T17:12:19","modified_gmt":"2023-04-23T09:12:19","slug":"basic-learning-08","status":"publish","type":"post","link":"https:\/\/gulass.cn\/basic-learning-08.html","title":{"rendered":"\u7b2c8\u7ae0 \u4f7f\u7528Iptables\u4e0eFirewalld\u9632\u706b\u5899"},"content":{"rendered":"

\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\/8\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\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 Wrapper\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\u80fd\u591f\u719f\u7ec3\u5730\u8fc7\u6ee4\u8bf7\u6c42\u7684\u6d41\u91cf\u3001\u57fa\u4e8e\u670d\u52a1\u7a0b\u5e8f\u7684\u540d\u79f0\u5bf9\u6d41\u91cf\u8fdb\u884c\u5141\u8bb8\u548c\u62d2\u7edd\u64cd\u4f5c\uff0c\u8fd8\u53ef\u4ee5\u4f7f\u7528Cockpit\u8f7b\u677e\u76d1\u63a7\u7cfb\u7edf\u7684\u8fd0\u884c\u72b6\u6001\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\u5c31\u50cf\u5bb6\u91cc\u5b89\u88c5\u7684\u9632\u76d7\u95e8\u4e00\u6837\uff0c\u76ee\u7684\u662f\u4fdd\u62a4\u4eb2\u4eba\u548c\u8d22\u4ea7\u5b89\u5168\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\u80fd\u591f\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

\"\"<\/p>\n

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

\u4eceRHEL 7\u7cfb\u7edf\u5f00\u59cb\uff0cfirewalld\u9632\u706b\u5899\u6b63\u5f0f\u53d6\u4ee3\u4e86iptables\u9632\u706b\u5899\u3002\u5bf9\u4e8e\u63a5\u89e6Linux\u7cfb\u7edf\u6bd4\u8f83\u65e9\u6216\u5b66\u4e60\u8fc7RHEL 5\/6\u7cfb\u7edf\u7684\u8bfb\u8005\u6765\u8bf4\uff0c\u5f53\u4ed6\u4eec\u53d1\u73b0\u66fe\u7ecf\u638c\u63e1\u7684\u77e5\u8bc6\u5728RHEL 7\/8\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\uff1b\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<\/p>\n

\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\u6309\u7167\u4ece\u4e0a\u5230\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\u201c\u901a\u201d\uff08\u5373\u653e\u884c\uff09\u548c\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\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\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\u987b\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\u201c\u62d2\u7edd\u201d\u201c\u767b\u8bb0\u201d\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\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

\u4e0b\u9762\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\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

\n
\n

Tips<\/strong><\/h3>\n<\/div>\n
\n

\u5728\u7ea2\u5e3d\u8ba4\u8bc1\u8003\u8bd5\u4e2d\u5fc5\u987b\u7528REJECT\u8fdb\u884c\u62d2\u7edd\uff0c\u597d\u8ba9\u7528\u4e8e\u5224\u5206\u7684\u811a\u672c\u5f97\u5230\u53cd\u5e94\uff0c\u4ee5\u83b7\u5f97\u5206\u503c\u3002\u800c\u5728\u5de5\u4f5c\u4e2d\u66f4\u591a\u5efa\u8bae\u7528DROP\u8fdb\u884c\u62d2\u7edd\uff0c\u8fd9\u53ef\u4ee5\u9690\u85cf\u670d\u52a1\u5668\u7684\u8fd0\u884c\u72b6\u6001\u3002\u8fd9\u6837\u505a\u6709\u5f88\u591a\u597d\u5904\u3002<\/p>\n<\/div>\n<\/div>\n

\u5f53\u628aLinux\u7cfb\u7edf\u4e2d\u7684\u9632\u706b\u5899\u7b56\u7565\u8bbe\u7f6e\u4e3aREJECT\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\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\u7684\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\u987b\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

\u6839\u636eOSI\u4e03\u5c42\u6a21\u578b\u7684\u5b9a\u4e49\uff0ciptables\u5c5e\u4e8e\u5de5\u4f5c\u5728\u7b2c\u4e8c\u4e09\u56db\u5c42\u7684\u670d\u52a1\uff0c\u6240\u4ee5\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\uff1b\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\u5230\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\u65e0\u987b\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

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

[root@linuxprobe ~]# iptables -L\r\nChain INPUT (policy ACCEPT)\r\ntarget     prot opt source               destination         \r\nACCEPT     udp  --  anywhere             anywhere             udp dpt:domain\r\nACCEPT     tcp  --  anywhere             anywhere             tcp dpt:domain\r\nACCEPT     udp  --  anywhere             anywhere             udp dpt:bootps\r\nACCEPT     tcp  --  anywhere             anywhere             tcp dpt:bootps\r\n\r\nChain FORWARD (policy ACCEPT)\r\ntarget     prot opt source               destination         \r\nACCEPT     all  --  anywhere             192.168.122.0\/24     ctstate RELATED,ESTABLISHED\r\nACCEPT     all  --  192.168.122.0\/24     anywhere            \r\nACCEPT     all  --  anywhere             anywhere            \r\nREJECT     all  --  anywhere             anywhere             reject-with icmp-port-unreachable\r\nREJECT     all  --  anywhere             anywhere             reject-with icmp-port-unreachable\r\n\r\nChain OUTPUT (policy ACCEPT)\r\ntarget     prot opt source               destination         \r\nACCEPT     udp  --  anywhere             anywhere             udp dpt:bootpc\r\n<\/pre>\n

2\uff0e<\/strong>\u5728iptables\u547d\u4ee4\u540e\u6dfb\u52a0-F\u53c2\u6570\u6e05\u7a7a\u5df2\u6709\u7684\u9632\u706b\u5899\u89c4\u5219\u94fe\u3002<\/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\r\nChain FORWARD (policy ACCEPT)\r\ntarget     prot opt source               destination         \r\n\r\nChain OUTPUT (policy ACCEPT)\r\ntarget     prot opt source               destination<\/pre>\n

3\uff0e<\/strong>\u628aINPUT\u89c4\u5219\u94fe\u7684\u9ed8\u8ba4\u7b56\u7565\u8bbe\u7f6e\u4e3a\u62d2\u7edd\u3002<\/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\r\nChain FORWARD (policy ACCEPT)\r\ntarget     prot opt source               destination         \r\n\r\nChain OUTPUT (policy ACCEPT)\r\ntarget     prot opt source               destination<\/pre>\n

\u524d\u6587\u63d0\u5230\uff0c\u9632\u706b\u5899\u7b56\u7565\u89c4\u5219\u7684\u8bbe\u7f6e\u65e0\u975e\u6709\u4e24\u79cd\u65b9\u5f0f\uff1a\u201c\u901a\u201d\u548c\u201c\u5835\u201d\u3002\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\u3002\u540c\u5b66\u4eec\u9700\u8981\u7559\u610f\u7684\u662f\uff0c\u89c4\u5219\u94fe\u7684\u9ed8\u8ba4\u7b56\u7565\u62d2\u7edd\u52a8\u4f5c\u53ea\u80fd\u662fDROP\uff0c\u800c\u4e0d\u80fd\u662fREJECT\u3002<\/p>\n

4\uff0e<\/strong>\u5411INPUT\u94fe\u4e2d\u6dfb\u52a0\u5141\u8bb8ICMP\u6d41\u91cf\u8fdb\u5165\u7684\u7b56\u7565\u89c4\u5219\u3002<\/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 192.168.10.10 (192.168.10.10) 56(84) bytes of data.\r\n64 bytes from 192.168.10.10: icmp_seq=1 ttl=64 time=0.154 ms\r\n64 bytes from 192.168.10.10: icmp_seq=2 ttl=64 time=0.041 ms\r\n64 bytes from 192.168.10.10: icmp_seq=3 ttl=64 time=0.038 ms\r\n64 bytes from 192.168.10.10: icmp_seq=4 ttl=64 time=0.046 ms\r\n\r\n--- 192.168.10.10 ping statistics ---\r\n4 packets transmitted, 4 received, 0% packet loss, time 104ms\r\nrtt min\/avg\/max\/mdev = 0.038\/0.069\/0.154\/0.049 ms\r\n<\/pre>\n

5\uff0e\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\u3002<\/strong><\/p>\n

\u4f7f\u7528-F\u53c2\u6570\u4f1a\u6e05\u7a7a\u5df2\u6709\u7684\u6240\u6709\u9632\u706b\u5899\u7b56\u7565\uff1b\u4f7f\u7528-D\u53c2\u6570\u53ef\u4ee5\u5220\u9664\u67d0\u4e00\u6761\u6307\u5b9a\u7684\u7b56\u7565\uff0c\u56e0\u6b64\u66f4\u52a0\u5b89\u5168\u548c\u51c6\u786e\u3002<\/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\r\nChain FORWARD (policy ACCEPT)\r\ntarget     prot opt source               destination         \r\n\r\nChain OUTPUT (policy ACCEPT)\r\ntarget     prot opt source               destination<\/pre>\n

6\uff0e\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\u3002<\/strong><\/p>\n

\u8981\u5bf9\u67d0\u53f0\u4e3b\u673a\u8fdb\u884c\u5339\u914d\uff0c\u53ef\u76f4\u63a5\u5199\u51fa\u5b83\u7684IP\u5730\u5740\uff1b\u5982\u9700\u5bf9\u7f51\u6bb5\u8fdb\u884c\u5339\u914d\uff0c\u5219\u9700\u8981\u5199\u4e3a\u5b50\u7f51\u63a9\u7801\u7684\u5f62\u5f0f\uff08\u6bd4\u5982192.168.10.0\/24\uff09\u3002<\/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 ~]# iptables -L\r\nChain INPUT (policy ACCEPT)\r\ntarget prot opt source destination\r\n ACCEPT tcp -- 192.168.10.0\/24 anywhere tcp dpt:ssh \r\n REJECT 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\u7b2c9\u7ae0\uff09\uff0c\u8fd9\u91cc\u5148\u6316\u4e2a\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\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 SHA256:5d52kZi1la\/FJK4v4jibLBZhLqzGqbJAskZiME6ZXpQ.\r\nAre you sure you want to continue connecting (yes\/no)? yes<\/strong>\r\nWarning: Permanently added '192.168.10.10' (ECDSA) to the list of known hosts.\r\nroot@192.168.10.10's password: \u6b64\u5904\u8f93\u5165\u670d\u52a1\u5668\u5bc6\u7801<\/strong>\r\nActivate the web console with: systemctl enable --now cockpit.socket\r\n\r\nLast login: Wed Jan 20 16:30:28 2021 from 192.168.10.1\r\n<\/pre>\n

\u7136\u540e\uff0c\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\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

\u7531\u4e0a\u53ef\u4ee5\u770b\u5230\uff0c\u63d0\u793a\u8fde\u63a5\u8bf7\u6c42\u88ab\u62d2\u7edd\u4e86\uff08Connection failed\uff09\u3002<\/p>\n

7\uff0e\u5411INPUT\u89c4\u5219\u94fe\u4e2d\u6dfb\u52a0\u62d2\u7edd\u6240\u6709\u4eba\u8bbf\u95ee\u672c\u673a12345\u7aef\u53e3\u7684\u7b56\u7565\u89c4\u5219\u3002<\/strong><\/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\n REJECT udp -- anywhere anywhere udp dpt:italk reject-with icmp-port-unreachable\r\n<\/span> REJECT tcp -- anywhere anywhere tcp dpt:italk reject-with icmp-port-unreachable<\/span>\r\n ACCEPT tcp -- 192.168.10.0\/24 anywhere tcp dpt:ssh\r\n REJECT 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

8\uff0e\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\u3002<\/strong><\/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\n REJECT tcp -- 192.168.10.5 anywhere tcp dpt:http reject-with icmp-port-unreachable<\/span>\r\n REJECT udp -- anywhere anywhere udp dpt:italk reject-with icmp-port-unreachable\r\n REJECT tcp -- anywhere anywhere tcp dpt:italk reject-with icmp-port-unreachable\r\n ACCEPT tcp -- 192.168.10.0\/24 anywhere tcp dpt:ssh\r\n REJECT 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

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

\u524d\u9762\u5728\u6dfb\u52a0\u9632\u706b\u5899\u7b56\u7565\u65f6\uff0c\u4f7f\u7528\u7684\u662f-I\u53c2\u6570\uff0c\u5b83\u9ed8\u8ba4\u4f1a\u628a\u89c4\u5219\u6dfb\u52a0\u5230\u6700\u4e0a\u9762\u7684\u4f4d\u7f6e\uff0c\u56e0\u6b64\u4f18\u5148\u7ea7\u662f\u6700\u9ad8\u7684\u3002\u5982\u679c\u5de5\u4f5c\u4e2d\u9700\u8981\u6dfb\u52a0\u4e00\u6761\u6700\u540e\u201c\u515c\u5e95\u201d\u7684\u89c4\u5219\uff0c\u90a3\u5c31\u7528-A\u53c2\u6570\u5427\u3002\u8fd9\u4e24\u4e2a\u53c2\u6570\u7684\u6548\u679c\u5dee\u522b\u8fd8\u662f\u5f88\u5927\u7684\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\n REJECT tcp -- 192.168.10.5 anywhere tcp dpt:http reject-with icmp-port-unreachable\r\n REJECT udp -- anywhere anywhere udp dpt:italk reject-with icmp-port-unreachable\r\n REJECT tcp -- anywhere anywhere tcp dpt:italk reject-with icmp-port-unreachable\r\n ACCEPT tcp -- 192.168.10.0\/24 anywhere tcp dpt:ssh\r\n REJECT tcp -- anywhere anywhere tcp dpt:ssh reject-with icmp-port-unreachable\r\n REJECT tcp -- anywhere anywhere tcp dpts:cadlock2:1024 reject-with icmp-port-unreachable<\/span>\r\n REJECT udp -- anywhere anywhere udp dpts:cadlock2:1024 reject-with icmp-port-unreachable<\/span>\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 ~]# iptables-save \r\n# Generated by xtables-save v1.8.2 on Wed Jan 20 16:56:27 2021\r\n\u2026\u2026\u2026\u2026\u2026\u2026\u7701\u7565\u90e8\u5206\u8f93\u51fa\u4fe1\u606f\u2026\u2026\u2026\u2026\u2026\u2026\r\n<\/pre>\n

\u5bf9\u4e86\uff0c\u5982\u679c\u516c\u53f8\u670d\u52a1\u5668\u662f5\/6\/7\u7248\u672c\u7684\u8bdd\uff0c\u5bf9\u5e94\u7684\u4fdd\u5b58\u547d\u4ee4\u5e94\u8be5\u662f\uff1a<\/p>\n

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

RHEL 8\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\u5236\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\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\u65f6\u66fe\u7ecf\u63d0\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\u3002\u5927\u5bb6\u4e0d\u8981\u4e00\u542c\u5230\u957f\u683c\u5f0f\u5c31\u5934\u5927\uff0c\u56e0\u4e3aRHEL 8\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\u3002\u8fd9\u592a\u68d2\u4e86\uff01\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\u4f1a\u968f\u7740\u7cfb\u7edf\u7684\u91cd\u542f\u800c\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

\n
\n

Tips<\/strong><\/h3>\n<\/div>\n
\n

Runtime\uff1a\u5f53\u524d\u7acb\u5373\u751f\u6548\uff0c\u91cd\u542f\u540e\u5931\u6548\u3002<\/p>\n

Permanent\uff1a\u5f53\u524d\u4e0d\u751f\u6548\uff0c\u91cd\u542f\u540e\u751f\u6548\u3002<\/p>\n<\/div>\n<\/div>\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\u4f7f\u7528\u7684\u662fRuntime\u6a21\u5f0f\u8fd8\u662fPermanent\u6a21\u5f0f\u3002\u5982\u679c\u4e0d\u5173\u6ce8\u8fd9\u4e2a\u7ec6\u8282\uff0c\u5c31\u7b97\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

1\uff0e\u67e5\u770bfirewalld\u670d\u52a1\u5f53\u524d\u6240\u4f7f\u7528\u7684\u533a\u57df\u3002<\/strong><\/p>\n

\u8fd9\u662f\u4e00\u6b65\u975e\u5e38\u91cd\u8981\u7684\u64cd\u4f5c\u3002\u5728\u914d\u7f6e\u9632\u706b\u5899\u7b56\u7565\u524d\uff0c\u5fc5\u987b\u67e5\u770b\u5f53\u524d\u751f\u6548\u7684\u662f\u54ea\u4e2a\u533a\u57df\uff0c\u5426\u5219\u914d\u7f6e\u7684\u9632\u706b\u5899\u7b56\u7565\u5c06\u4e0d\u4f1a\u7acb\u5373\u751f\u6548\u3002<\/p>\n

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

2\uff0e\u67e5\u8be2\u6307\u5b9a\u7f51\u5361\u5728firewalld\u670d\u52a1\u4e2d\u7ed1\u5b9a\u7684\u533a\u57df\u3002<\/strong><\/p>\n

\u5728\u751f\u4ea7\u73af\u5883\u4e2d\uff0c\u670d\u52a1\u5668\u5927\u591a\u4e0d\u6b62\u6709\u4e00\u5757\u7f51\u5361\u3002\u4e00\u822c\u6765\u8bf4\uff0c\u5145\u5f53\u7f51\u5173\u7684\u670d\u52a1\u5668\u6709\u4e24\u5757\u7f51\u5361\uff0c\u4e00\u5757\u5bf9\u516c\u7f51\uff0c\u53e6\u5916\u4e00\u5757\u5bf9\u5185\u7f51\uff0c\u90a3\u4e48\u8fd9\u4e24\u5757\u7f51\u5361\u5728\u5ba1\u67e5\u6d41\u91cf\u65f6\u6240\u7528\u7684\u7b56\u7565\u80af\u5b9a\u4e5f\u662f\u4e0d\u4e00\u81f4\u7684\u3002\u56e0\u6b64\uff0c\u53ef\u4ee5\u6839\u636e\u7f51\u5361\u9488\u5bf9\u7684\u6d41\u91cf\u6765\u6e90\uff0c\u4e3a\u7f51\u5361\u7ed1\u5b9a\u4e0d\u540c\u7684\u533a\u57df\uff0c\u5b9e\u73b0\u5bf9\u9632\u706b\u5899\u7b56\u7565\u7684\u7075\u6d3b\u7ba1\u63a7\u3002<\/p>\n

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

3\uff0e\u628a\u7f51\u5361\u9ed8\u8ba4\u533a\u57df\u4fee\u6539\u4e3aexternal\uff0c\u5e76\u5728\u7cfb\u7edf\u91cd\u542f\u540e\u751f\u6548\u3002<\/strong><\/p>\n

[root@linuxprobe ~]# firewall-cmd --permanent --zone=external --change-interface=ens160\r\nThe interface is under control of NetworkManager, setting zone to 'external'.\r\nsuccess\r\n[root@linuxprobe ~]# firewall-cmd --permanent --get-zone-of-interface=ens160\r\nexternal<\/pre>\n

4\uff0e\u628afirewalld\u670d\u52a1\u7684\u9ed8\u8ba4\u533a\u57df\u8bbe\u7f6e\u4e3apublic\u3002<\/strong><\/p>\n

\u9ed8\u8ba4\u533a\u57df\u4e5f\u53eb\u5168\u5c40\u914d\u7f6e\uff0c\u6307\u7684\u662f\u5bf9\u6240\u6709\u7f51\u5361\u90fd\u751f\u6548\u7684\u914d\u7f6e\uff0c\u4f18\u5148\u7ea7\u8f83\u4f4e\u3002\u5728\u4e0b\u9762\u7684\u4ee3\u7801\u4e2d\u53ef\u4ee5\u770b\u5230\uff0c\u5f53\u524d\u9ed8\u8ba4\u533a\u57df\u4e3apublic\uff0c\u800cens160\u7f51\u5361\u7684\u533a\u57df\u4e3aexternal\u3002\u6b64\u65f6\u4fbf\u662f\u4ee5\u7f51\u5361\u7684\u533a\u57df\u540d\u79f0\u4e3a\u51c6\u3002<\/p>\n

\u901a\u4fd7\u6765\u8bf4\uff0c\u9ed8\u8ba4\u533a\u57df\u5c31\u662f\u4e00\u79cd\u901a\u7528\u7684\u653f\u7b56\u3002\u4f8b\u5982\uff0c\u98df\u5802\u4e3a\u6240\u6709\u4eba\u51c6\u5907\u4e86\u4e00\u6b21\u6027\u9910\u5177\uff0c\u800c\u73af\u4fdd\u4e3b\u4e49\u8005\u5219\u4f1a\u81ea\u5df1\u643a\u5e26\u7897\u7b77\u3002\u5982\u679c\u60a8\u81ea\u5e26\u4e86\u7897\u7b77\uff0c\u5c31\u53ef\u4ee5\u7528\u81ea\u5df1\u7684\uff1b\u53cd\u4e4b\u5c31\u7528\u98df\u5802\u7edf\u4e00\u63d0\u4f9b\u7684\u3002<\/p>\n

[root@linuxprobe ~]# firewall-cmd --set-default-zone=public\r\nWarning: ZONE_ALREADY_SET: public\r\nsuccess\r\n[root@linuxprobe ~]# firewall-cmd --get-default-zone \r\npublic\r\n[root@linuxprobe ~]# firewall-cmd --get-zone-of-interface=ens160\r\nexterna\r\n<\/pre>\n

5\uff0e\u542f\u52a8\u548c\u5173\u95edfirewalld\u9632\u706b\u5899\u670d\u52a1\u7684\u5e94\u6025\u72b6\u51b5\u6a21\u5f0f\u3002<\/strong><\/p>\n

\u5982\u679c\u60f3\u57281s\u7684\u65f6\u95f4\u5185\u963b\u65ad\u4e00\u5207\u7f51\u7edc\u8fde\u63a5\uff0c\u6709\u4ec0\u4e48\u597d\u529e\u6cd5\u5462\uff1f\u5927\u5bb6\u4e0b\u610f\u8bc6\u5730\u4f1a\u8bf4\uff1a\u201c\u62d4\u6389\u7f51\u7ebf\uff01\u201d\u8fd9\u662f\u4e00\u4e2a\u7269\u7406\u7ea7\u522b\u7684\u9ad8\u62db\u3002\u4f46\u662f\uff0c\u5982\u679c\u4eba\u5728\u5317\u4eac\uff0c\u670d\u52a1\u5668\u5728\u5f02\u5730\u5462\uff1fpanic\u7d27\u6025\u6a21\u5f0f\u5728\u8fd9\u4e2a\u65f6\u5019\u5c31\u6d3e\u4e0a\u7528\u573a\u4e86\u3002\u4f7f\u7528--panic-on\u53c2\u6570\u4f1a\u7acb\u5373\u5207\u65ad\u4e00\u5207\u7f51\u7edc\u8fde\u63a5\uff0c\u800c\u4f7f\u7528--panic-off\u5219\u4f1a\u6062\u590d\u7f51\u7edc\u8fde\u63a5\u3002\u5207\u8bb0\uff0c\u7d27\u6025\u6a21\u5f0f\u4f1a\u5207\u65ad\u4e00\u5207\u7f51\u7edc\u8fde\u63a5\uff0c\u56e0\u6b64\u5728\u8fdc\u7a0b\u7ba1\u7406\u670d\u52a1\u5668\u65f6\uff0c\u5728\u6309\u4e0b\u56de\u8f66\u952e\u524d\u4e00\u5b9a\u8981\u4e09\u601d\u3002<\/p>\n

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

6\uff0e\u67e5\u8be2SSH\u548cHTTPS\u534f\u8bae\u7684\u6d41\u91cf\u662f\u5426\u5141\u8bb8\u653e\u884c\u3002<\/strong><\/p>\n

\u5728\u5de5\u4f5c\u4e2d\u53ef\u4ee5\u4e0d\u4f7f\u7528--zone\u53c2\u6570\u6307\u5b9a\u533a\u57df\u540d\u79f0\uff0cfirewall-cmd\u547d\u4ee4\u4f1a\u81ea\u52a8\u4f9d\u636e\u9ed8\u8ba4\u533a\u57df\u8fdb\u884c\u67e5\u8be2\uff0c\u4ece\u800c\u51cf\u5c11\u7528\u6237\u8f93\u5165\u91cf\u3002\u4f46\u662f\uff0c\u5982\u679c\u9ed8\u8ba4\u533a\u57df\u4e0e\u7f51\u5361\u6240\u7ed1\u5b9a\u7684\u4e0d\u4e00\u81f4\u65f6\uff0c\u5c31\u4f1a\u53d1\u751f\u51b2\u7a81\uff0c\u56e0\u6b64\u89c4\u8303\u5199\u6cd5\u7684zone\u53c2\u6570\u662f\u4e00\u5b9a\u8981\u52a0\u7684\u3002<\/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

7\uff0e\u628aHTTPS\u534f\u8bae\u7684\u6d41\u91cf\u8bbe\u7f6e\u4e3a\u6c38\u4e45\u5141\u8bb8\u653e\u884c\uff0c\u5e76\u7acb\u5373\u751f\u6548\u3002<\/strong><\/p>\n

\u9ed8\u8ba4\u60c5\u51b5\u4e0b\u8fdb\u884c\u7684\u4fee\u6539\u90fd\u5c5e\u4e8eRuntime\u6a21\u5f0f\uff0c\u5373\u5f53\u524d\u751f\u6548\u800c\u91cd\u542f\u540e\u5931\u6548\uff0c\u56e0\u6b64\u5728\u5de5\u4f5c\u548c\u8003\u8bd5\u4e2d\u5c3d\u91cf\u907f\u514d\u4f7f\u7528\u3002\u800c\u5728\u4f7f\u7528--permanent\u53c2\u6570\u65f6\uff0c\u5219\u662f\u5f53\u524d\u4e0d\u4f1a\u7acb\u5373\u770b\u5230\u6548\u679c\uff0c\u800c\u5728\u91cd\u542f\u6216\u91cd\u65b0\u52a0\u8f7d\u540e\u65b9\u53ef\u751f\u6548\u3002\u4e8e\u662f\uff0c\u5728\u6dfb\u52a0\u4e86\u5141\u8bb8\u653e\u884cHTTPS\u6d41\u91cf\u7684\u7b56\u7565\u540e\uff0c\u67e5\u8be2\u5f53\u524d\u6a21\u5f0f\u7b56\u7565\uff0c\u53d1\u73b0\u4f9d\u7136\u662f\u4e0d\u5141\u8bb8\u653e\u884cHTTPS\u534f\u8bae\u7684\u6d41\u91cf\uff1a<\/p>\n

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

\u4e0d\u60f3\u91cd\u542f\u670d\u52a1\u5668\u7684\u8bdd\uff0c\u5c31\u7528--reload\u53c2\u6570\u5427\uff1a<\/p>\n

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

8\uff0e\u628aHTTP\u534f\u8bae\u7684\u6d41\u91cf\u8bbe\u7f6e\u4e3a\u6c38\u4e45\u62d2\u7edd\uff0c\u5e76\u7acb\u5373\u751f\u6548\u3002<\/strong><\/p>\n

\u7531\u4e8e\u5728\u9ed8\u8ba4\u60c5\u51b5\u4e0bHTTP\u534f\u8bae\u7684\u6d41\u91cf\u5c31\u6ca1\u6709\u88ab\u5141\u8bb8\uff0c\u6240\u4ee5\u4f1a\u6709\u201cWarning: NOT_ENABLED: http\u201d\u8fd9\u6837\u7684\u63d0\u793a\u4fe1\u606f\uff0c\u56e0\u6b64\u5bf9\u5b9e\u9645\u64cd\u4f5c\u6ca1\u6709\u5f71\u54cd\u3002<\/p>\n

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

9\uff0e\u628a\u8bbf\u95ee8080\u548c8081\u7aef\u53e3\u7684\u6d41\u91cf\u7b56\u7565\u8bbe\u7f6e\u4e3a\u5141\u8bb8\uff0c\u4f46\u4ec5\u9650\u5f53\u524d\u751f\u6548\u3002<\/strong><\/p>\n

[root@linuxprobe ~]# firewall-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

10\uff0e\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\u3002<\/strong><\/p>\n

\u7b2c9\u7ae0\u4ecb\u7ecd\u7684SSH\u8fdc\u7a0b\u63a7\u5236\u534f\u8bae\u662f\u57fa\u4e8eTCP\/22\u7aef\u53e3\u4f20\u8f93\u63a7\u5236\u6307\u4ee4\u7684\uff0c\u5982\u679c\u60f3\u8ba9\u7528\u6237\u901a\u8fc7\u5176\u4ed6\u7aef\u53e3\u53f7\u4e5f\u80fd\u8bbf\u95eessh\u670d\u52a1\uff0c\u5c31\u53ef\u4ee5\u8bd5\u8bd5\u7aef\u53e3\u8f6c\u53d1\u6280\u672f\u4e86\u3002\u901a\u8fc7\u8fd9\u9879\u6280\u672f\uff0c\u65b0\u7684\u7aef\u53e3\u53f7\u5728\u6536\u5230\u7528\u6237\u8bf7\u6c42\u540e\u4f1a\u81ea\u52a8\u8f6c\u53d1\u5230\u539f\u672c\u670d\u52a1\u7684\u7aef\u53e3\u4e0a\uff0c\u4f7f\u5f97\u7528\u6237\u80fd\u591f\u901a\u8fc7\u65b0\u7684\u7aef\u53e3\u8bbf\u95ee\u5230\u539f\u672c\u7684\u670d\u52a1\u3002<\/p>\n

\u6765\u4e3e\u4e2a\u4f8b\u5b50\u5e2e\u52a9\u5927\u5bb6\u7406\u89e3\u3002\u5047\u8bbe\u5c0f\u5f3a\u662f\u7535\u5b50\u5382\u7684\u5de5\u4eba\uff0c\u4ed6\u559c\u6b22\u4e0a\u4e86\u4e09\u53f7\u6d41\u6c34\u7ebf\u4e0a\u7684\u5de5\u4eba\u5c0f\u82b1\uff0c\u4f46\u4e0d\u597d\u610f\u601d\u8868\u767d\uff0c\u4e8e\u662f\u5199\u4e86\u4e00\u5c01\u60c5\u4e66\u5e76\u4ea4\u7ed9\u95e8\u536b\u5f20\u5927\u7237\uff0c\u5e0c\u671b\u7531\u5f20\u5927\u7237\u8f6c\u4ea4\u7ed9\u5c0f\u82b1\u3002\u8fd9\u6837\u4e00\u6765\uff0c\u60c5\u4e66\uff08\u4fe1\u606f\uff09\u7684\u4f20\u8f93\u7531\u4ece\u5c0f\u5f3a\u5230\u5c0f\u82b1\uff0c\u53d8\u6210\u4e86\u5c0f\u5f3a\u5230\u5f20\u5927\u7237\u518d\u5230\u5c0f\u82b1\uff0c\u60c5\u4e66\uff08\u4fe1\u606f\uff09\u4f9d\u7136\u80fd\u987a\u5229\u9001\u8fbe\u3002<\/p>\n

\u4f7f\u7528firewall-cmd\u547d\u4ee4\u5b9e\u73b0\u7aef\u53e3\u8f6c\u53d1\u7684\u683c\u5f0f\u6709\u70b9\u957f\uff0c\u8fd9\u91cc\u4e3a\u5927\u5bb6\u603b\u7ed3\u597d\u4e86\uff1a<\/p>\n

firewall-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

\u4e0a\u8ff0\u547d\u4ee4\u4e2d\u7684\u76ee\u6807IP\u5730\u5740\u4e00\u822c\u662f\u670d\u52a1\u5668\u672c\u673a\u7684IP\u5730\u5740\uff1a<\/p>\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\uff0c\u8bbf\u95ee\u6210\u529f\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 2021 from 192.168.10.10<\/pre>\n

11\uff0e<\/strong>\u5bcc\u89c4\u5219\u7684\u8bbe\u7f6e\u3002<\/p>\n

\u5bcc\u89c4\u5219\u4e5f\u53eb\u590d\u89c4\u5219\uff0c\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
\n
\n

Tips<\/strong><\/h3>\n<\/div>\n
\n

\u201c\u4e00\u4e2a\u7537\u4eba\u201d\u548c\u201c\u4e00\u4e2a\u9ad8\u4e2a\u5b50\u3001\u5927\u773c\u775b\u3001\u8138\u53f3\u4fa7\u6709\u4e2a\u9152\u7a9d\u7684\u7537\u4eba\u201d\u76f8\u6bd4\uff0c\u5f88\u660e\u663e\u540e\u8005\u7684\u63cf\u8ff0\u66f4\u52a0\u7cbe\u51c6\uff0c\u51cf\u5c11\u4e86\u9519\u8bef\u5339\u914d\u7684\u6982\u7387\uff0c\u5e94\u8be5\u4f18\u5148\u5339\u914d\u3002<\/p>\n<\/div>\n<\/div>\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\u5b66\u4e60\u8bf7\u52a0\u8bfb\u8005\u7fa4\uff08\u63a8\u8350<\/span><\/strong>\uff09\uff1ahttps:\/\/gulass.cn\/club<\/a><\/p>\n

*\u672c\u7fa4\u7279\u8272\uff1a\u786e\u4fdd\u6bcf\u4e00\u4f4d\u7fa4\u53cb\u90fd\u662f\u300aLinux\u5c31\u8be5\u8fd9\u4e48\u5b66\u300b\u7684\u8bfb\u8005\uff0c\u7b54\u7591\u66f4\u6709\u9488\u5bf9\u6027\uff0c\u4e0d\u5b9a\u671f\u9886\u53d6\u5b9a\u5236\u793c\u54c1\u3002<\/p><\/blockquote>\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\u5730\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 8\u4e2d\u7684\u9632\u706b\u5899\u7b56\u7565\u3002\u4f46\u5728\u9ed8\u8ba4\u60c5\u51b5\u4e0b\u7cfb\u7edf\u5e76\u6ca1\u6709\u63d0\u4f9bfirewall-config\u547d\u4ee4\uff0c\u6211\u4eec\u9700\u8981\u81ea\u884c\u7528dnf\u547d\u4ee4\u8fdb\u884c\u5b89\u88c5\uff0c\u6240\u4ee5\u9700\u8981\u5148\u914d\u7f6e\u8f6f\u4ef6\u4ed3\u5e93\u3002<\/p>\n

\u9996\u5148\u5c06\u865a\u62df\u673a\u7684\u201cCD\/DVD\uff08SATA\uff09\u201d\u5149\u76d8\u9009\u9879\u8bbe\u7f6e\u4e3a\u201c\u4f7f\u7528ISO\u6620\u50cf\u6587\u4ef6\u201d\uff0c\u7136\u540e\u9009\u62e9\u5df2\u7ecf\u4e0b\u8f7d\u597d\u7684\u7cfb\u7edf\u955c\u50cf\uff0c\u5982\u56fe8-2\u6240\u793a\u3002<\/p>\n

\u968f\u4e66\u914d\u5957\u7684\u8f6f\u4ef6\u8d44\u6e90\u8bf7\u5728\u8fd9\u91cc\u4e0b\u8f7d\uff1a<\/strong><\/span>https:\/\/gulass.cn\/tools\/<\/a><\/p>\n

RedHatEnterpriseLinux [RHEL]8.0\u2014\u2014\u7ea2\u5e3d\u64cd\u4f5c\u7cfb\u7edf<\/span>\uff08\u5fc5\u9700\uff09<\/span>\uff1a<\/strong><\/p>\n

\u7531\u5f00\u6e90\u8f6f\u4ef6\u53ca\u5168\u7403\u670d\u52a1\u6027\u7cfb\u7edf\u5f00\u53d1\u5546\u7ea2\u5e3d\u516c\u53f8\u51fa\u54c1\uff0c\u6700\u7a33\u5b9a\u51fa\u8272\u7684Linux\u64cd\u4f5c\u7cfb\u7edf\u3002<\/p>\n

\u57f9\u8bad\u8bfe\u7a0b\u4ecb\u7ecd\u89c6\u9891\uff1ahttps:\/\/gulass.cn\/training<\/a><\/strong><\/span><\/p><\/blockquote>\n

\"\"<\/p>\n

8-2 \u00a0\u5c06\u865a\u62df\u673a\u7684\u5149\u76d8\u8bbe\u5907\u6307\u5411ISO\u955c\u50cf<\/p>\n

\n
\n

Tips<\/strong><\/h3>\n<\/div>\n
\n

\u4e0b\u8f7d\u540e\u7684\u7cfb\u7edf\u955c\u50cf\u662f\u4ee5.iso\u7ed3\u5c3e\u7684\u6587\u4ef6\uff0c\u9009\u4e2d\u5373\u53ef\uff0c\u65e0\u987b\u89e3\u538b\u3002<\/p>\n<\/div>\n<\/div>\n

\u7136\u540e\uff0c\u628a\u5149\u76d8\u8bbe\u5907\u4e2d\u7684\u7cfb\u7edf\u955c\u50cf\u6302\u8f7d\u5230\/media\/cdrom\u76ee\u5f55\uff1a<\/p>\n

[root@linuxprobe ~]# mkdir -p \/media\/cdrom\r\n[root@linuxprobe ~]# mount \/dev\/cdrom \/media\/cdrom\r\nmount: \/media\/cdrom: WARNING: device write-protected, mounted read-only.\r\n<\/pre>\n

\u4e3a\u4e86\u80fd\u591f\u8ba9\u8f6f\u4ef6\u4ed3\u5e93\u4e00\u76f4\u4e3a\u7528\u6237\u63d0\u4f9b\u670d\u52a1\uff0c\u66f4\u52a0\u4e25\u8c28\u7684\u505a\u6cd5\u662f\u5c06\u7cfb\u7edf\u955c\u50cf\u6587\u4ef6\u7684\u6302\u8f7d\u4fe1\u606f\u5199\u5165\u5230\/etc\/fstab\u6587\u4ef6\u4e2d\uff0c\u4ee5\u4fdd\u8bc1\u4e07\u65e0\u4e00\u5931\uff1a<\/p>\n

[root@linuxprobe ~]# vim \/etc\/fstab\r\n#\r\n# \/etc\/fstab\r\n# Created by anaconda on Tue Jul 21 05:03:40 2021\r\n#\r\n# Accessible filesystems, by reference, are maintained under '\/dev\/disk\/'.\r\n# See man pages fstab(5), findfs(8), mount(8) and\/or blkid(8) for more info.\r\n#\r\n# After editing this file, run 'systemctl daemon-reload' to update systemd\r\n# units generated from this file.\r\n#\r\n\/dev\/mapper\/rhel-root                       \/                  xfs       defaults        0 0\r\nUUID=2db66eb4-d9c1-4522-8fab-ac074cd3ea0b   \/boot              xfs       defaults        0 0\r\n\/dev\/mapper\/rhel-swap                       swap               swap      defaults        0 0\r\n\/dev\/cdrom                                  \/media\/cdrom       iso9660   defaults        0 0 <\/strong>\r\n<\/pre>\n

\u6700\u540e\uff0c\u4f7f\u7528Vim\u6587\u672c\u7f16\u8f91\u5668\u521b\u5efa\u8f6f\u4ef6\u4ed3\u5e93\u7684\u914d\u7f6e\u6587\u4ef6\u3002\u4e0e\u4e4b\u524d\u7248\u672c\u7684\u7cfb\u7edf\u4e0d\u540c\uff0cRHEL 8\u9700\u8981\u914d\u7f6e\u4e24\u4e2a\u8f6f\u4ef6\u4ed3\u5e93\uff08\u5373[BaseOS]\u4e0e[AppStream]\uff09\uff0c\u4e14\u7f3a\u4e00\u4e0d\u53ef\u3002\u4e0b\u8ff0\u547d\u4ee4\u4e2d\u7528\u5230\u7684\u5177\u4f53\u53c2\u6570\u7684\u542b\u4e49\uff0c\u53ef\u53c2\u89c14.1.4\u8282\u3002<\/p>\n

[root@linuxprobe ~]# vim \/etc\/yum.repos.d\/rhel8.repo\r\n[BaseOS]\r\nname=BaseOS\r\nbaseurl=file:\/\/\/media\/cdrom\/BaseOS\r\nenabled=1\r\ngpgcheck=0\r\n[AppStream]\r\nname=AppStream\r\nbaseurl=file:\/\/\/media\/cdrom\/AppStream\r\nenabled=1\r\ngpgcheck=0\r\n<\/pre>\n

\u5728\u6b63\u786e\u914d\u7f6e\u5b8c\u8f6f\u4ef6\u4ed3\u5e93\u6587\u4ef6\u540e\uff0c\u5c31\u53ef\u4ee5\u5f00\u59cb\u7528yum\u6216dnf\u547d\u4ee4\u5b89\u88c5\u8f6f\u4ef6\u4e86\u3002\u8fd9\u4e24\u4e2a\u547d\u4ee4\u5728\u5b9e\u9645\u64cd\u4f5c\u4e2d\u9664\u4e86\u540d\u5b57\u4e0d\u540c\u5916\uff0c\u6267\u884c\u65b9\u6cd5\u5b8c\u5168\u4e00\u81f4\uff0c\u5927\u5bb6\u53ef\u968f\u65f6\u7528yum\u6765\u66ff\u4ee3dnf\u547d\u4ee4\u3002\u4e0b\u9762\u5b89\u88c5firewalld\u56fe\u5f62\u7528\u6237\u754c\u9762\u5de5\u5177\uff1a<\/p>\n

[root@linuxprobe ~]# dnf install firewall-config\r\nUpdating Subscription Management repositories.\r\nUnable to read consumer identity\r\nThis system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.\r\nAppStream                                       3.1 MB\/s | 3.2 kB     00:00    \r\nBaseOS                                          2.7 MB\/s | 2.7 kB     00:00    \r\nDependencies resolved.\r\n================================================================================\r\n Package                Arch          Version            Repository        Size\r\n================================================================================\r\nInstalling:\r\n firewall-config        noarch        0.6.3-7.el8        AppStream        157 k\r\n\r\nTransaction Summary\r\n================================================================================\r\nInstall  1 Package\r\n\r\nTotal size: 157 k\r\nInstalled size: 1.1 M\r\nIs this ok [y\/N]: y<\/strong>\r\nDownloading Packages:\r\nRunning transaction check\r\nTransaction check succeeded.\r\nRunning transaction test\r\nTransaction test succeeded.\r\nRunning transaction\r\n  Preparing        :                                                        1\/1 \r\n  Installing       : firewall-config-0.6.3-7.el8.noarch                     1\/1 \r\n  Running scriptlet: firewall-config-0.6.3-7.el8.noarch                     1\/1 \r\n  Verifying        : firewall-config-0.6.3-7.el8.noarch                     1\/1 \r\nInstalled products updated.\r\n\r\nInstalled:\r\n  firewall-config-0.6.3-7.el8.noarch                                            \r\n\r\nComplete!\r\n<\/pre>\n

\u5b89\u88c5\u6210\u529f\u540e\uff0cfirewall-config\u5de5\u5177\u7684\u754c\u9762\u5982\u56fe8-3\u6240\u793a\uff0c\u5176\u529f\u80fd\u5177\u4f53\u5982\u4e0b\u3002<\/p>\n<\/div>\n

\n

1\uff1a<\/strong>\u9009\u62e9\u8fd0\u884c\u65f6\uff08Runtime\uff09\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\uff1a<\/strong>\u4e3b\u673a\u5730\u5740\u7684\u9ed1\u767d\u540d\u5355\u3002<\/p>\n

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

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

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

8\uff1a<\/strong>\u8bbe\u7f6e\u5141\u8bb8\u88ab\u8bbf\u95ee\u7684\u534f\u8bae\u3002<\/p>\n

9\uff1a<\/strong>\u8bbe\u7f6e\u5141\u8bb8\u88ab\u8bbf\u95ee\u7684\u7aef\u53e3\u3002<\/p>\n

10<\/strong>\uff1a\u5f00\u542f\u6216\u5173\u95edSNAT\uff08\u6e90\u7f51\u7edc\u5730\u5740\u8f6c\u6362\uff09\u6280\u672f\u3002<\/p>\n

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

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

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

14<\/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

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

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

\u56fe8-3\u00a0 firewall-config\u7684\u56fe\u5f62\u754c\u9762<\/p>\n

\u9664\u4e86\u56fe8-3\u4e2d\u5217\u51fa\u7684\u529f\u80fd\uff0c\u8fd8\u6709\u7528\u4e8e\u5c06\u7f51\u5361\u4e0e\u533a\u57df\u7ed1\u5b9a\u7684Interfaces\u9009\u9879\uff0c\u4ee5\u53ca\u7528\u4e8e\u5c06IP\u5730\u5740\u4e0e\u533a\u57df\u7ed1\u5b9a\u7684Sources\u9009\u9879\u3002\u53e6\u5916\u518d\u5570\u5506\u4e00\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<\/p>\n

\u4e0b\u9762\u8fdb\u884c\u52a8\u624b\u5b9e\u8df5\u73af\u8282\u3002<\/strong><\/p>\n

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

\"\"<\/div>\n

\u56fe8-4\u00a0 \u5141\u8bb8\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-5\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-6\uff09\u3002\u8fd9\u4e0e\u5728\u547d\u4ee4\u884c\u4e2d\u4f7f\u7528--reload\u53c2\u6570\u7684\u6548\u679c\u4e00\u6837\u3002<\/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\u901a\u8fc7\u5bb6\u4e2d\u7684\u7f51\u5173\u8bbe\u5907\uff08\u65e0\u7ebf\u8def\u7531\u5668\uff09\u8bbf\u95ee\u672c\u4e66\u914d\u5957\u7ad9\u70b9gulass.cn<\/a>\u65f6\uff0c\u5c31\u7528\u5230\u4e86SNAT\u6280\u672f\u3002<\/p>\n

\"\"<\/p>\n

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

\"\"<\/p>\n

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

\u5927\u5bb6\u53ef\u4ee5\u770b\u4e00\u4e0b\u5728\u7f51\u7edc\u4e2d\u4e0d\u4f7f\u7528SNAT\u6280\u672f\uff08\u89c1\u56fe8-7\uff09\u548c\u4f7f\u7528SNAT\u6280\u672f\uff08\u89c1\u56fe8-8\uff09\u65f6\u7684\u60c5\u51b5\u3002\u5728\u56fe8-7\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-8\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-7\u00a0 \u6ca1\u6709\u4f7f\u7528SNAT\u6280\u672f\u7684\u7f51\u7edc<\/p>\n

\"\"<\/div>\n

\u56fe8-8\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-9\u8fdb\u884c\u914d\u7f6e\uff0c\u5e76\u9009\u4e2dMasquerade zone\u590d\u9009\u6846\uff0c\u5c31\u81ea\u52a8\u5f00\u542f\u4e86SNAT\u6280\u672f\u3002<\/p>\n

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

\u56fe8-9\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\u65f6\u7684\u533a\u522b\uff0c\u9488\u5bf9\u524d\u9762\u4f7f\u7528firewall-cmd\u914d\u7f6e\u7684\u9632\u706b\u5899\u7b56\u7565\u89c4\u5219\uff0c\u8fd9\u91cc\u4f7f\u7528firewall-config\u5de5\u5177\u8fdb\u884c\u4e86\u91cd\u65b0\u6f14\u793a\uff1a\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-10\u548c\u56fe8-11\u6240\u793a\u3002<\/p>\n

\"\"<\/p>\n

\n

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

\"\"<\/p>\n

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

\u7528\u547d\u4ee4\u914d\u7f6e\u5bcc\u89c4\u5219\u53ef\u771f\u8f9b\u82e6\uff0c\u5e78\u597d\u6211\u4eec\u73b0\u5728\u6709\u4e86\u56fe\u5f62\u7528\u6237\u754c\u9762\u7684\u5de5\u5177\u3002\u8ba9192.168.10.20\u4e3b\u673a\u8bbf\u95ee\u672c\u673a\u76841234\u7aef\u53e3\u53f7\uff0c\u5982\u56fe8-12\u6240\u793a\u3002\u5176\u4e2dElement\u9009\u9879\u80fd\u591f\u6839\u636e\u670d\u52a1\u540d\u79f0\u3001\u7aef\u53e3\u53f7\u3001\u534f\u8bae\u7b49\u4fe1\u606f\u8fdb\u884c\u5339\u914d\uff1bSource\u4e0eDestination\u9009\u9879\u540e\u7684inverted\u590d\u9009\u6846\u4ee3\u8868\u53cd\u9009\u529f\u80fd\uff0c\u5c06\u5176\u9009\u4e2d\u5219\u4ee3\u8868\u5bf9\u5df2\u586b\u5199\u4fe1\u606f\u8fdb\u884c\u53cd\u9009\uff0c\u5373\u9009\u4e2d\u586b\u5199\u4fe1\u606f\u4ee5\u5916\u7684\u4e3b\u673a\u5730\u5740\uff1bLog\u590d\u9009\u6846\u5728\u9009\u4e2d\u540e\uff0c\u65e5\u5fd7\u4e0d\u4ec5\u4f1a\u88ab\u8bb0\u5f55\u5230\u65e5\u5fd7\u6587\u4ef6\u4e2d\uff0c\u800c\u4e14\u8fd8\u53ef\u4ee5\u5728\u8bbe\u7f6e\u65e5\u5fd7\u7684\u7ea7\u522b\uff08Level\uff09\u540e\uff0c\u518d\u5c06\u65e5\u5fd7\u8bb0\u5f55\u5230\u65e5\u5fd7\u6587\u4ef6\u4e2d\uff0c\u4ee5\u65b9\u4fbf\u540e\u7eed\u7684\u7b5b\u67e5\u3002<\/p>\n

\"\"<\/p>\n

\u56fe8-12 \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-13\u548c\u56fe8-14\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\u6709\u9488\u5bf9\u6027\u7684\u76d1\u63a7\uff0c\u6548\u679c\u4f1a\u66f4\u597d\u3002<\/p>\n

\"\"<\/p>\n

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

\u56fe8-14 \u7f51\u5361\u4e0e\u7b56\u7565\u533a\u57df\u7ed1\u5b9a\u5b8c\u6210<\/p>\n

\u6700\u540e\u518d\u63d0\u4e00\u53e5\uff0cfirewall-config\u5de5\u5177\u771f\u7684\u975e\u5e38\u5b9e\u7528\uff0c\u5f88\u591a\u539f\u672c\u590d\u6742\u7684\u957f\u547d\u4ee4\u88ab\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

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

TCP Wrapper\u662fRHEL 6\/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\u505a\u51fa\u5141\u8bb8\u6216\u62d2\u7edd\u7684\u64cd\u4f5c\u3002\u5728RHEL 8\u7248\u672c\u4e2d\uff0c\u5b83\u5df2\u7ecf\u88abfirewalld\u6b63\u5f0f\u66ff\u4ee3<\/span>\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 Wrapper\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 Wrapper\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\u4f1a\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\u90fd\u6ca1\u6709\u5339\u914d\u5230\uff0c\u5219\u9ed8\u8ba4\u653e\u884c\u6d41\u91cf\u3002<\/p>\n

\u7531\u4e8eRHEL 8\u7248\u672c\u5df2\u7ecf\u4e0d\u518d\u652f\u6301TCP Wrapper\u670d\u52a1\u7a0b\u5e8f\uff0c\u56e0\u6b64\u6211\u4eec\u63a5\u4e0b\u6765\u9009\u62e9\u5728\u4e00\u53f0\u8001\u7248\u672c\u7684\u670d\u52a1\u5668\u4e0a\u8fdb\u884c\u5b9e\u9a8c<\/span>\u3002TCP Wrapper\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.gulass.cn<\/td>\n\u6240\u6709DNS\u540e\u7f00\u4e3a.gulass.cn\u7684\u4e3b\u673a<\/td>\n<\/tr>\n
\u6307\u5b9a\u4e3b\u673a\u540d\u79f0<\/td>\ngulass.cn<\/td>\n\u4e3b\u673a\u540d\u79f0\u4e3agulass.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 Wrapper\u670d\u52a1\u65f6\u9700\u8981\u9075\u5faa\u4e24\u4e2a\u539f\u5219\uff1a<\/p>\n

\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<\/p>\n

\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<\/p><\/blockquote>\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\u4fee\u6539\/etc\/hosts.deny\u6587\u4ef6\u4e2d\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\u4e14\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<\/strong>\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 2021\r\n[root@linuxprobe ~]# \r\n<\/pre>\n
\n
8.5 Cockpit\u9a7e\u9a76\u8231\u7ba1\u7406\u5de5\u5177<\/strong><\/span><\/h5>\n

\u9996\u5148\uff0cCockpit\u662f\u4e00\u4e2a\u82f1\u6587\u5355\u8bcd\uff0c\u5373\u201c\uff08\u98de\u673a\u3001\u8239\u6216\u8d5b\u8f66\u7684\uff09\u9a7e\u9a76\u8231\u3001\u9a7e\u9a76\u5ea7\u201d\uff08\u89c1\u56fe8-15\uff09\uff0c\u5b83\u7528\u540d\u5b57\u4f20\u8fbe\u51fa\u4e86\u529f\u80fd\u4e30\u5bcc\u7684\u7279\u6027\u3002\u5176\u6b21\uff0cCockpit\u662f\u4e00\u4e2a\u57fa\u4e8eWeb\u7684\u56fe\u5f62\u5316\u670d\u52a1\u7ba1\u7406\u5de5\u5177\uff0c\u5bf9\u7528\u6237\u76f8\u5f53\u53cb\u597d\uff0c\u5373\u4fbf\u662f\u65b0\u624b\u4e5f\u53ef\u4ee5\u8f7b\u677e\u4e0a\u624b\u3002\u800c\u4e14\u5b83\u5929\u7136\u5177\u5907\u5f88\u597d\u7684\u8de8\u5e73\u53f0\u6027\uff0c\u56e0\u6b64\u88ab\u5e7f\u6cdb\u5e94\u7528\u4e8e\u670d\u52a1\u5668\u3001\u5bb9\u5668\u3001\u865a\u62df\u673a\u7b49\u591a\u79cd\u7ba1\u7406\u573a\u666f\u3002\u6700\u540e\uff0c\u7ea2\u5e3d\u516c\u53f8\u5bf9Cockpit\u4e5f\u5341\u5206\u770b\u91cd\uff0c\u76f4\u63a5\u5c06\u5b83\u9ed8\u8ba4\u5b89\u88c5\u5230\u4e86RHEL 8\u7cfb\u7edf\u4e2d\uff0c\u7531\u6b64\u884d\u751f\u7684CentOS\u548cFedora\u4e5f\u90fd\u6807\u914d\u6709Cockpit\u3002<\/p>\n

\"\"<\/p>\n

\u56fe8-15\u00a0 \u9a7e\u9a76\u8231\u793a\u610f\u56fe<\/p>\n

Cockpit\u5728\u9ed8\u8ba4\u60c5\u51b5\u4e0b\u5c31\u5df2\u7ecf\u88ab\u5b89\u88c5\u5230\u7cfb\u7edf\u4e2d\u3002\u4e0b\u9762\u6267\u884cdnf\u547d\u4ee4\u5bf9\u6b64\u8fdb\u884c\u786e\u8ba4\uff1a<\/p>\n

[root@linuxprobe ~]# dnf install cockpit\r\nUpdating Subscription Management repositories.\r\nUnable to read consumer identity\r\nThis system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.\r\nAppStream                                       3.1 MB\/s | 3.2 kB     00:00    \r\nBaseOS                                          2.7 MB\/s | 2.7 kB     00:00    \r\nPackage cockpit-185-2.el8.x86_64 is already installed.\r\nDependencies resolved.\r\nNothing to do.\r\nComplete!\r\n<\/pre>\n<\/div>\n

\u4f46\u662f\uff0cCockpit\u670d\u52a1\u7a0b\u5e8f\u5728RHEL 8\u7248\u672c\u4e2d\u6ca1\u6709\u81ea\u52a8\u8fd0\u884c\uff0c\u4e0b\u9762\u5c06\u5b83\u5f00\u542f\u5e76\u52a0\u5165\u5230\u5f00\u673a\u542f\u52a8\u9879\u4e2d\uff1a<\/p>\n<\/div>\n

[root@linuxprobe ~]# systemctl start cockpit\r\n[root@linuxprobe ~]# systemctl enable cockpit.socket\r\nCreated symlink \/etc\/systemd\/system\/sockets.target.wants\/cockpit.socket \u2192 \/usr\/lib\/systemd\/system\/cockpit.socket.<\/pre>\n
\n

\u5728Cockpit\u670d\u52a1\u542f\u52a8\u540e\uff0c\u6253\u5f00\u7cfb\u7edf\u81ea\u5e26\u7684\u6d4f\u89c8\u5668\uff0c\u5728\u5730\u5740\u680f\u4e2d\u8f93\u5165\u201c\u672c\u673a\u5730\u5740:9090\u201d\u5373\u53ef\u8bbf\u95ee\u3002\u7531\u4e8e\u8bbf\u95eeCockpit\u7684\u6d41\u91cf\u4f1a\u4f7f\u7528HTTPS\u8fdb\u884c\u52a0\u5bc6\uff0c\u800c\u8bc1\u4e66\u53c8\u662f\u5728\u672c\u5730\u7b7e\u53d1\u7684\uff0c\u56e0\u6b64\u8fd8\u9700\u8981\u8fdb\u884c\u6dfb\u52a0\u5e76\u4fe1\u4efb\u672c\u5730\u8bc1\u4e66\u7684\u64cd\u4f5c\uff0c\u5982\u56fe8-16\u4e0e\u56fe8-17\u6240\u793a\u3002\u8fdb\u5165Cockpit\u7684\u767b\u5f55\u754c\u9762\u540e\uff0c\u8f93\u5165root\u7ba1\u7406\u5458\u7684\u8d26\u53f7\u4e0e\u7cfb\u7edf\u5bc6\u7801\uff0c\u5355\u51fbLog In\u6309\u94ae\u540e\u5373\u53ef\u8fdb\u5165\uff0c\u5982\u56fe8-18\u6240\u793a\u3002<\/p>\n

\u8fdb\u5165Cockpit\u7684Web\u754c\u9762\uff0c\u53d1\u73b0\u91cc\u9762\u53ef\u8c13\u201c\u522b\u6709\u6d1e\u5929\u201d\u3002Cockpit\u603b\u5171\u5206\u4e3a13\u4e2a\u529f\u80fd\u6a21\u5757\uff1a\u7cfb\u7edf\u72b6\u6001\uff08System\uff09\u3001\u65e5\u5fd7\u4fe1\u606f\uff08Logs\uff09\u3001\u786c\u76d8\u5b58\u50a8\uff08Storage\uff09\u3001\u7f51\u5361\u7f51\u7edc\uff08Networking\uff09\u3001\u8d26\u6237\u5b89\u5168\uff08Accounts\uff09\u3001\u670d\u52a1\u7a0b\u5e8f\uff08Services\uff09\u3001\u8f6f\u4ef6\u4ed3\u5e93\uff08Applications\uff09\u3001\u62a5\u544a\u5206\u6790\uff08Diagnostic Reports\uff09\u3001\u5185\u6838\u6392\u9519\uff08Kernel Dump\uff09\u3001SElinux\u3001\u66f4\u65b0\u8f6f\u4ef6\uff08Software Updates\uff09\u3001\u8ba2\u9605\u670d\u52a1\uff08Subscriptions\uff09\u3001\u7ec8\u7aef\u754c\u9762\uff08Terminal\uff09\u3002\u4e0b\u9762\u9010\u4e00\u8fdb\u884c\u8bb2\u89e3\u3002<\/p>\n

\"\"<\/p>\n

\u56fe8-16 \u6dfb\u52a0\u989d\u5916\u5141\u8bb8\u7684\u8bc1\u4e66<\/p>\n

\"\"<\/p>\n

\u56fe8-17 \u786e\u8ba4\u4fe1\u4efb\u672c\u5730\u8bc1\u4e66<\/p>\n

\"\"<\/p>\n

\u56fe8-18 \u8f93\u5165\u767b\u5f55\u8d26\u53f7\u4e0e\u7cfb\u7edf\u5bc6\u7801<\/p>\n

\u8fdb\u5165\u5230Cockpit\u7f51\u9875\u754c\u9762\u540e\u53ef\u8c13\u662f\u522b\u6709\u6d1e\u5929\uff0c\u603b\u5171\u5206\u4e3a\u5341\u4e09\u4e2a\u529f\u80fd\u6a21\u5757\uff0c\u5373\uff1a\u7cfb\u7edf\u72b6\u6001\u3001\u65e5\u5fd7\u4fe1\u606f\u3001\u786c\u76d8\u5b58\u50a8\u3001\u7f51\u5361\u7f51\u7edc\u3001\u8d26\u6237\u5b89\u5168\u3001\u670d\u52a1\u7a0b\u5e8f\u3001\u8f6f\u4ef6\u4ed3\u5e93\u3001\u62a5\u544a\u5206\u6790\u3001\u5185\u6838\u6392\u9519\u3001SElinux\u3001\u66f4\u65b0\u8f6f\u4ef6\u3001\u8ba2\u9605\u670d\u52a1\u3001\u7ec8\u7aef\u754c\u9762\u3002\u9010\u4e00\u4e3a\u540c\u5b66\u4eec\u8fdb\u884c\u8bb2\u89e3\u3002<\/p>\n

1\uff0eSystem<\/strong><\/p>\n

\u8fdb\u5165Cockpit\u754c\u9762\u540e\u9ed8\u8ba4\u663e\u793a\u7684\u4fbf\u662fSystem\uff08\u7cfb\u7edf\uff09\u754c\u9762\uff0c\u5728\u8be5\u754c\u9762\u4e2d\u80fd\u591f\u770b\u5230\u7cfb\u7edf\u67b6\u6784\u3001\u7248\u672c\u3001\u4e3b\u673a\u540d\u4e0e\u65f6\u95f4\u7b49\u4fe1\u606f\uff0c\u8fd8\u80fd\u591f\u52a8\u6001\u5730\u5c55\u73b0\u51faCPU\u3001\u786c\u76d8\u3001\u5185\u5b58\u548c\u7f51\u7edc\u7684\u590d\u6742\u60c5\u51b5\uff0c\u8fd9\u6709\u70b9\u7c7b\u4f3c\u4e8eWeb\u7248\u7684\u201cWinodws\u7cfb\u7edf\u4efb\u52a1\u7ba1\u7406\u5668\u201d\uff0c\u5c5e\u5b9e\u597d\u7528\uff0c\u5982\u56fe8-19\u6240\u793a\u3002<\/p>\n

\"\"<\/p>\n

\u56fe8-19 \u7cfb\u7edf\u72b6\u6001\u754c\u9762<\/p>\n

2\uff0eLogs<\/strong><\/p>\n

\u8fd9\u4e2a\u6a21\u5757\u80fd\u591f\u63d0\u4f9b\u7cfb\u7edf\u7684\u5168\u90e8\u65e5\u5fd7\uff0c\u4f46\u662f\u540c\u5b66\u4eec\u53ef\u80fd\u4f1a\u597d\u5947\uff0c\u201c\u4e3a\u4ec0\u4e48\u56fe8-20\u4e2d\u7684\u5185\u5bb9\u8fd9\u4e48\u6709\u9650\u5462\u201d\uff1f\u539f\u56e0\u51fa\u5728\u56fe8-20\u4e2d\u7684\u4e24\u4e2a\u9009\u9879\u4e2d\uff1a\u65f6\u95f4\u548c\u65e5\u5fd7\u7ea7\u522b\u3002\u901a\u8fc7\u8fd9\u4e24\u4e2a\u9009\u9879\u53ef\u4ee5\u8ba9\u7528\u6237\u66f4\u5feb\u5730\u627e\u5230\u6240\u9700\u4fe1\u606f\uff0c\u800c\u4e0d\u662f\u50cf\/var\/log\/message\u6587\u4ef6\u90a3\u6837\u4e00\u80a1\u8111\u513f\u5730\u90fd\u629b\u7ed9\u7528\u6237\u3002<\/p>\n

\"\"<\/p>\n

\u56fe8-20 \u65e5\u5fd7\u4fe1\u606f\u754c\u9762<\/p>\n

3\uff0eStorage<\/strong><\/p>\n

\u8fd9\u4e2a\u529f\u80fd\u6a21\u5757\u662f\u540c\u5b66\u4eec\u6700\u559c\u6b22\u7684\u4e00\u4e2a\u6a21\u5757\uff0c\u539f\u56e0\u4e0d\u662f\u8fd9\u4e2a\u6a21\u5757\u663e\u793a\u4e86\u786c\u76d8\u7684I\/O\u8bfb\u5199\u8d1f\u8f7d\u60c5\u51b5\uff0c\u800c\u662f\u53ef\u4ee5\u8ba9\u7528\u6237\u901a\u8fc7\u8be5\u754c\u9762\uff0c\u7528\u9f20\u6807\u521b\u5efa\u51faRAID\u3001LVM\u3001VDO\u548ciSCSI\u7b49\u5b58\u50a8\u8bbe\u5907\uff0c\u5982\u56fe8-21\u6240\u793a\u3002\u662f\u7684\uff0c\u60a8\u6ca1\u6709\u770b\u9519\uff0cRAID\u548cLVM\u90fd\u53ef\u4ee5\u7528\u9f20\u6807\u8fdb\u884c\u521b\u5efa\u4e86\uff0c\u662f\u4e0d\u662f\u5f88\u5f00\u5fc3\u5462\uff1f<\/p>\n

\"\"<\/p>\n

\u56fe8-21 \u786c\u76d8\u5b58\u50a8\u754c\u9762<\/p>\n

4\uff0eNetworking<\/strong><\/p>\n

\u65e2\u7136\u540d\u4e3aNetworking\u6a21\u5757\uff0c\u90a3\u4e48\u52a8\u6001\u770b\u7f51\u5361\u7684\u8f93\u51fa\u548c\u63a5\u6536\u503c\u80af\u5b9a\u662f\u8fd9\u4e2a\u6a21\u5757\u7684\u6807\u914d\u529f\u80fd\u4e86\u3002\u5982\u56fe8-22\u6240\u793a\uff0c\u6211\u4eec\u4e0d\u4ec5\u53ef\u4ee5\u5728\u8fd9\u91cc\u8fdb\u884c\u7f51\u5361\u7684\u7ed1\u5b9a\uff08Bonding\uff09\u548c\u805a\u5408\uff08Team\uff09\uff0c\u8fd8\u53ef\u4ee5\u521b\u5efa\u6865\u63a5\u7f51\u5361\u53ca\u6dfb\u52a0VLAN\u3002\u56fe8-22\u7684\u6700\u4e0b\u65b9\u4f1a\u5355\u72ec\u5217\u51fa\u4e0e\u7f51\u5361\u76f8\u5173\u7684\u65e5\u5fd7\u4fe1\u606f\u3002<\/p>\n

\"\"<\/p>\n

8-22 \u7f51\u5361\u7f51\u7edc\u754c\u9762<\/p>\n

5\uff0e<\/strong>Accounts<\/p>\n

\u5927\u5bb6\u5343\u4e07\u522b\u5c0f\u770bAccounts\u6a21\u5757\uff0c\u867d\u7136\u5b83\u7684\u529f\u80fd\u754c\u9762\u6709\u4e9b\u7b80\u964b\uff08\u89c1\u56fe8-23\uff09\uff0c\u53ea\u6709\u4e00\u4e2a\u7528\u4e8e\u521b\u5efa\u8d26\u6237\u7684\u6309\u94ae\uff0c\u4f46\u53ea\u8981\u70b9\u51fb\u8fdb\u5165\u67d0\u4e2a\u7528\u6237\u7684\u7ba1\u7406\u754c\u9762\u4e2d\uff0c\u9a6c\u4e0a\u4f1a\u53d1\u73b0\u201c\u522b\u6709\u6d1e\u5929\u201d\uff0c\u5982\u56fe8-24\u6240\u793a\u3002\u8fd9\u4e2a\u754c\u9762\u4e2d\u7684\u529f\u80fd\u975e\u5e38\u4e30\u5bcc\uff0c\u6211\u4eec\u5728\u8fd9\u91cc\u53ef\u4ee5\u5bf9\u7528\u6237\u8fdb\u884c\u91cd\u547d\u540d\uff0c\u8bbe\u7f6e\u7528\u6237\u7684\u6743\u9650\uff0c\u8fd8\u53ef\u4ee5\u9501\u5b9a\u3001\u4fee\u6539\u5bc6\u7801\u4ee5\u53ca\u521b\u5efaSSH\u5bc6\u94a5\u4fe1\u606f\u3002<\/p>\n

\"\"<\/p>\n

\u56fe8-23 \u8d26\u6237\u5b89\u5168\u754c\u9762<\/p>\n

\"\"<\/p>\n

\u56fe8-24 \u8d26\u6237\u7ba1\u7406\u754c\u9762<\/p>\n

6\uff0eServices<\/strong><\/p>\n

\u5728Services\u529f\u80fd\u6a21\u5757\u7684\u754c\u9762\u4e2d\uff08\u89c1\u56fe8-25\uff09\uff0c\u53ef\u4ee5\u67e5\u770b\u7cfb\u7edf\u4e2d\u5df2\u6709\u7684\u670d\u52a1\u5217\u8868\u548c\u8fd0\u884c\u72b6\u6001\u3002\u5355\u51fb\u67d0\u4e00\u670d\u52a1\uff0c\u8fdb\u5165\u8be5\u670d\u52a1\u7684\u7ba1\u7406\u754c\u9762\u540e\uff08\u89c1\u56fe8-26\uff09\uff0c\u53ef\u4ee5\u5bf9\u5177\u4f53\u7684\u670d\u52a1\u8fdb\u884c\u5f00\u542f\u3001\u5173\u95ed\u64cd\u4f5c\u3002\u5728Services\u529f\u80fd\u6a21\u5757\u4e2d\u8bbe\u7f6e\u4e86\u670d\u52a1\u5e76\u5c06\u5176\u52a0\u5165\u5230\u5f00\u673a\u542f\u52a8\u9879\u540e\uff0c\u5728\u7cfb\u7edf\u91cd\u542f\u540e\u4e5f\u4f9d\u7136\u4f1a\u4e3a\u7528\u6237\u63d0\u4f9b\u670d\u52a1\u3002<\/p>\n

\"\"<\/p>\n

\u56fe8-25 \u670d\u52a1\u7a0b\u5e8f\u754c\u9762<\/p>\n

\"\"<\/p>\n

\u56fe8-26 \u670d\u52a1\u7ba1\u7406\u754c\u9762<\/p>\n

7\uff0eApplications<\/strong><\/p>\n

\u540e\u671f\u91c7\u7528Cockpit\u6216\u7ea2\u5e3d\u8ba2\u9605\u670d\u52a1\u5b89\u88c5\u7684\u8f6f\u4ef6\u90fd\u4f1a\u663e\u793a\u5728\u8fd9\u4e2a\u529f\u80fd\u6a21\u5757\u4e2d\uff0c\u5982\u56fe8-27\u6240\u793a\u3002<\/p>\n

\"\"<\/p>\n

\u56fe8-27 \u8f6f\u4ef6\u4ed3\u5e93\u754c\u9762<\/p>\n

8\uff0eDiagnostic Report<\/strong><\/p>\n

Diagnostic Report\u6a21\u5757\u7684\u529f\u80fd\u662f\u5e2e\u52a9\u7528\u6237\u6536\u96c6\u53ca\u5206\u6790\u7cfb\u7edf\u7684\u4fe1\u606f\uff0c\u627e\u5230\u7cfb\u7edf\u51fa\u73b0\u95ee\u9898\u7684\u539f\u56e0\uff0c\u754c\u9762\u5982\u56fe8-28\u6240\u793a\u3002\u5355\u51fbCreate Report\u6309\u94ae\u540e\u5927\u7ea6\u4e24\u5206\u949f\u5de6\u53f3\uff0c\u4f1a\u51fa\u73b0\u5982\u56fe8-29\u6240\u793a\u7684\u754c\u9762\u3002\u597d\u5427\uff0c\u644a\u724c\u4e86\uff0c\u8fd9\u4e2a\u529f\u80fd\u5176\u5b9e\u5f88\u9e21\u808b\uff0c\u5c31\u662f\u5c06sosreport\u547d\u4ee4\u505a\u6210\u4e86\u4e00\u4e2a\u7f51\u9875\u6309\u94ae\u3002<\/p>\n

\"\"<\/p>\n

\u56fe8-28 \u62a5\u544a\u5206\u6790\u754c\u9762<\/p>\n

\"\"<\/p>\n

\u56fe8-29 \u62a5\u544a\u751f\u6210\u5b8c\u6bd5<\/p>\n

9\uff0eKernel Dump<\/strong><\/p>\n

Kernel Dump\uff08Kdump\uff09\u662f\u4e00\u4e2a\u5728\u7cfb\u7edf\u5d29\u6e83\u3001\u6b7b\u9501\u6216\u6b7b\u673a\u65f6\u7528\u6765\u6536\u96c6\u5185\u6838\u53c2\u6570\u7684\u4e00\u4e2a\u670d\u52a1\u3002\u4e3e\u4f8b\u6765\u8bf4\uff0c\u5982\u679c\u6709\u4e00\u5929\u7cfb\u7edf\u5d29\u6e83\u4e86\uff0c\u8fd9\u65f6Kdump\u670d\u52a1\u5c31\u4f1a\u5f00\u59cb\u5de5\u4f5c\uff0c\u5c06\u7cfb\u7edf\u7684\u8fd0\u884c\u72b6\u6001\u548c\u5185\u6838\u6570\u636e\u6536\u96c6\u5230\u4e00\u4e2a\u540d\u4e3adump core\u7684\u6587\u4ef6\u4e2d\uff0c\u4ee5\u4fbf\u540e\u7eed\u8ba9\u8fd0\u7ef4\u4eba\u5458\u5206\u6790\u5e76\u627e\u51fa\u95ee\u9898\u6240\u5728\u3002\u7531\u4e8e\u6211\u4eec\u5728\u5b89\u88c5\u7cfb\u7edf\u65f6\u6ca1\u6709\u542f\u52a8\u8be5\u670d\u52a1\uff0c\u6240\u4ee5\u53ef\u4ee5\u7b49\u5230\u540e\u7eed\u4f7f\u7528\u65f6\u518d\u5f00\u542f\u8be5\u529f\u80fd\u754c\u9762\uff08\u89c1\u56fe8-30\uff09\u3002<\/p>\n

\"\"<\/p>\n

\u56fe8-30 \u5185\u6838\u6392\u9519\u754c\u9762<\/p>\n

10\uff0eSElinux<\/strong><\/p>\n

\u56fe8-31\u6240\u793a\u4e3aSELinux\u670d\u52a1\u7684\u63a7\u5236\u6309\u94ae\u548c\u8b66\u544a\u4fe1\u606f\u754c\u9762\uff0c\u7b2c10\u7ae0\u5c06\u8be6\u7ec6\u4ecb\u7ecdSELinux\u5b89\u5168\u5b50\u7cfb\u7edf\uff0c\u8fd9\u91cc\u6682\u65f6\u7565\u8fc7\u3002<\/p>\n

\"\"<\/p>\n

\u56fe8-29 SElinux\u7ba1\u7406\u754c\u9762<\/p>\n

11\uff0eSoftware Updates<\/strong><\/p>\n

Software Updates\u529f\u80fd\u6a21\u5757\u7684\u754c\u9762\u5982\u56fe8-32\u6240\u793a\u3002\u4f46\u662f\uff0c\u8fd9\u91cc\u63d0\u5230\u7684Software Updates\u5e76\u4e0d\u662f\u6211\u4eec\u7528\u6765\u66f4\u65b0\u5176\u4ed6\u5e38\u89c4\u8f6f\u4ef6\u7684\u4e00\u4e2a\u754c\u9762\uff0c\u800c\u662f\u7528\u6765\u5bf9\u7ea2\u5e3d\u5ba2\u6237\u8ba2\u9605\u7684\u670d\u52a1\u8fdb\u884c\u66f4\u65b0\u7684\u754c\u9762\u3002\u7528\u6237\u53ea\u6709\u5728\u8d2d\u4e70\u4e86\u7ea2\u5e3d\u7b2c\u4e09\u65b9\u670d\u52a1\u540e\u624d\u80fd\u4f7f\u7528\u8fd9\u91cc\u9762\u7684\u529f\u80fd\u3002\u5728\u8d2d\u4e70\u4e86\u7ea2\u5e3d\u8ba2\u9605\u670d\u52a1\u540e\uff0c\u7528\u6237\u4fbf\u53ef\u4ee5\u5728\u8fd9\u91cc\u4e0b\u8f7d\u5230\u76f8\u5e94\u670d\u52a1\u7a0b\u5e8f\u7684\u6700\u65b0\u7248\u672c\u548c\u7a33\u5b9a\u7248\u672c\u3002<\/p>\n

\"\"<\/p>\n

\u56fe8-30 \u66f4\u65b0\u8f6f\u4ef6\u754c\u9762<\/p>\n

12\uff0eSubscriptions<\/strong><\/p>\n

Subscriptions\u529f\u80fd\u6a21\u5757\u7684\u754c\u9762\u5982\u56fe8-33\u6240\u793a\u3002\u8fd9\u91cc\u4f9d\u7136\u662f\u4e00\u5219\u7ea2\u5e3d\u516c\u53f8\u7684\u201c\u5c0f\u5e7f\u544a\u201d\u2014\u5982\u679c\u60f3\u6210\u4e3a\u5c0a\u8d35\u7684\u7ea2\u5e3d\u670d\u52a1\u7528\u6237\uff0c\u8981\u4ed8\u8d39\u8d2d\u4e70\u8ba2\u9605\u670d\u52a1\u3002\u4e2a\u4eba\u7528\u6237\u65e0\u987b\u8d2d\u4e70\uff0c\u800c\u4e14\u8fd9\u5bf9\u6211\u4eec\u7684\u540e\u7eed\u5b9e\u9a8c\u6ca1\u6709\u4efb\u4f55\u5f71\u54cd\u3002<\/p>\n

\"\"<\/p>\n

\u56fe8-31 \u8ba2\u9605\u670d\u52a1\u754c\u9762<\/p>\n

13\uff0eTerminal<\/strong><\/p>\n

\u538b\u8f74\u7684\u603b\u662f\u5728\u6700\u540e\u3002Terminal\u529f\u80fd\u6a21\u5757\u7684\u754c\u9762\u5982\u56fe8-34\u6240\u793a\u3002Cockpit\u670d\u52a1\u63d0\u4f9b\u4e86Shell\u7ec8\u7aef\u7684\u5728\u7ebf\u63a7\u5236\u5e73\u53f0\uff0c\u53ef\u65b9\u4fbf\u7528\u6237\u901a\u8fc7\u7f51\u9875\u4e0a\u7684\u7ec8\u7aef\u529f\u80fd\u7ba1\u7406\u670d\u52a1\u5668\u3002\u8fd9\u4e2a\u529f\u80fd\u6df1\u53d7\u8fd0\u7ef4\u4eba\u5458\u559c\u7231\u3002<\/p>\n<\/div>\n

\"\"<\/p>\n

\u56fe8-32 \u7ec8\u7aef\u7ba1\u7406\u754c\u9762<\/p>\n

\u81f3\u6b64\uff0c\u76f8\u4fe1\u5404\u4f4d\u8bfb\u8005\u5df2\u7ecf\u5145\u5206\u638c\u63e1\u4e86\u9632\u706b\u5899\u7684\u7ba1\u7406\u80fd\u529b\u3002\u9632\u706b\u5899\u7ba1\u7406\u5de5\u5177\u6709\u5f88\u591a\u79cd\uff0c\u6211\u4eec\u4efb\u9009\u5176\u4e00\u5373\u53ef\u3002\u5728\u914d\u7f6e\u540e\u7eed\u7684\u670d\u52a1\u524d\uff0c\u5927\u5bb6\u8981\u8bb0\u5f97\u68c0\u67e5\u7f51\u7edc\u548c\u9632\u706b\u5899\u7684\u72b6\u6001\uff0c\u4ee5\u907f\u514d\u51fa\u73b0\u670d\u52a1\u660e\u660e\u914d\u7f6e\u6b63\u786e\uff0c\u4f46\u65e0\u6cd5\u4ece\u5916\u90e8\u8bbf\u95ee\u7684\u60c5\u51b5\uff0c\u6700\u7ec8\u5f71\u54cd\u5b9e\u9a8c\u6548\u679c\u3002<\/p>\n

\u597d\u4e86\uff0c\u4f11\u606f\u4e00\u4e0b\uff0c\u51c6\u5907\u4e0b\u4e00\u7ae0\u7684\u5b66\u4e60\uff01<\/p>\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\u5b66\u4e60\u8bf7\u52a0\u8bfb\u8005\u7fa4\uff08\u63a8\u8350<\/span><\/strong>\uff09\uff1ahttps:\/\/gulass.cn\/club<\/a><\/p>\n

*\u672c\u7fa4\u7279\u8272\uff1a\u786e\u4fdd\u6bcf\u4e00\u4f4d\u7fa4\u53cb\u90fd\u662f\u300aLinux\u5c31\u8be5\u8fd9\u4e48\u5b66\u300b\u7684\u8bfb\u8005\uff0c\u7b54\u7591\u66f4\u6709\u9488\u5bf9\u6027\uff0c\u4e0d\u5b9a\u671f\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

1\uff0e\u5728RHEL 8\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 8\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\u3002<\/span><\/p>\n

9\uff0e\u00a0TCP Wrapper\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 Wrapper\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\uff1b\u5982\u679c\u90fd\u6ca1\u6709\u5339\u914d\u5230\uff0c\u5219\u9ed8\u8ba4\u653e\u884c\u6d41\u91cf\u3002<\/span><\/p>\n

10\uff0e\u9ed8\u8ba4\u60c5\u51b5\u4e0b\u5982\u4f55\u4f7f\u7528Cockpit\u670d\u52a1\uff1f<\/p>\n

\u7b54\uff1a<\/strong>Cockpit\u670d\u52a1\u9ed8\u8ba4\u5360\u75289090\u7aef\u53e3\u53f7\uff0c\u53ef\u76f4\u63a5\u7528\u6d4f\u89c8\u5668\u8bbf\u95eeCockpit\u7684Web\u754c\u9762\u3002<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"

\u7ae0\u8282\u7b80\u8ff0\uff1a \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 […]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[559],"tags":[],"class_list":["post-181461","post","type-post","status-publish","format-standard","hentry","category-rhel8"],"acf":[],"_links":{"self":[{"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/posts\/181461","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/comments?post=181461"}],"version-history":[{"count":97,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/posts\/181461\/revisions"}],"predecessor-version":[{"id":292208,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/posts\/181461\/revisions\/292208"}],"wp:attachment":[{"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/media?parent=181461"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/categories?post=181461"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/tags?post=181461"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}