{"id":21033,"date":"2025-10-02T09:21:11","date_gmt":"2025-10-02T09:21:11","guid":{"rendered":"https:\/\/www.webhosting.uk.com\/kb\/?p=21033"},"modified":"2026-06-03T10:03:59","modified_gmt":"2026-06-03T10:03:59","slug":"how-to-configure-firewall-rules-in-linux-ufw-firewalld-iptables","status":"publish","type":"post","link":"https:\/\/www.webhosting.uk.com\/kb\/how-to-configure-firewall-rules-in-linux-ufw-firewalld-iptables\/","title":{"rendered":"How to Configure Firewall Rules in Linux (UFW, firewalld, iptables)"},"content":{"rendered":"<p>Proper firewall configuration is critical for securing Linux servers, controlling network traffic, and preventing unauthorised access.<br \/>\nLinux provides multiple tools like UFW, firewalld, and iptables; each is designed for different levels of control and flexibility.<br \/>\nThis guide walks through configuration examples for all three, based on industry best practices and real-world administration experience.<\/p>\n<div class=\"more-tab-content\">\n<h2><strong><span class=\"cf0\">Table of Contents:<\/span><\/strong><\/h2>\n<ol>\n<li><a href=\"#firewall\">UFW (Uncomplicated Firewall)<\/a><\/li>\n<li><a href=\"#firewalld\">firewalld<\/a><\/li>\n<li><a href=\"#iptables\">iptables<\/a><a name=\"firewall\"><\/a><\/li>\n<li><a href=\"#management\">Best Practices for Firewall Management<\/a><\/li>\n<li><a href=\"#conclusion\">Conclusion<\/a><\/li>\n<\/ol>\n<\/div>\n<h3><strong>UFW (Uncomplicated Firewall)<\/strong><\/h3>\n<p>UFW is a user-friendly front-end for managing firewall rules, available by default on Ubuntu and Debian-based distributions. It simplifies configuration for administrators who prefer straightforward commands.<\/p>\n<p><strong>Steps to Configure UFW:<\/strong><\/p>\n<ol>\n<li>Enable and Verify UFW\n<pre>sudo ufw enable\r\nsudo ufw status verbose<\/pre>\n<p>The verbose flag displays detailed information about active rules and default policies.<\/li>\n<li>Allow or Deny Services:\n<pre>sudo ufw allow 22\/tcp\u00a0\u00a0\u00a0 # Allow SSH\r\nsudo ufw allow 80\/tcp\u00a0\u00a0\u00a0 # Allow HTTP\r\nsudo ufw allow 443\/tcp\u00a0\u00a0 # Allow HTTPS\r\nsudo ufw deny 23\/tcp\u00a0\u00a0\u00a0\u00a0 # Block Telnet<\/pre>\n<p>You can also specify a range or protocol when necessary:<\/p>\n<pre>sudo ufw allow 1000:2000\/tcp<\/pre>\n<\/li>\n<\/ol>\n<ol start=\"3\">\n<li>Manage and Reset Rules\n<ul>\n<li>\u00a0To delete a specific rule:\n<pre>sudo ufw delete allow 80\/tcp<\/pre>\n<\/li>\n<li>To reset all UFW configurations<a name=\"firewalld\"><\/a>:\n<pre>sudo ufw reset<\/pre>\n<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<p>Pro Tip:<br \/>\nBefore enabling UFW on a remote server, ensure that SSH (port 22) is allowed; otherwise, you may lose remote access.<\/p>\n<h3><strong>firewalld<\/strong><\/h3>\n<p>firewalld is the default firewall management tool for CentOS, RHEL, and Fedora. It organises rules into <em>zones<\/em> that define trust levels for different network connections.<\/p>\n<p><strong>Steps to Configure firewalld:<\/strong><\/p>\n<ol>\n<li>Enable and Check Status:\n<pre>sudo systemctl enable firewalld\r\nsudo systemctl start firewalld\r\nsudo firewall-cmd \u2013state<\/pre>\n<p>This confirms whether the firewalld service is running.<\/li>\n<li>View and Manage Zones\n<ul>\n<li>List all active zones:\n<pre>sudo firewall-cmd --get-active-zones<\/pre>\n<\/li>\n<li>Display rules for a specific zone:\n<pre>sudo firewall-cmd --zone=public --list-all<\/pre>\n<\/li>\n<\/ul>\n<\/li>\n<li>Allow or Block Services\n<ul>\n<li>To permanently allow HTTP and HTTPS traffic:\n<pre>sudo firewall-cmd --zone=public --add-service=http --permanent\r\nsudo firewall-cmd --zone=public --add-service=https --permanent\r\nsudo firewall-cmd --reload<\/pre>\n<\/li>\n<li>To block a specific service:\n<pre>sudo firewall-cmd --zone=public --remove-service=http --permanent\r\nsudo firewall-cmd --reload<\/pre>\n<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<p>Pro <a name=\"iptables\"><\/a>Tip:<br \/>\nAlways use the \u2018\u2014permanent\u2019 flag for configurations you want to persist after system reboots. Without it, rules apply only until the next restart.<\/p>\n<h3><strong>iptables<\/strong><\/h3>\n<p>iptables is a powerful, low-level firewall utility available on most Linux distributions. It provides granular control over network traffic and packet filtering but requires careful rule management.<\/p>\n<p><strong>Steps to Configure iptables:<\/strong><\/p>\n<ol>\n<li>List and Inspect Rules:\n<pre>sudo iptables -L -v -n<\/pre>\n<p>This displays all current rules along with packet and byte counters.<\/li>\n<li>Allow or Block Traffic\n<pre>sudo iptables -A INPUT -p tcp --dport 22 -j ACCEPT # Allow SSH\r\nsudo iptables -A INPUT -p tcp --dport 23 -j DROP # Block Telnet<\/pre>\n<\/li>\n<li>Allow Access from Specific IPs\n<pre>sudo iptables -A INPUT -p tcp -s 192.168.1.10 --dport 22 -j ACCEPT<\/pre>\n<\/li>\n<li>Delete and Save Rules:\n<ol>\n<li>\u00a0To remove a specific rule:\n<pre>sudo iptables -D INPUT -p tcp --dport 22 -j ACCEPT<\/pre>\n<\/li>\n<li>Save the current configuration:\n<ul>\n<li>On Debian\/Ubuntu:\n<pre>sudo iptables-save &gt; \/etc\/iptables\/rules.v4<\/pre>\n<\/li>\n<li>On RHEL\/CentOS:\n<pre>sudo service iptables save<\/pre>\n<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<\/li>\n<\/ol>\n<p>Expert <a name=\"management\"><\/a>Tip:<br \/>\nAlways keep console access (or recovery mode) available when editing iptables remotely; misconfigured rules can lock you out of the server.<\/p>\n<h3><strong>Best Practices for Firewall Management<\/strong><\/h3>\n<ol>\n<li>Test rules in a staging environment before deploying to production.<\/li>\n<li>Restrict SSH and critical ports to specific trusted IP addresses.<\/li>\n<li>Use persistent configurations (&#8211;permanent in firewalld or saved rules in iptables) to retain rules after reboots.<\/li>\n<li>Back up configurations regularly:\n<ul>\n<li>UFW:\n<pre>sudo ufw status &gt; ~\/ufw-backup.txt<\/pre>\n<\/li>\n<li><a name=\"conclusion\"><\/a>iptables:\n<pre>sudo iptables-save &gt; ~\/iptables-backup.v4<\/pre>\n<\/li>\n<\/ul>\n<\/li>\n<li>Prefer UFW or firewalld for simple use cases; use iptables only for advanced traffic management.<\/li>\n<\/ol>\n<h3><strong>Conclusion<\/strong><\/h3>\n<p>This way, configuring firewall rules in Linux is essential for protecting servers from unauthorised access and maintaining a secure network perimeter.<br \/>\nBy using UFW, firewalld, or iptables according to your environment and skill level, you can effectively manage inbound and outbound traffic, reduce vulnerabilities, and maintain a strong security posture.<\/p>\n<div style=\"background: #E6F0FF; padding: 15px; border-left: 4px solid #0047BA; margin: 20px 0;\"><strong>Managing firewall rules and network security on Linux?<\/strong><br \/>\nA <a href=\"https:\/\/www.webhosting.uk.com\/linux-vps\">Linux VPS Hosting<\/a> solution provides full root access and the control needed to manage firewalls, services and server security.<\/div>\n<p style=\"text-align: center;\"><em><strong>Concerned about server security? Learn <a href=\"https:\/\/www.webhosting.uk.com\/kb\/how-to-check-if-your-linux-server-is-under-ddos-attack\/\"> How to check if your Linux server is under a DDOS attack<\/a><\/strong><\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Proper firewall configuration is critical for securing Linux servers, controlling network traffic, and preventing unauthorised access. Linux provides multiple tools like UFW, firewalld, and iptables; each is designed for different&hellip;<\/p>\n<p><a href=\"https:\/\/www.webhosting.uk.com\/kb\/how-to-configure-firewall-rules-in-linux-ufw-firewalld-iptables\/\" class=\"more-link\">Read More<\/a><\/p>\n<div class='heateorSssClear'><\/div><div  class='heateor_sss_sharing_container heateor_sss_horizontal_sharing' data-heateor-sss-href='https:\/\/www.webhosting.uk.com\/kb\/how-to-configure-firewall-rules-in-linux-ufw-firewalld-iptables\/'><div class='heateor_sss_sharing_title' style=\"font-weight:bold\" >Spread the love<\/div><div class=\"heateor_sss_sharing_ul\"><a aria-label=\"Facebook\" class=\"heateor_sss_facebook\" href=\"https:\/\/www.facebook.com\/sharer\/sharer.php?u=https%3A%2F%2Fwww.webhosting.uk.com%2Fkb%2Fhow-to-configure-firewall-rules-in-linux-ufw-firewalld-iptables%2F\" title=\"Facebook\" rel=\"nofollow noopener\" target=\"_blank\" style=\"font-size:32px!important;box-shadow:none;display:inline-block;vertical-align:middle\"><span class=\"heateor_sss_svg\" style=\"background-color:#0765FE;width:40px;height:40px;display:inline-block;opacity:1;float:left;font-size:32px;box-shadow:none;display:inline-block;font-size:16px;padding:0 4px;vertical-align:middle;background-repeat:repeat;overflow:hidden;padding:0;cursor:pointer;box-sizing:content-box\"><svg style=\"display:block;\" focusable=\"false\" aria-hidden=\"true\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"100%\" height=\"100%\" viewBox=\"0 0 32 32\"><path fill=\"#fff\" d=\"M28 16c0-6.627-5.373-12-12-12S4 9.373 4 16c0 5.628 3.875 10.35 9.101 11.647v-7.98h-2.474V16H13.1v-1.58c0-4.085 1.849-5.978 5.859-5.978.76 0 2.072.15 2.608.298v3.325c-.283-.03-.775-.045-1.386-.045-1.967 0-2.728.745-2.728 2.683V16h3.92l-.673 3.667h-3.247v8.245C23.395 27.195 28 22.135 28 16Z\"><\/path><\/svg><\/span><\/a><a aria-label=\"X\" class=\"heateor_sss_button_x\" href=\"https:\/\/twitter.com\/intent\/tweet?text=How%20to%20Apply%20Firewall%20Rules%20in%20Linux%20with%20UFW%2C%20firewalld%20%26%20iptables&url=https%3A%2F%2Fwww.webhosting.uk.com%2Fkb%2Fhow-to-configure-firewall-rules-in-linux-ufw-firewalld-iptables%2F\" title=\"X\" rel=\"nofollow noopener\" target=\"_blank\" style=\"font-size:32px!important;box-shadow:none;display:inline-block;vertical-align:middle\"><span class=\"heateor_sss_svg heateor_sss_s__default heateor_sss_s_x\" style=\"background-color:#2a2a2a;width:40px;height:40px;display:inline-block;opacity:1;float:left;font-size:32px;box-shadow:none;display:inline-block;font-size:16px;padding:0 4px;vertical-align:middle;background-repeat:repeat;overflow:hidden;padding:0;cursor:pointer;box-sizing:content-box\"><svg width=\"100%\" height=\"100%\" style=\"display:block;\" focusable=\"false\" aria-hidden=\"true\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 32 32\"><path fill=\"#fff\" d=\"M21.751 7h3.067l-6.7 7.658L26 25.078h-6.172l-4.833-6.32-5.531 6.32h-3.07l7.167-8.19L6 7h6.328l4.37 5.777L21.75 7Zm-1.076 16.242h1.7L11.404 8.74H9.58l11.094 14.503Z\"><\/path><\/svg><\/span><\/a><a aria-label=\"Linkedin\" class=\"heateor_sss_button_linkedin\" href=\"https:\/\/www.linkedin.com\/sharing\/share-offsite\/?url=https%3A%2F%2Fwww.webhosting.uk.com%2Fkb%2Fhow-to-configure-firewall-rules-in-linux-ufw-firewalld-iptables%2F\" title=\"Linkedin\" rel=\"nofollow noopener\" target=\"_blank\" style=\"font-size:32px!important;box-shadow:none;display:inline-block;vertical-align:middle\"><span class=\"heateor_sss_svg heateor_sss_s__default heateor_sss_s_linkedin\" style=\"background-color:#0077b5;width:40px;height:40px;display:inline-block;opacity:1;float:left;font-size:32px;box-shadow:none;display:inline-block;font-size:16px;padding:0 4px;vertical-align:middle;background-repeat:repeat;overflow:hidden;padding:0;cursor:pointer;box-sizing:content-box\"><svg style=\"display:block;\" focusable=\"false\" aria-hidden=\"true\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"100%\" height=\"100%\" viewBox=\"0 0 32 32\"><path d=\"M6.227 12.61h4.19v13.48h-4.19V12.61zm2.095-6.7a2.43 2.43 0 0 1 0 4.86c-1.344 0-2.428-1.09-2.428-2.43s1.084-2.43 2.428-2.43m4.72 6.7h4.02v1.84h.058c.56-1.058 1.927-2.176 3.965-2.176 4.238 0 5.02 2.792 5.02 6.42v7.395h-4.183v-6.56c0-1.564-.03-3.574-2.178-3.574-2.18 0-2.514 1.7-2.514 3.46v6.668h-4.187V12.61z\" fill=\"#fff\"><\/path><\/svg><\/span><\/a><\/div><div class=\"heateorSssClear\"><\/div><\/div><div class='heateorSssClear'><\/div>","protected":false},"author":28,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1409],"tags":[204],"class_list":["post-21033","post","type-post","status-publish","format-standard","hentry","category-server","tag-linux"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v27.9 (Yoast SEO v27.9) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>How to Apply Firewall Rules in Linux with UFW, firewalld &amp; iptables<\/title>\n<meta name=\"description\" content=\"Learn how to Apply firewall rules in Linux using UFW, firewalld, and iptables. Step-by-step guide to secure your Linux server effectively.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.webhosting.uk.com\/kb\/how-to-configure-firewall-rules-in-linux-ufw-firewalld-iptables\/\" \/>\n<meta property=\"og:locale\" content=\"en_GB\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Apply Firewall Rules in Linux with UFW, firewalld &amp; iptables\" \/>\n<meta property=\"og:description\" content=\"Learn how to configure firewall rules in Linux using UFW, firewalld, and iptables. Step-by-step guide to secure your Linux server effectively.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.webhosting.uk.com\/kb\/how-to-configure-firewall-rules-in-linux-ufw-firewalld-iptables\/\" \/>\n<meta property=\"og:site_name\" content=\"Webhosting UK Knowledge Base\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/webhostingukcom\" \/>\n<meta property=\"article:published_time\" content=\"2025-10-02T09:21:11+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-06-03T10:03:59+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.webhosting.uk.com\/kb\/wp-content\/uploads\/2023\/08\/WHUK-logo-1.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"628\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Victor G\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:title\" content=\"How to Apply Firewall Rules in Linux with UFW, firewalld &amp; iptables\" \/>\n<meta name=\"twitter:description\" content=\"Learn how to configure firewall rules in Linux using UFW, firewalld, and iptables. Step-by-step guide to secure your Linux server effectively.\" \/>\n<meta name=\"twitter:creator\" content=\"@WebhostingUKcom\" \/>\n<meta name=\"twitter:site\" content=\"@WebhostingUKcom\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.webhosting.uk.com\\\/kb\\\/how-to-configure-firewall-rules-in-linux-ufw-firewalld-iptables\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.webhosting.uk.com\\\/kb\\\/how-to-configure-firewall-rules-in-linux-ufw-firewalld-iptables\\\/\"},\"author\":{\"name\":\"Victor G\",\"@id\":\"https:\\\/\\\/www.webhosting.uk.com\\\/kb\\\/#\\\/schema\\\/person\\\/ea067684eae84c2b8b49a81c69407297\"},\"headline\":\"How to Configure Firewall Rules in Linux (UFW, firewalld, iptables)\",\"datePublished\":\"2025-10-02T09:21:11+00:00\",\"dateModified\":\"2026-06-03T10:03:59+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.webhosting.uk.com\\\/kb\\\/how-to-configure-firewall-rules-in-linux-ufw-firewalld-iptables\\\/\"},\"wordCount\":528,\"publisher\":{\"@id\":\"https:\\\/\\\/www.webhosting.uk.com\\\/kb\\\/#organization\"},\"keywords\":[\"Linux\"],\"articleSection\":[\"Servers, Hosting &amp; Email\"],\"inLanguage\":\"en-GB\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.webhosting.uk.com\\\/kb\\\/how-to-configure-firewall-rules-in-linux-ufw-firewalld-iptables\\\/\",\"url\":\"https:\\\/\\\/www.webhosting.uk.com\\\/kb\\\/how-to-configure-firewall-rules-in-linux-ufw-firewalld-iptables\\\/\",\"name\":\"How to Apply Firewall Rules in Linux with UFW, firewalld & iptables\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.webhosting.uk.com\\\/kb\\\/#website\"},\"datePublished\":\"2025-10-02T09:21:11+00:00\",\"dateModified\":\"2026-06-03T10:03:59+00:00\",\"description\":\"Learn how to Apply firewall rules in Linux using UFW, firewalld, and iptables. Step-by-step guide to secure your Linux server effectively.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.webhosting.uk.com\\\/kb\\\/how-to-configure-firewall-rules-in-linux-ufw-firewalld-iptables\\\/#breadcrumb\"},\"inLanguage\":\"en-GB\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.webhosting.uk.com\\\/kb\\\/how-to-configure-firewall-rules-in-linux-ufw-firewalld-iptables\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.webhosting.uk.com\\\/kb\\\/how-to-configure-firewall-rules-in-linux-ufw-firewalld-iptables\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.webhosting.uk.com\\\/kb\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Configure Firewall Rules in Linux (UFW, firewalld, iptables)\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.webhosting.uk.com\\\/kb\\\/#website\",\"url\":\"https:\\\/\\\/www.webhosting.uk.com\\\/kb\\\/\",\"name\":\"Webhosting UK Knowledge Base\",\"description\":\"Expert Insights on Hosting, Development, Security, Marketing, and SEO\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.webhosting.uk.com\\\/kb\\\/#organization\"},\"alternateName\":\"WHUK\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.webhosting.uk.com\\\/kb\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-GB\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.webhosting.uk.com\\\/kb\\\/#organization\",\"name\":\"Webhosting UK\",\"alternateName\":\"WHUK\",\"url\":\"https:\\\/\\\/www.webhosting.uk.com\\\/kb\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-GB\",\"@id\":\"https:\\\/\\\/www.webhosting.uk.com\\\/kb\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.webhosting.uk.com\\\/kb\\\/wp-content\\\/uploads\\\/2023\\\/08\\\/WHUK-logo-1.png\",\"contentUrl\":\"https:\\\/\\\/www.webhosting.uk.com\\\/kb\\\/wp-content\\\/uploads\\\/2023\\\/08\\\/WHUK-logo-1.png\",\"width\":1200,\"height\":628,\"caption\":\"Webhosting UK\"},\"image\":{\"@id\":\"https:\\\/\\\/www.webhosting.uk.com\\\/kb\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/webhostingukcom\",\"https:\\\/\\\/x.com\\\/WebhostingUKcom\",\"https:\\\/\\\/www.youtube.com\\\/c\\\/webhostinguk\",\"https:\\\/\\\/www.linkedin.com\\\/company\\\/webhosting-uk-com-ltd\\\/\",\"https:\\\/\\\/www.instagram.com\\\/webhosting_uk\\\/\",\"https:\\\/\\\/www.tiktok.com\\\/@webhostinguk\"],\"description\":\"Fast, reliable, and cost-effective website hosting services with Webhosting UK. Committed to providing you secure support around the clock.\",\"email\":\"sales@webhosting.uk.com\",\"telephone\":\"0800 862 0890\",\"legalName\":\"Webhosting UK\",\"foundingDate\":\"2001-02-07\",\"numberOfEmployees\":{\"@type\":\"QuantitativeValue\",\"minValue\":\"51\",\"maxValue\":\"200\"}},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.webhosting.uk.com\\\/kb\\\/#\\\/schema\\\/person\\\/ea067684eae84c2b8b49a81c69407297\",\"name\":\"Victor G\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-GB\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/9bf0713adcbaded4878508c93d93927ecbfa4f74548fd9bcee41478d8768bd66?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/9bf0713adcbaded4878508c93d93927ecbfa4f74548fd9bcee41478d8768bd66?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/9bf0713adcbaded4878508c93d93927ecbfa4f74548fd9bcee41478d8768bd66?s=96&d=mm&r=g\",\"caption\":\"Victor G\"}}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"How to Apply Firewall Rules in Linux with UFW, firewalld & iptables","description":"Learn how to Apply firewall rules in Linux using UFW, firewalld, and iptables. Step-by-step guide to secure your Linux server effectively.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.webhosting.uk.com\/kb\/how-to-configure-firewall-rules-in-linux-ufw-firewalld-iptables\/","og_locale":"en_GB","og_type":"article","og_title":"How to Apply Firewall Rules in Linux with UFW, firewalld & iptables","og_description":"Learn how to configure firewall rules in Linux using UFW, firewalld, and iptables. Step-by-step guide to secure your Linux server effectively.","og_url":"https:\/\/www.webhosting.uk.com\/kb\/how-to-configure-firewall-rules-in-linux-ufw-firewalld-iptables\/","og_site_name":"Webhosting UK Knowledge Base","article_publisher":"https:\/\/www.facebook.com\/webhostingukcom","article_published_time":"2025-10-02T09:21:11+00:00","article_modified_time":"2026-06-03T10:03:59+00:00","og_image":[{"width":1200,"height":628,"url":"https:\/\/www.webhosting.uk.com\/kb\/wp-content\/uploads\/2023\/08\/WHUK-logo-1.png","type":"image\/png"}],"author":"Victor G","twitter_card":"summary_large_image","twitter_title":"How to Apply Firewall Rules in Linux with UFW, firewalld & iptables","twitter_description":"Learn how to configure firewall rules in Linux using UFW, firewalld, and iptables. Step-by-step guide to secure your Linux server effectively.","twitter_creator":"@WebhostingUKcom","twitter_site":"@WebhostingUKcom","schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.webhosting.uk.com\/kb\/how-to-configure-firewall-rules-in-linux-ufw-firewalld-iptables\/#article","isPartOf":{"@id":"https:\/\/www.webhosting.uk.com\/kb\/how-to-configure-firewall-rules-in-linux-ufw-firewalld-iptables\/"},"author":{"name":"Victor G","@id":"https:\/\/www.webhosting.uk.com\/kb\/#\/schema\/person\/ea067684eae84c2b8b49a81c69407297"},"headline":"How to Configure Firewall Rules in Linux (UFW, firewalld, iptables)","datePublished":"2025-10-02T09:21:11+00:00","dateModified":"2026-06-03T10:03:59+00:00","mainEntityOfPage":{"@id":"https:\/\/www.webhosting.uk.com\/kb\/how-to-configure-firewall-rules-in-linux-ufw-firewalld-iptables\/"},"wordCount":528,"publisher":{"@id":"https:\/\/www.webhosting.uk.com\/kb\/#organization"},"keywords":["Linux"],"articleSection":["Servers, Hosting &amp; Email"],"inLanguage":"en-GB"},{"@type":"WebPage","@id":"https:\/\/www.webhosting.uk.com\/kb\/how-to-configure-firewall-rules-in-linux-ufw-firewalld-iptables\/","url":"https:\/\/www.webhosting.uk.com\/kb\/how-to-configure-firewall-rules-in-linux-ufw-firewalld-iptables\/","name":"How to Apply Firewall Rules in Linux with UFW, firewalld & iptables","isPartOf":{"@id":"https:\/\/www.webhosting.uk.com\/kb\/#website"},"datePublished":"2025-10-02T09:21:11+00:00","dateModified":"2026-06-03T10:03:59+00:00","description":"Learn how to Apply firewall rules in Linux using UFW, firewalld, and iptables. Step-by-step guide to secure your Linux server effectively.","breadcrumb":{"@id":"https:\/\/www.webhosting.uk.com\/kb\/how-to-configure-firewall-rules-in-linux-ufw-firewalld-iptables\/#breadcrumb"},"inLanguage":"en-GB","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.webhosting.uk.com\/kb\/how-to-configure-firewall-rules-in-linux-ufw-firewalld-iptables\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.webhosting.uk.com\/kb\/how-to-configure-firewall-rules-in-linux-ufw-firewalld-iptables\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.webhosting.uk.com\/kb\/"},{"@type":"ListItem","position":2,"name":"How to Configure Firewall Rules in Linux (UFW, firewalld, iptables)"}]},{"@type":"WebSite","@id":"https:\/\/www.webhosting.uk.com\/kb\/#website","url":"https:\/\/www.webhosting.uk.com\/kb\/","name":"Webhosting UK Knowledge Base","description":"Expert Insights on Hosting, Development, Security, Marketing, and SEO","publisher":{"@id":"https:\/\/www.webhosting.uk.com\/kb\/#organization"},"alternateName":"WHUK","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.webhosting.uk.com\/kb\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-GB"},{"@type":"Organization","@id":"https:\/\/www.webhosting.uk.com\/kb\/#organization","name":"Webhosting UK","alternateName":"WHUK","url":"https:\/\/www.webhosting.uk.com\/kb\/","logo":{"@type":"ImageObject","inLanguage":"en-GB","@id":"https:\/\/www.webhosting.uk.com\/kb\/#\/schema\/logo\/image\/","url":"https:\/\/www.webhosting.uk.com\/kb\/wp-content\/uploads\/2023\/08\/WHUK-logo-1.png","contentUrl":"https:\/\/www.webhosting.uk.com\/kb\/wp-content\/uploads\/2023\/08\/WHUK-logo-1.png","width":1200,"height":628,"caption":"Webhosting UK"},"image":{"@id":"https:\/\/www.webhosting.uk.com\/kb\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/webhostingukcom","https:\/\/x.com\/WebhostingUKcom","https:\/\/www.youtube.com\/c\/webhostinguk","https:\/\/www.linkedin.com\/company\/webhosting-uk-com-ltd\/","https:\/\/www.instagram.com\/webhosting_uk\/","https:\/\/www.tiktok.com\/@webhostinguk"],"description":"Fast, reliable, and cost-effective website hosting services with Webhosting UK. Committed to providing you secure support around the clock.","email":"sales@webhosting.uk.com","telephone":"0800 862 0890","legalName":"Webhosting UK","foundingDate":"2001-02-07","numberOfEmployees":{"@type":"QuantitativeValue","minValue":"51","maxValue":"200"}},{"@type":"Person","@id":"https:\/\/www.webhosting.uk.com\/kb\/#\/schema\/person\/ea067684eae84c2b8b49a81c69407297","name":"Victor G","image":{"@type":"ImageObject","inLanguage":"en-GB","@id":"https:\/\/secure.gravatar.com\/avatar\/9bf0713adcbaded4878508c93d93927ecbfa4f74548fd9bcee41478d8768bd66?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/9bf0713adcbaded4878508c93d93927ecbfa4f74548fd9bcee41478d8768bd66?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/9bf0713adcbaded4878508c93d93927ecbfa4f74548fd9bcee41478d8768bd66?s=96&d=mm&r=g","caption":"Victor G"}}]}},"_links":{"self":[{"href":"https:\/\/www.webhosting.uk.com\/kb\/wp-json\/wp\/v2\/posts\/21033","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.webhosting.uk.com\/kb\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.webhosting.uk.com\/kb\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.webhosting.uk.com\/kb\/wp-json\/wp\/v2\/users\/28"}],"replies":[{"embeddable":true,"href":"https:\/\/www.webhosting.uk.com\/kb\/wp-json\/wp\/v2\/comments?post=21033"}],"version-history":[{"count":7,"href":"https:\/\/www.webhosting.uk.com\/kb\/wp-json\/wp\/v2\/posts\/21033\/revisions"}],"predecessor-version":[{"id":22725,"href":"https:\/\/www.webhosting.uk.com\/kb\/wp-json\/wp\/v2\/posts\/21033\/revisions\/22725"}],"wp:attachment":[{"href":"https:\/\/www.webhosting.uk.com\/kb\/wp-json\/wp\/v2\/media?parent=21033"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.webhosting.uk.com\/kb\/wp-json\/wp\/v2\/categories?post=21033"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.webhosting.uk.com\/kb\/wp-json\/wp\/v2\/tags?post=21033"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}