{"id":79089,"date":"2026-11-17T01:59:52","date_gmt":"2026-11-17T01:59:52","guid":{"rendered":"http:\/\/bangla.sitestree.com\/?p=79089"},"modified":"2026-11-17T01:59:52","modified_gmt":"2026-11-17T01:59:52","slug":"linux-advanced-04-firewall","status":"publish","type":"post","link":"http:\/\/bangla.sitestree.com\/?p=79089","title":{"rendered":"Linux Advanced 04 \u2014 Firewall Zones and Runtime Rules"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/bangla.sitestree.com\/?name=linux-course-index\">Linux course index<\/a> \u00b7 <a href=\"https:\/\/bangla.sitestree.com\/?cat=1992\">Linux Advanced category<\/a> \u00b7 Lesson 4 of 9<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>AI disclosure<\/strong> \u2014 AI-generated content, posted as is. AI can make mistakes. This lesson draws on the linked Open Education posts and adds original explanations or lab examples where useful. The newly written explanations and examples may be freely reused. Linked source material retains its own terms.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Learning goal<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Identify the active zone and compare a timed runtime firewall rule with permanent policy.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Concepts and setup<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">A firewall allows or denies an application path, but opening a path does not create a listener. In firewalld, a zone groups the policy for an interface or source. A runtime change applies now, while permanent configuration is used after reload or restart. Old TCP Wrappers and FTP posts are historical examples and should not be copied to current systems.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Use firewalld in a disposable VM with a host-only adapter and console access. Use the internal zone only if it contains the intended isolated interface and no unrelated interfaces or sources.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Inspect the real interface and zone<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo firewall-cmd --state\nsudo firewall-cmd --get-default-zone\nsudo firewall-cmd --get-active-zones\nsudo firewall-cmd --list-all --zone=internal\nsudo ss -ltn<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Possible output<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>running\npublic\ninternal\n  interfaces: enp0s8\ninternal (active)\n  interfaces: enp0s8\n  services: ...\n...\nLISTEN ... 127.0.0.1:22 ...<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Do not assume the default zone applies. Confirm the VM uses internal for the isolated interface before continuing.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Add a one-minute test rule<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo firewall-cmd --zone=internal --query-port=8088\/tcp\n# Continue only if the query above prints &quot;no&quot;.\nsudo firewall-cmd --zone=internal --add-port=8088\/tcp --timeout=60s\nsudo firewall-cmd --zone=internal --query-port=8088\/tcp\nsudo firewall-cmd --permanent --zone=internal --query-port=8088\/tcp\n# Wait a minute before running this final query:\nsudo firewall-cmd --zone=internal --query-port=8088\/tcp<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Possible output<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>no\nsuccess\nyes\nno\nno<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The timeout is runtime only. No listener is started. A query printing no can return a nonzero status. If ending early, remove the temporary port from the same zone.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Questions only<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Quick-check questions<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n\n<li>Does an allowed port prove a process is listening?<\/li>\n\n\n<li>Does the timed rule change the permanent policy?<\/li>\n\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\">Assessment questions<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n\n<li>How would you prove a service was reachable from an authorized client?<\/li>\n\n\n<li>Why might opening a port on the default zone have no effect?<\/li>\n\n\n<li>Why can an earlier test work until the firewall reloads?<\/li>\n\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\">Questions and answers<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Quick-check answers<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n\n<li><strong>Does an allowed port prove a process is listening?<\/strong><br><strong>Answer<\/strong> \u2014 No. The firewall rule and listener are separate.<\/li>\n\n\n<li><strong>Does the timed rule change the permanent policy?<\/strong><br><strong>Answer<\/strong> \u2014 No. It expires from runtime policy.<\/li>\n\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\">Assessment answer key<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n\n<li><strong>How would you prove a service was reachable from an authorized client?<\/strong><br><strong>Answer<\/strong> \u2014 Check the listener address on the server and exercise the intended application protocol from that client.<\/li>\n\n\n<li><strong>Why might opening a port on the default zone have no effect?<\/strong><br><strong>Answer<\/strong> \u2014 The incoming interface or source may belong to another zone.<\/li>\n\n\n<li><strong>Why can an earlier test work until the firewall reloads?<\/strong><br><strong>Answer<\/strong> \u2014 The test rule may exist only at runtime. Review scope before making a lasting change.<\/li>\n\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\">Source articles on this site<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n\n<li><a href=\"https:\/\/bangla.sitestree.com\/?p=67588\">Experiment with Firewalls in Linux (CentOS\/RedHat) #DevOps #RHCSA<\/a><\/li>\n\n\n<li><a href=\"https:\/\/bangla.sitestree.com\/?p=76481\">Let FTP work through Firewall<\/a><\/li>\n\n\n<li><a href=\"https:\/\/bangla.sitestree.com\/?p=21833\">TCP Wrappers in Linux\/CentOS\/Redhat\/Fedora #Unix\/Linux #GNU\/Linux #Linux #GNU\/Linux #GNU\/Linux #Linux #GNU\/Linux #DevOps #Everything Linux #RHCSA<\/a><\/li>\n\n\n<li><a href=\"https:\/\/bangla.sitestree.com\/?p=78439\">Basic Commands for Networking in Linux<\/a><\/li>\n\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Continue the course<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Previous lesson 03 \u2014 SELinux Contexts, Booleans, and Denials. Next lesson 05 \u2014 Authoritative DNS with BIND.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/bangla.sitestree.com\/?name=linux-course-index\">Linux course index<\/a> \u00b7 <a href=\"https:\/\/bangla.sitestree.com\/?cat=1992\">Linux Advanced category<\/a> \u00b7 Lesson 4 of 9<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Identify the active zone and compare a timed runtime firewall rule with permanent policy.<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":true,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_hide_featured_image":false,"_jetpack_featured_image_duplicate_dismissed":0,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_post_was_ever_published":false},"categories":[1992],"tags":[],"class_list":["post-79089","post","type-post","status-publish","format-standard","hentry","category-linux-advanced","item-wrap"],"jetpack_sharing_enabled":true,"jetpack-related-posts":[{"id":79102,"url":"http:\/\/bangla.sitestree.com\/?p=79102","url_meta":{"origin":79089,"position":0},"title":"Linux Administration Course \u2014 Start Here and Lesson Index","author":"Sayed","date":"November 17, 2026","format":false,"excerpt":"A 33-lesson Linux course from shell fundamentals to server administration, performance, and a recovery capstone.","rel":"","context":"In &quot;Linux Basics&quot;","block_context":{"text":"Linux Basics","link":"http:\/\/bangla.sitestree.com\/?cat=1990"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":79090,"url":"http:\/\/bangla.sitestree.com\/?p=79090","url_meta":{"origin":79089,"position":1},"title":"Linux Advanced 05 \u2014 Authoritative DNS with BIND","author":"Sayed","date":"November 17, 2026","format":false,"excerpt":"Build an authoritative forward zone and distinguish an authoritative answer, NXDOMAIN, and no response.","rel":"","context":"In &quot;Linux Advanced&quot;","block_context":{"text":"Linux Advanced","link":"http:\/\/bangla.sitestree.com\/?cat=1992"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":79088,"url":"http:\/\/bangla.sitestree.com\/?p=79088","url_meta":{"origin":79089,"position":2},"title":"Linux Advanced 03 \u2014 SELinux Contexts, Booleans, and Denials","author":"Sayed","date":"November 17, 2026","format":false,"excerpt":"Diagnose ordinary permission and SELinux policy problems separately and set a persistent file context.","rel":"","context":"In &quot;Linux Advanced&quot;","block_context":{"text":"Linux Advanced","link":"http:\/\/bangla.sitestree.com\/?cat=1992"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":67588,"url":"http:\/\/bangla.sitestree.com\/?p=67588","url_meta":{"origin":79089,"position":3},"title":"Experiment with Firewalls in Linux (CentOS\/RedHat) #DevOps #RHCSA","author":"Author-Check- Article-or-Video","date":"July 25, 2021","format":false,"excerpt":"44 firewall-cmd --state 45 systemctl status firewalld 46 firewall-cmd --reload 47 systemctl restart firewalld.service systemctl restart firewalld 48 firewall-cmd --get-default-zone 49 firewall-cmd --get-active-zones 50 firewall-cmd --get-zones 51 firewall-cmd --get-zone-of-interface=ens33 52 firewall-cmd --list-all 53 firewall-cmd --list-all-zones 54 firewall-cmd --get-default-zone 55 firewall-cmd --get-active-zones 56 firewall-cmd --list-all 57 firewall-cmd --get-zones 58 firewall-cmd --list-all-zones\u2026","rel":"","context":"In &quot;FromSitesTree.com&quot;","block_context":{"text":"FromSitesTree.com","link":"http:\/\/bangla.sitestree.com\/?cat=1917"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":79083,"url":"http:\/\/bangla.sitestree.com\/?p=79083","url_meta":{"origin":79089,"position":4},"title":"Linux Intermediate 07 \u2014 IP Addresses, Routes, and Name Resolution","author":"Sayed","date":"November 17, 2026","format":false,"excerpt":"Separate the problems of link state, addressing, routing, name resolution, and listening services.","rel":"","context":"In &quot;Linux Intermediate&quot;","block_context":{"text":"Linux Intermediate","link":"http:\/\/bangla.sitestree.com\/?cat=1991"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":79094,"url":"http:\/\/bangla.sitestree.com\/?p=79094","url_meta":{"origin":79089,"position":5},"title":"Linux Advanced 09 \u2014 MariaDB Service Accounts and Restore Verification","author":"Sayed","date":"November 17, 2026","format":false,"excerpt":"Check a Linux-hosted MariaDB service, identify least-privilege database roles, and test a logical restore.","rel":"","context":"In &quot;Linux Advanced&quot;","block_context":{"text":"Linux Advanced","link":"http:\/\/bangla.sitestree.com\/?cat=1992"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"jetpack_featured_media_url":"","_links":{"self":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts\/79089","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=79089"}],"version-history":[{"count":0,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts\/79089\/revisions"}],"wp:attachment":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=79089"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=79089"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=79089"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}