{"id":4499,"date":"2021-02-15T10:40:26","date_gmt":"2021-02-15T10:40:26","guid":{"rendered":"https:\/\/linuxways.net\/?p=4499"},"modified":"2021-02-15T10:44:12","modified_gmt":"2021-02-15T10:44:12","slug":"how-to-easily-manage-firewall-rules-with-ufw-on-red-hat-enterprise-linux-8","status":"publish","type":"post","link":"https:\/\/linuxways.net\/de\/red-hat\/how-to-easily-manage-firewall-rules-with-ufw-on-red-hat-enterprise-linux-8\/","title":{"rendered":"How to Easily Manage Firewall Rules with UFW on Red Hat Enterprise Linux 8"},"content":{"rendered":"<p>UFW stands for Uncomplicated FireWall &#8212; and as the name implies, it makes firewall management very easy. UFW was developed by Canonical and is available by default on all recent Ubuntu versions. In this guide, we are going to install UFW on Red Hat Enterprise Linux (RHEL) 8 through Snaps.<\/p>\n<p>Snaps can be likened to containers for packaging applications with everything that they require to run successfully across multiple Linux distributions. To use snaps, you must install snapd.<\/p>\n<h2>Install Snapd<\/h2>\n<p>Snapd is a background process that manages snaps. To install snapd on RHEL 8, you would first need to add the Extra Packages for Enterprise Linux (EPEL) repository as follows.<\/p>\n<pre>$ <strong>sudo dnf install https:\/\/dl.fedoraproject.org\/pub\/epel\/epel-release-latest-8.noarch.rpm<\/strong><\/pre>\n<p><strong><img loading=\"lazy\" decoding=\"async\" width=\"737\" height=\"293\" class=\"wp-image-4500\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/02\/word-image-282.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/02\/word-image-282.png 737w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/02\/word-image-282-300x119.png 300w\" sizes=\"auto, (max-width: 737px) 100vw, 737px\" \/><\/strong><\/p>\n<p>When prompted, enter <strong>y<\/strong> to continue. Once the EPEL installation completes successfully, run the next command to update packages to the latest version.<\/p>\n<pre>$<strong> sudo dnf upgrade<\/strong><\/pre>\n<p><strong><img loading=\"lazy\" decoding=\"async\" width=\"653\" height=\"53\" class=\"wp-image-4501\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/02\/word-image-283.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/02\/word-image-283.png 653w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/02\/word-image-283-300x24.png 300w\" sizes=\"auto, (max-width: 653px) 100vw, 653px\" \/><\/strong><\/p>\n<p>You may now install snapd as follows.<\/p>\n<pre>$ <strong>sudo yum install snapd<\/strong><\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-4517 size-full\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/02\/Install-Snapd.jpg\" alt=\"Install Snapd\" width=\"862\" height=\"339\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/02\/Install-Snapd.jpg 862w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/02\/Install-Snapd-300x118.jpg 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/02\/Install-Snapd-768x302.jpg 768w\" sizes=\"auto, (max-width: 862px) 100vw, 862px\" \/><\/p>\n<p>When prompted, enter <strong>y <\/strong>to proceed with the installation.<\/p>\n<p>After the snapd installation completes successfully, run the next command to enable snapd.socket which manages snap communications.<\/p>\n<pre>$ <strong>sudo systemctl enable --now snapd.socket<\/strong><\/pre>\n<p><strong><img loading=\"lazy\" decoding=\"async\" width=\"669\" height=\"53\" class=\"wp-image-4502\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/02\/word-image-284.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/02\/word-image-284.png 669w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/02\/word-image-284-300x24.png 300w\" sizes=\"auto, (max-width: 669px) 100vw, 669px\" \/><\/strong><\/p>\n<p>You should see a message indicating that a symlink was created.<\/p>\n<p>You may now log out and log in again so that snap\u2019s paths can be updated.<\/p>\n<h2>Install UFW<\/h2>\n<p>The following command will install UFW on RHEL 8.<\/p>\n<pre>$ <strong>sudo snap install ufw<\/strong><\/pre>\n<p><strong><img loading=\"lazy\" decoding=\"async\" width=\"585\" height=\"53\" class=\"wp-image-4503\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/02\/word-image-285.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/02\/word-image-285.png 585w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/02\/word-image-285-300x27.png 300w\" sizes=\"auto, (max-width: 585px) 100vw, 585px\" \/><\/strong><\/p>\n<p>Once installed, run the next command to check the status of UFW.<\/p>\n<pre>$ <strong>sudo ufw status<\/strong><\/pre>\n<p><strong>Note: <\/strong>If you get an error saying, \u201cufw: command not found,\u201d it may be a problem with ufw\u2019s paths. As a workaround, run the command below to create a symbolic link to <strong>\/var\/lib\/snapd\/snap\/bin\/ufw<\/strong> from <strong>\/usr\/bin\/ufw<\/strong>. After that, try to check the status of ufw again and it should work fine.<\/p>\n<pre>$<strong> sudo ln -s \/var\/lib\/snapd\/snap\/bin\/ufw \/usr\/bin\/ufw<\/strong><\/pre>\n<p><strong><img loading=\"lazy\" decoding=\"async\" width=\"683\" height=\"85\" class=\"wp-image-4504\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/02\/word-image-286.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/02\/word-image-286.png 683w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/02\/word-image-286-300x37.png 300w\" sizes=\"auto, (max-width: 683px) 100vw, 683px\" \/><\/strong><\/p>\n<p>To enable UFW and configure it to always start at system boot, run:<\/p>\n<pre>$ <strong>sudo ufw enable<\/strong><\/pre>\n<p><strong><img loading=\"lazy\" decoding=\"async\" width=\"635\" height=\"53\" class=\"wp-image-4505\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/02\/word-image-287.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/02\/word-image-287.png 635w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/02\/word-image-287-300x25.png 300w\" sizes=\"auto, (max-width: 635px) 100vw, 635px\" \/><\/strong><\/p>\n<p>If your goal is to replace the built-in firewalld in RHEL 8 with UFW, then you may want to disable firewalld by running the following commands.<\/p>\n<pre>$<strong> sudo systemctl stop firewalld <\/strong>\n\n$<strong> sudo systemctl disable firewalld<\/strong><\/pre>\n<p><strong><img loading=\"lazy\" decoding=\"async\" width=\"589\" height=\"67\" class=\"wp-image-4506\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/02\/word-image-288.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/02\/word-image-288.png 589w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/02\/word-image-288-300x34.png 300w\" sizes=\"auto, (max-width: 589px) 100vw, 589px\" \/><\/strong><\/p>\n<p>By default, UFW denies all incoming traffic and allows outgoing traffic. However, you can change this default behaviour if you wish. To deny outgoing traffic for example, run:<\/p>\n<pre>$<strong> sudo ufw default deny outgoing<\/strong><\/pre>\n<p>Run the next command to list UFW application profiles.<\/p>\n<pre>$<strong> sudo ufw app list<\/strong><\/pre>\n<p><strong><img loading=\"lazy\" decoding=\"async\" width=\"593\" height=\"243\" class=\"wp-image-4507\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/02\/word-image-289.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/02\/word-image-289.png 593w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/02\/word-image-289-300x123.png 300w\" sizes=\"auto, (max-width: 593px) 100vw, 593px\" \/><\/strong><\/p>\n<p>For instance, to deny access to <strong>Bonjour<\/strong>, the following command would suffice.<\/p>\n<pre>$<strong> sudo ufw deny Bonjour<\/strong><\/pre>\n<p><strong><img loading=\"lazy\" decoding=\"async\" width=\"475\" height=\"51\" class=\"wp-image-4508\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/02\/word-image-290.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/02\/word-image-290.png 475w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/02\/word-image-290-300x32.png 300w\" sizes=\"auto, (max-width: 475px) 100vw, 475px\" \/><\/strong><\/p>\n<p>You could also specify port numbers to allow or deny traffic on as follows.<\/p>\n<pre>$<strong> sudo ufw deny 25<\/strong><\/pre>\n<p><strong><img loading=\"lazy\" decoding=\"async\" width=\"437\" height=\"51\" class=\"wp-image-4509\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/02\/word-image-291.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/02\/word-image-291.png 437w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/02\/word-image-291-300x35.png 300w\" sizes=\"auto, (max-width: 437px) 100vw, 437px\" \/><\/strong><\/p>\n<pre>$<strong> sudo ufw allow 22<\/strong><\/pre>\n<p><strong><img loading=\"lazy\" decoding=\"async\" width=\"421\" height=\"53\" class=\"wp-image-4510\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/02\/word-image-292.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/02\/word-image-292.png 421w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/02\/word-image-292-300x38.png 300w\" sizes=\"auto, (max-width: 421px) 100vw, 421px\" \/><\/strong><\/p>\n<p>Here\u2019s another example that allows traffic on TCP port 80.<\/p>\n<pre>$<strong> sudo ufw allow 80\/tcp<\/strong><\/pre>\n<p><strong><img loading=\"lazy\" decoding=\"async\" width=\"423\" height=\"53\" class=\"wp-image-4511\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/02\/word-image-293.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/02\/word-image-293.png 423w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/02\/word-image-293-300x38.png 300w\" sizes=\"auto, (max-width: 423px) 100vw, 423px\" \/><\/strong><\/p>\n<p>After adding your firewall rules, you may run the next command to see detailed information about the status of UFW.<\/p>\n<pre>$ <strong>sudo ufw status verbose<\/strong><\/pre>\n<p><strong><img loading=\"lazy\" decoding=\"async\" width=\"541\" height=\"369\" class=\"wp-image-4512\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/02\/word-image-294.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/02\/word-image-294.png 541w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/02\/word-image-294-300x205.png 300w\" sizes=\"auto, (max-width: 541px) 100vw, 541px\" \/><\/strong><\/p>\n<p>To view additional usage information for UFW, run:<\/p>\n<pre>$ <strong>ufw --help<\/strong><\/pre>\n<p><strong><img loading=\"lazy\" decoding=\"async\" width=\"577\" height=\"275\" class=\"wp-image-4513\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/02\/word-image-295.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/02\/word-image-295.png 577w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/02\/word-image-295-300x143.png 300w\" sizes=\"auto, (max-width: 577px) 100vw, 577px\" \/><\/strong><\/p>\n<p>You could also review the official UFW manual pages at the following link.<\/p>\n<pre><a href=\"http:\/\/manpages.ubuntu.com\/manpages\/hirsute\/en\/man8\/ufw.8.html\">http:\/\/manpages.ubuntu.com\/manpages\/hirsute\/en\/man8\/ufw.8.html<\/a><\/pre>\n<h2>Conclusion<\/h2>\n<p>As you have seen, getting started with UFW on Red Hat Enterprise Linux 8 is not difficult. UFW may not be intended to provide complete firewall functionality, but it does provide an easy way to create and manage simple firewall rules. Share your thoughts with us.<\/p>","protected":false},"excerpt":{"rendered":"<p>UFW stands for Uncomplicated FireWall &#8212; and as the name implies, it makes firewall management very easy. UFW was developed by Canonical and is available by default on&hellip;<\/p>","protected":false},"author":28,"featured_media":4515,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[165],"tags":[197,198,196],"class_list":["post-4499","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-red-hat","tag-firewall","tag-red-hat-enterprise-linux-8","tag-ufw"],"_links":{"self":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/4499","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/users\/28"}],"replies":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/comments?post=4499"}],"version-history":[{"count":0,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/4499\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media\/4515"}],"wp:attachment":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media?parent=4499"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/categories?post=4499"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/tags?post=4499"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}