{"id":263421,"date":"2023-03-09T09:02:10","date_gmt":"2023-03-09T01:02:10","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=263421"},"modified":"2023-02-03T23:47:17","modified_gmt":"2023-02-03T15:47:17","slug":"linux-open-port","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/linux-open-port.html","title":{"rendered":"Linux \u4e2d\u5982\u4f55\u5f00\u542f\u7aef\u53e3"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\n\u6709\u65f6\u6211\u4eec\u53ef\u80fd\u9700\u8981\u5728Linux\u670d\u52a1\u5668\u4e2d\u6253\u5f00\u7aef\u53e3\u6216\u5728Linux\u670d\u52a1\u5668\u7684\u9632\u706b\u5899\u4e2d\u542f\u7528\u7aef\u53e3\u6765\u8fd0\u884c\u7279\u5b9a\u7684\u5e94\u7528\u7a0b\u5e8f\u3002\u5728\u672c\u6587\u4e2d\uff0c\u5c0f\u7f16\u5c06\u5e26\u5927\u5bb6\u5206\u6790\u4e00\u4e0b\u5982\u4f55\u5728linux\u670d\u52a1\u5668\u4e2d\u6253\u5f00\u7aef\u53e3\u547d\u4ee4\uff1f<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n
Linux \u7aef\u53e3\u7684\u5f00\u542f<\/strong><\/div>\n

Linux \u7aef\u53e3\u7684\u5f00\u542f<\/p>\n

\u4e00\u3001firewall \u65b9\u5f0f (centOS7.*)<\/p>\n

\u4e8c\u3001\u4fee\u6539 iptables \u65b9\u5f0f (centOS6.*)<\/p>\n

\u4e00\u3001firewall \u65b9\u5f0f (centOS7.*)<\/strong><\/div>\n

\u67e5\u770b\u9632\u706b\u5899\u72b6\u6001<\/p>\n

firewall-cmd --state<\/pre>\n

\u5982\u679c\u8fd4\u56de\u7684\u662f \u201cnot running\u201d\uff0c\u90a3\u4e48\u9700\u8981\u5148\u5f00\u542f\u9632\u706b\u5899\uff1b<\/p>\n

\u5f00\u542f\u9632\u706b\u5899<\/p>\n

systemctl start firewalld.service<\/pre>\n

\"\"<\/p>\n

\u518d\u6b21\u67e5\u770b\u9632\u706b\u5899\u72b6\u6001\uff0c\u53d1\u73b0\u5df2\u5f00\u542f\uff01<\/p>\n

\u5f00\u542f\u6307\u5b9a\u7aef\u53e3<\/p>\n

firewall-cmd --zone=public --add-port=3306\/tcp --permanent<\/pre>\n

\u663e\u793a success \u8868\u793a\u6210\u529f
\n\u2013zone=public \u8868\u793a\u4f5c\u7528\u57df\u4e3a\u516c\u5171\u7684
\n\u2013add-port=443\/tcp \u6dfb\u52a0 tcp \u534f\u8bae\u7684\u7aef\u53e3\u7aef\u53e3\u53f7\u4e3a 443
\n\u2013permanent \u6c38\u4e45\u751f\u6548\uff0c\u5982\u679c\u6ca1\u6709\u6b64\u53c2\u6570\uff0c\u5219\u53ea\u80fd\u7ef4\u6301\u5f53\u524d \u670d \u52a1\u751f\u547d\u5468\u671f\u5185\uff0c\u91cd\u65b0\u542f\u52a8\u540e\u5931\u6548\uff1b<\/p>\n

\"\"<\/p>\n

\u91cd\u542f\u9632\u706b\u5899<\/p>\n

systemctl restart firewalld.service<\/pre>\n

\u7cfb\u7edf\u6ca1\u6709\u4efb\u4f55\u63d0\u793a\u8868\u793a\u6210\u529f\uff01<\/p>\n

\u91cd\u65b0\u52a0\u8f7d\u9632\u706b\u5899<\/p>\n

firewall-cmd --reload<\/pre>\n

\u663e\u793a success \u8868\u793a\u6210\u529f<\/p>\n

\u5176\u4ed6\u547d\u4ee4<\/strong><\/div>\n

\u67e5\u770b\u5df2\u5f00\u542f\u7684\u7aef\u53e3<\/p>\n

irewall-cmd --list-ports<\/pre>\n

\u5173\u95ed\u6307\u5b9a\u7aef\u53e3<\/p>\n

firewall-cmd --zone=public --remove-port=8080\/tcp --permanent\r\nsystemctl restart firewalld.service\r\nfirewall-cmd --reload<\/pre>\n

\u67e5\u770b\u7aef\u53e3\u88ab\u54ea\u4e00\u4e2a\u8fdb\u7a0b\u5360\u7528<\/p>\n

netstat -lnpt |grep 5672\r\n# centos7\u9ed8\u8ba4\u6ca1\u6709 netstat \u547d\u4ee4\uff0c\u9700\u8981\u5b89\u88c5 net-tools \u5de5\u5177\uff1a\r\n# \u5b89\u88c5 net-tools\r\nyum install -y net-tools<\/pre>\n

\u4e34\u65f6\u5173\u95ed\u9632\u706b\u5899<\/p>\n

systemctl stop firewalld.service<\/pre>\n

\u6216\u8005<\/p>\n

systemctl stop firewalld<\/pre>\n

\u6c38\u4e45\u5173\u95ed\u9632\u706b\u5899\uff08\u5fc5\u987b\u5148\u4e34\u65f6\u5173\u95ed\u9632\u706b\u5899\uff0c\u518d\u6267\u884c\u8be5\u547d\u4ee4\uff0c\u8fdb\u884c\u6c38\u4e45\u5173\u95ed\uff09<\/p>\n

systemctl disable firewalld.service<\/pre>\n

\u6216\u8005<\/p>\n

systemctl disable firewalld<\/pre>\n
\u4e8c\u3001\u4fee\u6539 iptables \u65b9\u5f0f (centOS6.*)<\/strong><\/div>\n

centOS6.* \u7684linux\u7248\u672c\u662f\u81ea\u5e26iptables\u7684\uff0c\u6240\u4ee5\u53ef\u4ee5\u76f4\u63a5\u4f7f\u7528\u8be5\u65b9\u5f0f\uff0ccentOS7 \u4e0d\u81ea\u5e26iptables\u7684\uff0c\u6240\u4ee5\u8981\u4f7f\u7528\u8be5\u65b9\u5f0f\uff0c\u9700\u8981\u624b\u52a8\u5b89\u88c5iptables\u540e\uff0c\u518d\u4f7f\u7528\u8be5\u65b9\u5f0f\uff01<\/p>\n

\u4fee\u6539 iptables \u6587\u4ef6<\/p>\n

vi \/etc\/sysconfig\/iptables<\/pre>\n

\"\"<\/p>\n

\u91cd\u542f\u9632\u706b\u5899<\/p>\n

 \/etc\/init.d\/iptables restart<\/pre>\n

\"\"<\/p>\n

\u4e09\u3001\u6ce8\u610f\u4e8b\u9879<\/strong><\/div>\n

\u5f53\u5728 Linux \u4e2d\u6210\u529f\u5f00\u542f\u4e86\u67d0\u4e2a\u7aef\u53e3\uff0c\u4f46\u662f\u8fdc\u7a0b telnet \u8fd8\u662f\u65e0\u6cd5 ping \u901a\uff0c\u662f\u6b63\u5e38\u7684\uff01<\/p>\n

\"\"<\/p>\n

\u56e0\u4e3a 3306 \u7aef\u53e3\u6ca1\u6709\u88ab Linux \u8fdb\u7a0b\u76d1\u542c\uff0c\u6362\u53e5\u8bdd\u8bf4\uff0c\u5c31\u662f\u8be5\u7aef\u53e3\u4e0a\u6ca1\u6709\u8fd0\u884c\u4efb\u4f55\u7a0b\u5e8f\uff01\uff01\uff01
\n\u5982\u679c\u8fd9\u65f6\uff0c\u6211\u5c06 Mysql \u5728 Linux \u4e2d\u542f\u52a8\uff0c\u5e76\u914d\u7f6e\u5b8c\u6210\uff0c\u90a3\u4e48\u8fdc\u7a0b telnet \u8be5\u7aef\u53e3\u662f\u53ef\u4ee5\u6210\u529f\u7684\uff01\uff01\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"

Linux \u7aef\u53e3\u7684\u5f00\u542f \u4e00\u3001firewall \u65b9\u5f0f (centOS7.*) \u4e8c\u3001\u4fee\u6539 iptables \u65b9\u5f0f […]<\/p>\n","protected":false},"author":310,"featured_media":263441,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-263421","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/263421","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/310"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=263421"}],"version-history":[{"count":14,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/263421\/revisions"}],"predecessor-version":[{"id":263513,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/263421\/revisions\/263513"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/263441"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=263421"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=263421"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=263421"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}