{"id":340,"date":"2024-09-16T12:11:40","date_gmt":"2024-09-16T04:11:40","guid":{"rendered":"http:\/\/www.daimuya.cn:3389\/?p=340"},"modified":"2024-09-16T12:11:40","modified_gmt":"2024-09-16T04:11:40","slug":"linux%e6%94%be%e8%a1%8c%e7%ab%af%e5%8f%a3","status":"publish","type":"post","link":"http:\/\/www.daimuya.cn:3389\/index.php\/2024\/09\/16\/linux%e6%94%be%e8%a1%8c%e7%ab%af%e5%8f%a3\/","title":{"rendered":"Linux\u653e\u884c\u7aef\u53e3"},"content":{"rendered":"<p>\u5728Linux\u7cfb\u7edf\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528iptables\u547d\u4ee4\u6216\u8005firewall-cmd\u547d\u4ee4\u6765\u653e\u884c\u7aef\u53e3\u53f7\u3002<br \/>\n1. \u4f7f\u7528iptables\u547d\u4ee4\u653e\u884c\u7aef\u53e3\u53f7:<br \/>\n\u9996\u5148\uff0c\u9700\u8981\u786e\u8ba4iptables\u9632\u706b\u5899\u662f\u5426\u542f\u7528\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u8fdb\u884c\u68c0\u67e5\uff1a<br \/>\n\u201c`shell<br \/>\nsystemctl status iptables<br \/>\n\u201c`<br \/>\n\u5982\u679c\u8fd4\u56de\u7684\u7ed3\u679c\u4e2d\u663e\u793a\u201dactive (running)\u201d\u7b49\u5b57\u6837\uff0c\u5219\u8868\u793aiptables\u9632\u706b\u5899\u5df2\u542f\u7528\uff0c\u53ef\u4ee5\u8fdb\u884c\u4e0b\u4e00\u6b65\u64cd\u4f5c\u3002<br \/>\n\u7136\u540e\uff0c\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5f00\u653e\u4e00\u4e2a\u7279\u5b9a\u7684\u7aef\u53e3\u53f7\uff0c\u6bd4\u598280\u7aef\u53e3\uff1a<br \/>\n\u201c`shell<br \/>\niptables -A INPUT -p tcp \u2013dport 80 -j ACCEPT<br \/>\n\u201c`<br \/>\n\u8fd9\u6761\u547d\u4ee4\u7684\u610f\u601d\u662f\u5c06\u8f93\u5165\u89c4\u5219(INPUT)\u6dfb\u52a0\u5230iptables\u4e2d\uff0c\u5141\u8bb8\u901a\u8fc7TCP\u534f\u8bae\u8bbf\u95ee80\u7aef\u53e3\u3002<br \/>\n\u6700\u540e\uff0c\u4fdd\u5b58iptables\u89c4\u5219\uff0c\u5e76\u91cd\u542fiptables\u670d\u52a1\uff0c\u4f7f\u89c4\u5219\u751f\u6548\uff1a<br \/>\n\u201c`shell<br \/>\nservice iptables save<br \/>\nservice iptables restart<br \/>\n\u201c`<br \/>\n\u5982\u679c\u5e0c\u671b\u6c38\u4e45\u6027\u5730\u653e\u884c\u7aef\u53e3\u53f7\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u8fdb\u884c\u8bbe\u7f6e\uff1a<br \/>\n\u201c`shell<br \/>\niptables-save &gt; \/etc\/sysconfig\/iptables<br \/>\nsystemctl restart iptables<br \/>\n\u201c`<br \/>\n2. \u4f7f\u7528firewall-cmd\u547d\u4ee4\u653e\u884c\u7aef\u53e3\u53f7:<br \/>\n\u9996\u5148\uff0c\u9700\u8981\u786e\u8ba4firewalld\u9632\u706b\u5899\u662f\u5426\u542f\u7528\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u8fdb\u884c\u68c0\u67e5\uff1a<br \/>\n\u201c`shell<br \/>\nsystemctl status firewalld<br \/>\n\u201c`<br \/>\n\u5982\u679c\u8fd4\u56de\u7684\u7ed3\u679c\u4e2d\u663e\u793a\u201dactive (running)\u201d\u7b49\u5b57\u6837\uff0c\u5219\u8868\u793afirewalld\u9632\u706b\u5899\u5df2\u542f\u7528\uff0c\u53ef\u4ee5\u8fdb\u884c\u4e0b\u4e00\u6b65\u64cd\u4f5c\u3002<br \/>\n\u63a5\u4e0b\u6765\uff0c\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5f00\u653e\u4e00\u4e2a\u7279\u5b9a\u7684\u7aef\u53e3\u53f7\uff0c\u6bd4\u598280\u7aef\u53e3\uff1a<br \/>\n\u201c`shell<br \/>\nfirewall-cmd \u2013zone=public \u2013add-port=80\/tcp \u2013permanent<br \/>\n\u201c`<br \/>\n\u8fd9\u6761\u547d\u4ee4\u7684\u610f\u601d\u662f\u5728public\u533a\u57df\u4e2d\u6c38\u4e45\u6027\u5730\u5f00\u653eTCP\u534f\u8bae\u768480\u7aef\u53e3\u3002<br \/>\n\u6700\u540e\uff0c\u91cd\u542ffirewalld\u670d\u52a1\uff0c\u4f7f\u89c4\u5219\u751f\u6548\uff1a<br \/>\n\u201c`shell<br \/>\nsystemctl restart firewalld<br \/>\n\u201c`<br \/>\n\u81f3\u6b64\uff0c\u4f60\u5df2\u7ecf\u5b66\u4f1a\u4e86\u5728Linux\u7cfb\u7edf\u4e2d\u653e\u884c\u7aef\u53e3\u53f7\u7684\u547d\u4ee4\u3002\u8bf7\u6839\u636e\u81ea\u5df1\u7684\u9700\u6c42\u9009\u62e9\u5408\u9002\u7684\u65b9\u6cd5\u8fdb\u884c\u64cd\u4f5c\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5728Linux\u7cfb\u7edf\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528iptables\u547d\u4ee4\u6216\u8005firewall-cmd\u547d\u4ee4 &hellip; <a href=\"http:\/\/www.daimuya.cn:3389\/index.php\/2024\/09\/16\/linux%e6%94%be%e8%a1%8c%e7%ab%af%e5%8f%a3\/\">\u7ee7\u7eed\u9605\u8bfb <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[],"class_list":["post-340","post","type-post","status-publish","format-standard","hentry","category-9"],"_links":{"self":[{"href":"http:\/\/www.daimuya.cn:3389\/index.php\/wp-json\/wp\/v2\/posts\/340","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.daimuya.cn:3389\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.daimuya.cn:3389\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.daimuya.cn:3389\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.daimuya.cn:3389\/index.php\/wp-json\/wp\/v2\/comments?post=340"}],"version-history":[{"count":1,"href":"http:\/\/www.daimuya.cn:3389\/index.php\/wp-json\/wp\/v2\/posts\/340\/revisions"}],"predecessor-version":[{"id":341,"href":"http:\/\/www.daimuya.cn:3389\/index.php\/wp-json\/wp\/v2\/posts\/340\/revisions\/341"}],"wp:attachment":[{"href":"http:\/\/www.daimuya.cn:3389\/index.php\/wp-json\/wp\/v2\/media?parent=340"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.daimuya.cn:3389\/index.php\/wp-json\/wp\/v2\/categories?post=340"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.daimuya.cn:3389\/index.php\/wp-json\/wp\/v2\/tags?post=340"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}