{"id":3812,"date":"2023-02-04T15:43:00","date_gmt":"2023-02-04T21:43:00","guid":{"rendered":"http:\/\/www.incredigeek.com\/home\/?p=3812"},"modified":"2023-02-04T13:51:01","modified_gmt":"2023-02-04T19:51:01","slug":"dual-zones-in-firewalld-public-private-or-external-internal","status":"publish","type":"post","link":"https:\/\/www.incredigeek.com\/home\/dual-zones-in-firewalld-public-private-or-external-internal\/","title":{"rendered":"Dual Zones in Firewalld (Public\/Private or External\/Internal)"},"content":{"rendered":"\n<p><\/p>\n\n\n\n<p>In Firewalld we can use multiple zones for different types of traffic.  For instance, we can setup an &#8220;internal&#8221; zone with our local IP addresses that are trusted, and then setup the public facing interface to the &#8220;drop&#8221; or &#8220;block&#8221; zone to block everything not from our internal network. <\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Setup trusted IP addresses in the &#8220;internal&#8221; zone<\/li>\n\n\n\n<li>Configure services\/ports that should be allowed on our &#8220;internal&#8221; zone<\/li>\n\n\n\n<li>Set &#8220;drop&#8221; zone as the default for all other traffic<\/li>\n\n\n\n<li>Reload firewall<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\">1. Setup trusted IP addresses in &#8220;internal&#8221; zone<\/h2>\n\n\n\n<p>Add all of our trusted IP addresses to the internal zone.  The following example adds all of the private IP addresses &#8220;RFC 1918&#8221; to the internal zone.  Change as needed.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">firewall-cmd --zone=internal --add-source=192.168.0.0\/16 --add-source=172.16.0.0\/12 --add-source=10.0.0.0\/8 --permanent<\/pre>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">2. Configure services\/ports that should be allowed on our &#8220;internal&#8221; zone<\/h2>\n\n\n\n<p>Next we need to specify which services or ports should be accessible in our trusted zone.<\/p>\n\n\n\n<p>Here is an example to allow https, ssh, and cockpit services<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">firewall-cmd --zone=internal --add-service=https --add-service=ssh --add-service=cockpit --permanent <\/pre>\n\n\n\n<p>Here is an example to allow port 8080 tcp<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">firewall-cmd --zone=internal --add-port=8080\/tcp --permanent<\/pre>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">3. Set &#8220;drop&#8221; zone as the default for all other traffic<\/h2>\n\n\n\n<p>The final configuration piece we need to do is set the default zone.  Anything not specified in other zones will get processed by the default zone.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">firewall-cmd --set-default-zone=drop<\/pre>\n\n\n\n<p>The drop zone drops everything.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"> 4. Reload firewall<\/h2>\n\n\n\n<p>Reload the firewall with <\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">firewall-cmd --reload<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><br>Verifying changes<\/h2>\n\n\n\n<p>Let&#8217;s verify the changes with the firewall-cmd &#8211;get-active-zones command<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"># firewall-cmd --get-active-zones\ndrop\n  interfaces: en0\ninternal\n  sources: 192.168.0.0\/16 172.16.0.0\/12 10.0.0.0\/8<\/pre>\n\n\n\n<p>You can also use<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">firewall-cmd --list-all-zones<\/pre>\n\n\n\n<p>to list all the zones.  Active zones show (active) next to them.<\/p>\n\n\n\n<p>You can verify that your changes worked by doing an internal and external nmap scan.<\/p>\n\n\n\n<p>If you have issues with services still being accessible from the outside, try disabling Network Manager for that specific interface<\/p>\n\n\n\n<p>You can edit the ifcfg-eth0 file and add<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">NM_CONTROLLED=no<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>In Firewalld we can use multiple zones for different types of traffic. For instance, we can setup an &#8220;internal&#8221; zone with our local IP addresses that are trusted, and then setup the public facing interface to the &#8220;drop&#8221; or &#8220;block&#8221; &hellip; <a href=\"https:\/\/www.incredigeek.com\/home\/dual-zones-in-firewalld-public-private-or-external-internal\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[160,206,205,7,503],"class_list":["post-3812","post","type-post","status-publish","format-standard","hentry","category-linux","tag-firewall","tag-firewall-cmd","tag-firewalld","tag-linux-2","tag-security"],"_links":{"self":[{"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/posts\/3812","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/comments?post=3812"}],"version-history":[{"count":8,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/posts\/3812\/revisions"}],"predecessor-version":[{"id":4798,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/posts\/3812\/revisions\/4798"}],"wp:attachment":[{"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/media?parent=3812"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/categories?post=3812"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/tags?post=3812"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}