﻿{"id":84,"date":"2018-03-31T23:21:53","date_gmt":"2018-03-31T15:21:53","guid":{"rendered":"http:\/\/www.cloudy.pub\/?p=84"},"modified":"2019-02-05T02:30:53","modified_gmt":"2019-02-04T18:30:53","slug":"firewalld-%e6%89%93%e5%bc%80%e7%ab%af%e5%8f%a3%e6%8c%87%e4%bb%a4%e8%8c%83%e4%be%8b","status":"publish","type":"post","link":"https:\/\/www.0moon.com\/?p=84","title":{"rendered":"CentOS 7 \u9632\u706b\u5899firewalld \u6253\u5f00\u7aef\u53e3\u6307\u4ee4\u8303\u4f8b"},"content":{"rendered":"<p>\u67e5\u770b\u670d\u52a1\u72b6\u6001\/\u5237\u65b0\u89c4\u5219\u4f7f\u751f\u6548\uff1a<\/p>\n<pre>systemctl status firewalld \/ service firewalld restart\r\n<strong>firewall-cmd --reload<\/strong><\/pre>\n<p>&nbsp;<\/p>\n<p>\u6c38\u4e45\u6253\u5f00\u7aef\u53e3\uff1a<\/p>\n<pre>firewall-cmd --add-port=8080\/tcp --permanent\r\nfirewall-cmd --add-port=5000-5100\/tcp --permanent\r\nfirewall-cmd --add-port={110\/tcp,143\/tcp} --permanent\r\nfirewall-cmd --add-service=smtp --permanent\r\nfirewall<span class=\"hljs-attribute\">-cmd<\/span> <span class=\"hljs-subst\">--<\/span>permanent <span class=\"hljs-subst\">--<\/span>add<span class=\"hljs-attribute\">-rich<\/span><span class=\"hljs-attribute\">-rule<\/span><span class=\"hljs-subst\">=<\/span><span class=\"hljs-string\">\"rule family=\"<\/span>ipv4<span class=\"hljs-string\">\" source address=\"127.0.0.1<\/span><span class=\"hljs-string\">\" port protocol=\"<\/span>tcp<span class=\"hljs-string\">\" port=\"<\/span><span class=\"hljs-number\">8000<\/span><span class=\"hljs-string\">\" accept\"\r\n<\/span>#\u5bf9\u6307\u5b9a\u8fdc\u7a0bIP\u5730\u5740127.0.0.1\u6253\u5f008000\u7aef\u53e3<\/pre>\n<p>&nbsp;<\/p>\n<p>\u6c38\u4e45\u7981\u6b62\uff1a<\/p>\n<pre>firewall-cmd --permanent --add-rich-rule=\"rule family=ipv4 source address='x.x.x.x\/24' service name='ssh' drop\"<\/pre>\n<p>&nbsp;<\/p>\n<p><span class=\"Comment\">\u5217\u51fa\u6240\u6709\u7684\u5167\u5bb9\uff1a<\/span><\/p>\n<pre>firewall-cmd <span class=\"Special\">--list-all-zones<\/span>\r\n<span class=\"Special\">firewall-cmd --list-all<\/span><\/pre>\n<p>&nbsp;<\/p>\n<p><span class=\"Special\">\u6c38\u4e45\u5220\u9664HTTP\u670d\u52a1\u7aef\u53e3\uff1a <\/span><\/p>\n<pre>firewall-cmd <span class=\"Special\">--zone=public <\/span><span class=\"Special\">--permanent <\/span><span class=\"Special\">--remove-service=http\r\nfirewall-cmd --zone=public --permanent --remove-port=80\/tcp\r\nfirewall<span class=\"hljs-attribute\">-cmd<\/span> <span class=\"hljs-subst\">--<\/span>permanent <span class=\"hljs-subst\">--<\/span>remove<span class=\"hljs-attribute\">-rich<\/span><span class=\"hljs-attribute\">-rule<\/span><span class=\"hljs-subst\">=<\/span><span class=\"hljs-string\">\"rule family=\"<\/span>ipv4<span class=\"hljs-string\">\" source address=\"127.0.0.1<\/span><span class=\"hljs-string\">\" port protocol=\"<\/span>tcp<span class=\"hljs-string\">\" port=\"<\/span><span class=\"hljs-number\">8000<\/span><span class=\"hljs-string\">\" accept\"<\/span>\r\n\r\n<\/span><\/pre>\n<p>&nbsp;<\/p>\n<p>\u7aef\u53e3\u8f6c\u53d1\uff1a<\/p>\n<pre>firewall-cmd --permanent --add-forward-port=port=80:proto=tcp:toport=8080:toaddr=192.0.2.55\r\nfirewall-cmd --permanent --add-masquerade<\/pre>\n<p>\u8f6c\u53d1\u548c\u4f2a\u88c5\uff08\u9700\u8981\u8f6c\u53d1\u7684\u7f51\u5361wg0\uff0cip:10.200.200.1\uff09\uff1a<\/p>\n<pre>firewall-cmd --permanent --direct --add-rule ipv4 filter FORWARD 0 -i wg0 -o eth0 -j ACCEPT\r\nfirewall-cmd --permanent --add-rich-rule='rule family=ipv4 source address=10.200.200.1\/24 masquerade'<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u67e5\u770b\u670d\u52a1\u72b6\u6001\/\u5237\u65b0\u89c4\u5219\u4f7f\u751f\u6548\uff1a systemctl status firewalld \/ service fi [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12,13],"tags":[32,35],"class_list":["post-84","post","type-post","status-publish","format-standard","hentry","category-linux","category-study","tag-centos","tag-firewalld"],"_links":{"self":[{"href":"https:\/\/www.0moon.com\/index.php?rest_route=\/wp\/v2\/posts\/84","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.0moon.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.0moon.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.0moon.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.0moon.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=84"}],"version-history":[{"count":19,"href":"https:\/\/www.0moon.com\/index.php?rest_route=\/wp\/v2\/posts\/84\/revisions"}],"predecessor-version":[{"id":191,"href":"https:\/\/www.0moon.com\/index.php?rest_route=\/wp\/v2\/posts\/84\/revisions\/191"}],"wp:attachment":[{"href":"https:\/\/www.0moon.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=84"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.0moon.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=84"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.0moon.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=84"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}