{"id":18108,"date":"2024-11-18T12:10:07","date_gmt":"2024-11-18T04:10:07","guid":{"rendered":"https:\/\/fwq.ai\/blog\/18108\/"},"modified":"2024-11-18T12:10:07","modified_gmt":"2024-11-18T04:10:07","slug":"linux%e6%80%8e%e4%b9%88%e5%bc%80%e6%94%be%e7%ab%af%e5%8f%a3","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/18108\/","title":{"rendered":"linux\u600e\u4e48\u5f00\u653e\u7aef\u53e3"},"content":{"rendered":"<blockquote><p>\n  \u5728 linux \u7cfb\u7edf\u4e0a\u5f00\u653e\u7aef\u53e3\u7684\u6b65\u9aa4\u5982\u4e0b\uff1a\u786e\u5b9a\u8981\u5f00\u653e\u7684\u7aef\u53e3\u53f7\u3002\u68c0\u67e5\u9632\u706b\u5899\u72b6\u6001\u3002\u5982\u679c\u9632\u706b\u5899\u7981\u7528\uff0c\u5219\u542f\u7528\u5b83\u3002\u4f7f\u7528 firewall-cmd \u547d\u4ee4\u5141\u8bb8\u7aef\u53e3\u4e0a\u7684\u8fde\u63a5\u3002\u4f7f\u7528 &#8211;permanent \u6807\u5fd7\u5141\u8bb8\u66f4\u6539\u6c38\u7eed\u3002\u91cd\u65b0\u52a0\u8f7d\u9632\u706b\u5899\u4ee5\u5e94\u7528\u66f4\u6539\u3002\u4f7f\u7528 netstat \u547d\u4ee4\u9a8c\u8bc1\u7aef\u53e3\u662f\u5426\u5df2\u5f00\u653e\u3002\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202406\/03\/2024060311211929513.jpg\" class=\"aligncenter\" title=\"linux\u600e\u4e48\u5f00\u653e\u7aef\u53e3\u63d2\u56fe\" alt=\"linux\u600e\u4e48\u5f00\u653e\u7aef\u53e3\u63d2\u56fe\" \/><\/p>\n<h2>\u5982\u4f55\u5728 Linux \u4e2d\u5f00\u653e\u7aef\u53e3<\/h2>\n<p><strong>\u5f00\u95e8\u89c1\u5c71\uff1a<\/strong><\/p>\n<p>\u8981\u5f00\u653e Linux \u7cfb\u7edf\u4e0a\u7684\u7aef\u53e3\uff0c\u53ef\u4ee5\u6267\u884c\u4ee5\u4e0b\u6b65\u9aa4\uff1a<\/p>\n<p><strong>\u8be6\u7ec6\u6b65\u9aa4\uff1a<\/strong><\/p>\n<ol>\n<li> <strong>\u786e\u5b9a\u8981\u5f00\u653e\u7684\u7aef\u53e3\uff1a<\/strong>\u786e\u5b9a\u9700\u8981\u5f00\u653e\u7684\u7aef\u53e3\u53f7\u3002\u4f8b\u5982\uff0c\u8981\u5f00\u653e Web \u670d\u52a1\u5668\uff0c\u901a\u5e38\u9700\u8981\u5f00\u653e\u7aef\u53e3 80 \u6216 443\u3002<\/li>\n<li>\n<p><strong>\u68c0\u67e5\u9632\u706b\u5899\u72b6\u6001\uff1a<\/strong>\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u68c0\u67e5\u9632\u706b\u5899\u72b6\u6001\uff1a<\/p>\n<ul>\n<li>systemctl status firewalld<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u542f\u7528\u9632\u706b\u5899\uff1a<\/strong>\u5982\u679c\u9632\u706b\u5899\u5df2\u7981\u7528\uff0c\u8bf7\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u542f\u7528\u5b83\uff1a<\/p>\n<ul>\n<li>sudo systemctl start firewalld<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u5141\u8bb8\u8fde\u63a5\uff1a<\/strong>\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5141\u8bb8\u7aef\u53e3\u4e0a\u7684\u8fde\u63a5\uff1a<\/p>\n<ul>\n<li>sudo firewall-cmd &#8211;add-port \/tcp &#8211;permanent <\/li>\n<li>sudo firewall-cmd &#8211;add-port \/udp &#8211;permanent <\/li>\n<\/ul>\n<\/li>\n<li> <strong>\u5141\u8bb8\u6c38\u7eed\u53d8\u5316\uff1a<\/strong>\u66f4\u6539\u9700\u8981\u6c38\u7eed\uff0c\u56e0\u6b64\u4f7f\u7528 &#8211;permanent \u6807\u5fd7\u3002<\/li>\n<li>\n<p><strong>\u91cd\u65b0\u52a0\u8f7d\u9632\u706b\u5899\uff1a<\/strong>\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u91cd\u65b0\u52a0\u8f7d\u9632\u706b\u5899\u4ee5\u5e94\u7528\u66f4\u6539\uff1a<\/p>\n<ul>\n<li>sudo firewall-cmd &#8211;reload<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<p><strong>\u793a\u4f8b\uff1a<\/strong><\/p>\n<p>\u4ee5\u4e0b\u547d\u4ee4\u5f00\u653e\u7aef\u53e3 80 \u4ee5\u5141\u8bb8 HTTP \u8fde\u63a5\uff1a<\/p>\n<pre>sudo firewall-cmd --add-port 80\/tcp --permanent\nsudo firewall-cmd --reload<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u9a8c\u8bc1\u7aef\u53e3\u662f\u5426\u5df2\u5f00\u653e\uff1a<\/strong><\/p>\n<p>\u53ef\u4ee5\u4f7f\u7528 netstat \u547d\u4ee4\u9a8c\u8bc1\u7aef\u53e3\u662f\u5426\u5df2\u5f00\u653e\uff1a<\/p>\n<pre>netstat -an | grep &lt;PORT-NUMBER&gt;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u600e\u4e48\u5f00\u653e\u7aef\u53e3\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5728 linux \u7cfb\u7edf\u4e0a\u5f00\u653e\u7aef\u53e3\u7684\u6b65\u9aa4\u5982\u4e0b\uff1a\u786e\u5b9a\u8981\u5f00\u653e\u7684\u7aef\u53e3\u53f7\u3002\u68c0\u67e5\u9632\u706b\u5899\u72b6\u6001\u3002\u5982\u679c\u9632\u706b\u5899\u7981\u7528\uff0c\u5219\u542f\u7528\u5b83\u3002\u4f7f\u7528 firewall-cmd \u547d\u4ee4\u5141\u8bb8\u7aef\u53e3\u4e0a\u7684\u8fde\u63a5\u3002\u4f7f\u7528 &#8211;permanent \u6807\u5fd7\u5141\u8bb8\u66f4\u6539\u6c38\u7eed\u3002\u91cd\u65b0\u52a0\u8f7d\u9632\u706b\u5899\u4ee5\u5e94\u7528\u66f4\u6539\u3002\u4f7f\u7528 netstat \u547d\u4ee4\u9a8c\u8bc1\u7aef\u53e3\u662f\u5426\u5df2\u5f00\u653e\u3002 \u5982\u4f55\u5728 Linux \u4e2d\u5f00\u653e\u7aef\u53e3 \u5f00\u95e8\u89c1\u5c71\uff1a \u8981\u5f00\u653e Linux \u7cfb\u7edf\u4e0a\u7684\u7aef\u53e3\uff0c\u53ef\u4ee5\u6267\u884c\u4ee5\u4e0b\u6b65\u9aa4\uff1a \u8be6\u7ec6\u6b65\u9aa4\uff1a \u786e\u5b9a\u8981\u5f00\u653e\u7684\u7aef\u53e3\uff1a\u786e\u5b9a\u9700\u8981\u5f00\u653e\u7684\u7aef\u53e3\u53f7\u3002\u4f8b\u5982\uff0c\u8981\u5f00\u653e Web \u670d\u52a1\u5668\uff0c\u901a\u5e38\u9700\u8981\u5f00\u653e\u7aef\u53e3 80 \u6216 443\u3002 \u68c0\u67e5\u9632\u706b\u5899\u72b6\u6001\uff1a\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u68c0\u67e5\u9632\u706b\u5899\u72b6\u6001\uff1a systemctl status firewalld \u542f\u7528\u9632\u706b\u5899\uff1a\u5982\u679c\u9632\u706b\u5899\u5df2\u7981\u7528\uff0c\u8bf7\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u542f\u7528\u5b83\uff1a sudo systemctl start firewalld \u5141\u8bb8\u8fde\u63a5\uff1a\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5141\u8bb8\u7aef\u53e3\u4e0a\u7684\u8fde\u63a5\uff1a sudo firewall-cmd &#8211;add-port \/tcp &#8211;permanent sudo firewall-cmd &#8211;add-port \/udp &#8211;permanent \u5141\u8bb8\u6c38\u7eed\u53d8\u5316\uff1a\u66f4\u6539\u9700\u8981\u6c38\u7eed\uff0c\u56e0\u6b64\u4f7f\u7528 &#8211;permanent \u6807\u5fd7\u3002 \u91cd\u65b0\u52a0\u8f7d\u9632\u706b\u5899\uff1a\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u91cd\u65b0\u52a0\u8f7d\u9632\u706b\u5899\u4ee5\u5e94\u7528\u66f4\u6539\uff1a sudo firewall-cmd &#8211;reload \u793a\u4f8b\uff1a \u4ee5\u4e0b\u547d\u4ee4\u5f00\u653e\u7aef\u53e3 80 \u4ee5\u5141\u8bb8 HTTP [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[],"class_list":["post-18108","post","type-post","status-publish","format-standard","hentry","category-os"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/18108","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=18108"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/18108\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=18108"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=18108"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=18108"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}