{"id":617,"date":"2021-05-27T10:38:24","date_gmt":"2021-05-27T02:38:24","guid":{"rendered":"https:\/\/qtvz.com\/?p=617"},"modified":"2021-05-27T12:25:15","modified_gmt":"2021-05-27T04:25:15","slug":"centos-firewall%e9%98%b2%e7%81%ab%e5%a2%99%e5%91%bd%e4%bb%a4%e5%90%88%e9%9b%86","status":"publish","type":"post","link":"https:\/\/qtvz.com\/617.html","title":{"rendered":"Centos Firewall\u9632\u706b\u5899\u547d\u4ee4\u5408\u96c6"},"content":{"rendered":"<!--wp-compress-html--><!--wp-compress-html no compression--><h5>\u4e3a\u4e86\u65b9\u4fbf<a href=\"https:\/\/qtvz.com\/tag\/firewall\" class=\"tag-tooltip\" data-toggle=\"tooltip\" title=\"\u67e5\u770b\u66f4\u591a\u5173\u4e8e Firewall \u7684\u6587\u7ae0\" target=\"_blank\">Firewall<\/a>\u547d\u4ee4\u67e5\u8be2 \u7279\u5730\u8bb0\u5f55\u4ee5\u4e0b\u547d\u4ee4<\/h5>\n<h4>\u4e00\u3001\u57fa\u672c\u4f7f\u7528<\/h4>\n<p>1.\u542f\u52a8\uff1a<code>systemctl start firewalld<\/code><\/p>\n<p>2.\u5173\u95ed\uff1a<code>systemctl stop firewalld<\/code><\/p>\n<p>3.\u67e5\u770b\u72b6\u6001\uff1a<code>systemctl status firewalld<\/code><\/p>\n<p>4.\u5f00\u673a\u7981\u7528\uff1a<code>systemctl disable firewalld<\/code><\/p>\n<p>5.\u5f00\u673a\u542f\u7528\uff1a<code>systemctl enable firewalld<\/code><\/p>\n<p>6.\u914d\u7f6e\uff1a<code>firewalld-cmd<\/code><\/p>\n<p>7.\u67e5\u770b\u7248\u672c\uff1a<code>firewall-cmd --version<\/code><\/p>\n<p>8.\u67e5\u770b\u5e2e\u52a9\uff1a<code>firewall-cmd --help<\/code><\/p>\n<p>9.\u663e\u793a\u72b6\u6001\uff1a<code>firewall-cmd --state<\/code><\/p>\n<p>10.\u67e5\u770b\u6240\u6709\u6253\u5f00\u7684\u7aef\u53e3\uff1a<code>firewall-cmd --zone=public --list-ports<\/code><\/p>\n<p>11.\u66f4\u65b0\u9632\u706b\u5899\u89c4\u5219\uff1a<code>firewall-cmd --reload<\/code><\/p>\n<h4>\u4e8c\u3001\u7aef\u53e3\u5f00\u653e<\/h4>\n<p>1.\u6dfb\u52a0\uff1a<code>firewall-cmd --zone=public --add-port=80\/tcp --permanent<\/code><\/p>\n<p>2.\u91cd\u65b0\u8f7d\u5165\uff1a<code>firewall-cmd --reload<\/code><\/p>\n<p>3.\u5220\u9664\uff1a<code>firewall-cmd --zone= public --remove-port=80\/tcp --permanent<\/code><\/p>\n<h4>\u4e09\u3001\u7aef\u53e3\u8f6c\u53d1<\/h4>\n<p>1.\u6dfb\u52a0\uff08\u4f8b\u5982\uff1a\u8f6c\u53d1\u7aef\u53e3\uff0c\u5c06\u672c\u670d\u52a1\u76848056\u7aef\u53e3\u8f6c\u53d1\u5230ip\u5730\u5740\u4e3aXXX.XX.XX.XXX\u76843356\u7aef\u53e3\u4e0a,\u53ea\u80fd\u4f7f\u7528IP\u5730\u5740\uff0c\u4e0d\u80fd\u4f7f\u7528\u4e3b\u673a\u540d\uff09\uff1a<\/p>\n<pre><code class=\"language-shell\">firewall-cmd --permanent --zone=public --add-forward-port=port=8056:proto=tcp:toaddr=xxx.xx.xx.xxx:toport=3356<\/code><\/pre>\n<p>2.\u5220\u9664\u8f6c\u53d1\u89c4\u5219\uff1a<\/p>\n<pre><code class=\"language-shell\">firewall-cmd --permanent --zone=public --remove-forward-port=port=8056:proto=tcp:toaddr=xxx.xx.xx.xxx:toport=3356<\/code><\/pre>\n<p>3.\u67e5\u770b\u8f6c\u53d1\u7684\u7aef\u53e3\uff1a<br \/>\n<code>firewall-cmd --list-forward-ports<\/code><\/p>\n<h4>\u56db\u3001\u67e5\u770b\u5f53\u524d\u5f00\u4e86\u54ea\u4e9b\u7aef\u53e3<\/h4>\n<p>1.\u5176\u5b9e\u4e00\u4e2a\u670d\u52a1\u5bf9\u5e94\u4e00\u4e2a\u7aef\u53e3\uff0c\u6bcf\u4e2a\u670d\u52a1\u5bf9\u5e94\/usr\/lib\/firewalld\/services\u4e0b\u9762\u4e00\u4e2axml\u6587\u4ef6\uff1a<br \/>\n<code>firewall-cmd --list-services<\/code><\/p>\n<p>2.\u67e5\u770b\u8fd8\u6709\u54ea\u4e9b\u670d\u52a1\u53ef\u4ee5\u6253\u5f00\uff1a<br \/>\n<code>firewall-cmd --get-services<\/code><\/p>\n<p>3.\u67e5\u770b\u6240\u6709\u6253\u5f00\u7684\u7aef\u53e3\uff1a<br \/>\n<code>firewall-cmd --zone=public --list-ports<\/code><\/p>\n<p>4.\u66f4\u65b0\u9632\u706b\u5899\u89c4\u5219\uff1a<br \/>\n<code>firewall-cmd --reload<\/code><\/p>\n<h4>\u4e94\u3001\u7279\u6b8a\u547d\u4ee4<\/h4>\n<p>1.\u6dfb\u52a0\u591a\u4e2a\u7aef\u53e3<br \/>\n<code>firewall-cmd --permanent --zone=public --add-port=8080-8083\/tcp<\/code><\/p>\n<p>2.\u5220\u9664\u67d0\u4e2a\u7aef\u53e3<br \/>\n<code>firewall-cmd --permanent --zone=public --remove-port=81\/tcp<\/code><\/p>\n<p>3.\u9488\u5bf9\u67d0\u4e2a IP\u5f00\u653e\u7aef\u53e3<\/p>\n<pre><code class=\"language-shell\">firewall-cmd --permanent --add-rich-rule=&quot;rule family=&quot;ipv4&quot; source address=&quot;192.168.142.166&quot; port protocol=&quot;tcp&quot; port=&quot;6379&quot; accept&quot;<\/code><\/pre>\n<pre><code class=\"language-shell\">firewall-cmd --permanent --add-rich-rule=&quot;rule family=&quot;ipv4&quot; source address=&quot;192.168.0.233&quot; accept&quot;<\/code><\/pre>\n<p>4.\u5220\u9664\u67d0\u4e2aIP<\/p>\n<pre><code class=\"language-shell\">firewall-cmd --permanent --remove-rich-rule=&quot;rule family=&quot;ipv4&quot; source address=&quot;192.168.1.51&quot; accept&quot;<\/code><\/pre>\n<p>5.\u9488\u5bf9\u4e00\u4e2aip\u6bb5\u8bbf\u95ee<\/p>\n<pre><code class=\"language-shell\">firewall-cmd --permanent --add-rich-rule=&quot;rule family=&quot;ipv4&quot; source address=&quot;192.168.0.0\/16&quot; accept&quot;<\/code><\/pre>\n<pre><code class=\"language-shell\">firewall-cmd --permanent --add-rich-rule=&quot;rule family=&quot;ipv4&quot; source address=&quot;192.168.1.0\/24&quot; port protocol=&quot;tcp&quot; port=&quot;9200&quot; accept&quot;<\/code><\/pre>\n<p>6.\u6dfb\u52a0\u64cd\u4f5c\u540e\u522b\u5fd8\u4e86\u6267\u884c\u91cd\u8f7d<br \/>\n<code>firewall-cmd --reload<\/code><\/p>\n<!--wp-compress-html no compression--><!--wp-compress-html-->","protected":false},"excerpt":{"rendered":"\u4e3a\u4e86\u65b9\u4fbfFirewall\u547d\u4ee4\u67e5\u8be2 \u7279\u5730\u8bb0\u5f55\u4ee5\u4e0b\u547d\u4ee4 \u4e00\u3001\u57fa\u672c\u4f7f\u7528 1.\u542f\u52a8\uff1asystemctl start firewalld 2.\u5173\u95ed\uff1asystemctl stop firewalld 3.\u67e5\u770b\u72b6\u6001 \u00b7\u00b7\u00b7","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[43],"tags":[100,101],"views":2478,"_links":{"self":[{"href":"https:\/\/qtvz.com\/api\/wp\/v2\/posts\/617"}],"collection":[{"href":"https:\/\/qtvz.com\/api\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/qtvz.com\/api\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/qtvz.com\/api\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/qtvz.com\/api\/wp\/v2\/comments?post=617"}],"version-history":[{"count":33,"href":"https:\/\/qtvz.com\/api\/wp\/v2\/posts\/617\/revisions"}],"predecessor-version":[{"id":633,"href":"https:\/\/qtvz.com\/api\/wp\/v2\/posts\/617\/revisions\/633"}],"wp:attachment":[{"href":"https:\/\/qtvz.com\/api\/wp\/v2\/media?parent=617"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/qtvz.com\/api\/wp\/v2\/categories?post=617"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/qtvz.com\/api\/wp\/v2\/tags?post=617"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}