{"id":24007,"date":"2024-01-31T13:20:24","date_gmt":"2024-01-31T13:20:24","guid":{"rendered":"https:\/\/linuxways.net\/?p=24007"},"modified":"2024-01-31T13:26:09","modified_gmt":"2024-01-31T13:26:09","slug":"install-setup-firewall-with-ufw-debian-12","status":"publish","type":"post","link":"https:\/\/linuxways.net\/de\/debian\/install-setup-firewall-with-ufw-debian-12\/","title":{"rendered":"How to Install and Setup Firewall With UFW on Debian 12"},"content":{"rendered":"<p>Every internet-connected device needs a <strong>Firewall <\/strong>for security. The <strong>Firewall <\/strong>in Linux is a network security system that blocks the incoming and outgoing traffic to secure the network. It filters the dangerous traffic based on predefined rules to protect the device from any unauthorized access. It can be used to block and allow specific ports, IP addresses, and services.<\/p>\n<p>Debian has <strong>iptables<\/strong>, <strong>nftables<\/strong>, and <strong>firewalld<\/strong> that contain the <strong>Firewall <\/strong>rules and are used to configure the <strong>Firewall<\/strong> of the network. <strong>UFW <\/strong>is the best alternative to these utilities since these utilities have quite complex syntax. Using <strong>UFW<\/strong>, you can easily manage both incoming and outgoing traffic by defining different rules.<\/p>\n<h2><strong>Quick Outline<\/strong><\/h2>\n<ul>\n<li><a href=\"#post-24007-_brnqf02wyw4c\"><strong>What is UFW<\/strong><\/a><\/li>\n<li><a href=\"#post-24007-_vpg044norczn\"><strong>How to Install UFW on Debian 12 Using CLI<\/strong><\/a><\/li>\n<li><a href=\"#post-24007-_iczb2lb4bfkz\"><strong>How to Setup Firewall With UFW on Debian 12 Using CLI<\/strong><\/a><\/li>\n<li><a href=\"#post-24007-_uvsmmwsf4h98\"><strong>How to Install Graphical Application of UFW on Debian 12<\/strong><\/a><\/li>\n<li><a href=\"#post-24007-_ax95c1rf6axh\"><strong>How to Setup Firewall with UFW on Debian 12 Using GUI <\/strong><\/a><\/li>\n<li><a href=\"#post-24007-_32zk4uu480f\"><strong>How to Uninstall UFW on Debian 12<\/strong><\/a><\/li>\n<li><a href=\"#post-24007-_aui19by6fbit\"><strong>Conclusion<\/strong><\/a><\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<h2><a id=\"post-24007-_brnqf02wyw4c\"><\/a><strong>What is UFW <\/strong><\/h2>\n<p><strong>UFW<\/strong> is a tool in Linux that manages the Netfilter firewall and is known as an <strong>Uncomplicated Firewall<\/strong>. As the name suggests, the <strong>UFW<\/strong> provides the easy-to-use command line interface to manage the firewall on your system. It uses the simple command and iptables for configuration and protects your system from external attacks by blocking the connections. You can add and delete rules to create <strong>IPv4<\/strong> and <strong>IPv6<\/strong> based firewalls on your Debian system.<\/p>\n<p>You can install and setup <strong>UFW<\/strong> on your Debian through both the terminal and GUI-based application of <strong>UFW <\/strong>known as <strong>gufw<\/strong>. In the next section of this post, we will demonstrate these two mentioned approaches in detail.<\/p>\n<p>&nbsp;<\/p>\n<h2><a id=\"post-24007-_vpg044norczn\"><\/a><strong>How to Install UFW on Debian 12 Using CLI<\/strong><\/h2>\n<p>On most Linux-based distributions, the <strong>UFW<\/strong> comes pre-installed, if it is not, you can install it from the official repository. You will need sudo privileges to install and set up the<strong> firewall <\/strong>on Debian. Follow these steps to install <strong>UFW <\/strong>on Debian 12:<\/p>\n<p><strong>Step 1: <\/strong>It is recommended to upgrade your repository before installing any package:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">sudo<\/span> apt update <span class=\"sy0\">&amp;&amp;<\/span> <span class=\"kw2\">sudo<\/span> apt upgrade<\/div><\/div>\n<p><strong>Step 2: <\/strong>Next, install <strong>UFW<\/strong> on Debian from the official repository using the following command:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">sudo<\/span> apt <span class=\"kw2\">install<\/span> ufw <span class=\"re5\">-y<\/span><\/div><\/div>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"777\" height=\"283\" class=\"wp-image-24031\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2024\/01\/word-image-24007-1.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2024\/01\/word-image-24007-1.png 777w, https:\/\/linuxways.net\/wp-content\/uploads\/2024\/01\/word-image-24007-1-300x109.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2024\/01\/word-image-24007-1-768x280.png 768w\" sizes=\"auto, (max-width: 777px) 100vw, 777px\" \/><\/p>\n<p><strong>Step 3: <\/strong>Verify the installation by running the version command on the terminal:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">sudo<\/span> ufw <span class=\"re5\">--version<\/span><\/div><\/div>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"770\" height=\"148\" class=\"wp-image-24036\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2024\/01\/word-image-24007-2.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2024\/01\/word-image-24007-2.png 770w, https:\/\/linuxways.net\/wp-content\/uploads\/2024\/01\/word-image-24007-2-300x58.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2024\/01\/word-image-24007-2-768x148.png 768w\" sizes=\"auto, (max-width: 770px) 100vw, 770px\" \/><\/p>\n<p>&nbsp;<\/p>\n<h2><a id=\"post-24007-_iczb2lb4bfkz\"><\/a><strong>How to Setup Firewall with UFW on Debian 12 Using CLI<\/strong><\/h2>\n<p>Once you have installed <strong>UFW<\/strong> on your system, it is important to properly configure it. To protect our system from unauthorized access, we can do customization in port addresses and protocols. We have discussed the various aspects of configuring the <strong>UFW <\/strong>below:<\/p>\n<ul>\n<li><a href=\"#post-24007-hw8qshxalza8\"><strong>Configure UFW to Support IPV6<\/strong><\/a><\/li>\n<li><a href=\"#post-24007-dwjiiika0pu6\"><strong>Enable UFW<\/strong><\/a><\/li>\n<li><a href=\"#post-24007-f9yaxr9zo4eh\"><strong>Disable UFW<\/strong><\/a><\/li>\n<li><a href=\"#post-24007-cwzrew28we2i\"><strong>Check Application Profiles With UFW<\/strong><\/a><\/li>\n<li><a href=\"#post-24007-4hu62guuxz0e\"><strong>Allow, Deny, and Limit Traffic of Specific Port with UFW<\/strong><\/a><\/li>\n<li><a href=\"#post-24007-1c5tlwz18nr5\"><strong>Deal With Particular IP Using UFW<\/strong><\/a><\/li>\n<li><a href=\"#post-24007-kix.h2iyng7e7yyp\"><strong>Check the Status of UFW<\/strong><\/a><\/li>\n<li><a href=\"#post-24007-m7tb0iwxv8sa\"><strong>Restart UFW<\/strong><\/a><\/li>\n<li><a href=\"#post-24007-kix.ts87v9gur6xf\"><strong>Setup Default UFW Policy<\/strong><\/a><\/li>\n<li><a href=\"#post-24007-j8fabguk7p3p\"><strong>Delete Rules of UFW<\/strong><\/a><\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<h3><strong>1: Configure UFW to Support IPv6<\/strong><\/h3>\n<p>You can customize the settings of the <strong>UFW<\/strong> file to make it support both IPv4 and IPv6. To do so, access the configuration file using the nano editor through the execution of the following command:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">sudo<\/span> <span class=\"kw2\">nano<\/span> <span class=\"sy0\">\/<\/span>etc<span class=\"sy0\">\/<\/span>default<span class=\"sy0\">\/<\/span>ufw<\/div><\/div>\n<p>Look for the line <strong>IPV6 <\/strong>and set the \u201c<strong>IPV6=yes\u201d, <\/strong>save the file using <strong>Ctrl + X<\/strong>, add<strong> Y<\/strong> and press <strong>Enter <\/strong>to close it.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"785\" height=\"441\" class=\"wp-image-24044\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2024\/01\/word-image-24007-3.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2024\/01\/word-image-24007-3.png 785w, https:\/\/linuxways.net\/wp-content\/uploads\/2024\/01\/word-image-24007-3-300x169.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2024\/01\/word-image-24007-3-768x431.png 768w\" sizes=\"auto, (max-width: 785px) 100vw, 785px\" \/><\/p>\n<p>After editing the file, execute the below command to restart the <strong>UFW<\/strong>:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">sudo<\/span> ufw reload<\/div><\/div>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"743\" height=\"123\" class=\"wp-image-24051\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2024\/01\/word-image-24007-4.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2024\/01\/word-image-24007-4.png 743w, https:\/\/linuxways.net\/wp-content\/uploads\/2024\/01\/word-image-24007-4-300x50.png 300w\" sizes=\"auto, (max-width: 743px) 100vw, 743px\" \/><\/p>\n<h3><strong>2<\/strong><a id=\"post-24007-dwjiiika0pu6\"><\/a><strong>: Enable UFW <\/strong><\/h3>\n<p>To enable <strong>UFW<\/strong> on Debian, write out the following simple command on your terminal:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">sudo<\/span> ufw <span class=\"kw3\">enable<\/span><\/div><\/div>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"752\" height=\"118\" class=\"wp-image-24057\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2024\/01\/word-image-24007-5.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2024\/01\/word-image-24007-5.png 752w, https:\/\/linuxways.net\/wp-content\/uploads\/2024\/01\/word-image-24007-5-300x47.png 300w\" sizes=\"auto, (max-width: 752px) 100vw, 752px\" \/><\/p>\n<h3><strong>3<\/strong><a id=\"post-24007-f9yaxr9zo4eh\"><\/a><strong>: Disable UFW <\/strong><\/h3>\n<p>It is not recommended to disable <strong>UFW <\/strong>on Debian; however, if you want to disable it sometimes for troubleshooting purposes then you can run the following command:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">sudo<\/span> ufw disable<\/div><\/div>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"755\" height=\"122\" class=\"wp-image-24070\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2024\/01\/word-image-24007-6.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2024\/01\/word-image-24007-6.png 755w, https:\/\/linuxways.net\/wp-content\/uploads\/2024\/01\/word-image-24007-6-300x48.png 300w\" sizes=\"auto, (max-width: 755px) 100vw, 755px\" \/><\/p>\n<p>&nbsp;<\/p>\n<h3><strong>4: Check Application Profiles With UFW<\/strong><\/h3>\n<p>All the application profiles of the packages installed with apt on your Debian are stored in the <strong>etc\/ufw\/applications.d <\/strong>directory. To display the applications with <strong>UFW<\/strong>, execute the following command:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">sudo<\/span> ufw app list<\/div><\/div>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"750\" height=\"391\" class=\"wp-image-24084\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2024\/01\/word-image-24007-7.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2024\/01\/word-image-24007-7.png 750w, https:\/\/linuxways.net\/wp-content\/uploads\/2024\/01\/word-image-24007-7-300x156.png 300w\" sizes=\"auto, (max-width: 750px) 100vw, 750px\" \/><\/p>\n<p>To view the information about a specific package, use the info <strong>flag<\/strong> followed by the name of the package:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">sudo<\/span> ufw app info <span class=\"sy0\">&lt;<\/span>package name<span class=\"sy0\">&gt;<\/span><\/div><\/div>\n<p><strong>Example: <\/strong>I want to view the information about <strong>KTorrent<\/strong>:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">sudo<\/span> ufw app info KTorrent<\/div><\/div>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"775\" height=\"235\" class=\"wp-image-24100\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2024\/01\/word-image-24007-8.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2024\/01\/word-image-24007-8.png 775w, https:\/\/linuxways.net\/wp-content\/uploads\/2024\/01\/word-image-24007-8-300x91.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2024\/01\/word-image-24007-8-768x233.png 768w\" sizes=\"auto, (max-width: 775px) 100vw, 775px\" \/><\/p>\n<p>&nbsp;<\/p>\n<h3><strong>5: Allow, Deny, and Limit Traffic of Specific Port with UFW<\/strong><\/h3>\n<p>In Debian, you can use the name of the port number to allow or permit the traffic. For example, to enable the incoming connections for port 22, namely SSH, we will run one of the below-mentioned commands:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">sudo<\/span> ufw allow <span class=\"nu0\">22<\/span><\/div><\/div>\n<p><strong>OR<\/strong><\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">sudo<\/span> ufw allow <span class=\"kw2\">ssh<\/span><\/div><\/div>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"784\" height=\"148\" class=\"wp-image-24110\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2024\/01\/word-image-24007-9.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2024\/01\/word-image-24007-9.png 784w, https:\/\/linuxways.net\/wp-content\/uploads\/2024\/01\/word-image-24007-9-300x57.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2024\/01\/word-image-24007-9-768x145.png 768w\" sizes=\"auto, (max-width: 784px) 100vw, 784px\" \/><\/p>\n<p>To deny the incoming connections for port 22, execute the following command:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">sudo<\/span> ufw deny <span class=\"nu0\">80<\/span><\/div><\/div>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"764\" height=\"134\" class=\"wp-image-24117\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2024\/01\/word-image-24007-10.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2024\/01\/word-image-24007-10.png 764w, https:\/\/linuxways.net\/wp-content\/uploads\/2024\/01\/word-image-24007-10-300x53.png 300w\" sizes=\"auto, (max-width: 764px) 100vw, 764px\" \/><\/p>\n<p>To limit the traffic of the port, use the limit argument with the <strong>ufw <\/strong>command:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">sudo<\/span> ufw limit <span class=\"kw2\">ssh<\/span><\/div><\/div>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"716\" height=\"167\" class=\"wp-image-24121\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2024\/01\/word-image-24007-11.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2024\/01\/word-image-24007-11.png 716w, https:\/\/linuxways.net\/wp-content\/uploads\/2024\/01\/word-image-24007-11-300x70.png 300w\" sizes=\"auto, (max-width: 716px) 100vw, 716px\" \/><\/p>\n<p>&nbsp;<\/p>\n<h3><strong>6: Deal With Particular IP Using UFW<\/strong><\/h3>\n<p><strong>UFW<\/strong> allows you to define rules to allow or deny particular IP addresses to access your system. For instance, to allow incoming connections from IP address <strong>192.168.2.0<\/strong>, write out the following command on the terminal:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">sudo<\/span> ufw allow from 192.168.2.0<\/div><\/div>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"715\" height=\"116\" class=\"wp-image-24128\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2024\/01\/word-image-24007-12.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2024\/01\/word-image-24007-12.png 715w, https:\/\/linuxways.net\/wp-content\/uploads\/2024\/01\/word-image-24007-12-300x49.png 300w\" sizes=\"auto, (max-width: 715px) 100vw, 715px\" \/><\/p>\n<p>You can also create a rule to allow or prevent the IP address from connecting to the server through the specified port using the below syntax:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">sudo<\/span> ufw allow from <span class=\"sy0\">&lt;<\/span>IP<span class=\"sy0\">&gt;<\/span> to any port <span class=\"sy0\">&lt;<\/span>port number<span class=\"sy0\">&gt;<\/span><\/div><\/div>\n<p>For example, to allow <strong>192.168.2.0<\/strong> to connect to the server using port 44, execute the following command:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">sudo<\/span> ufw allow from 192.168.2.0 to any port <span class=\"nu0\">44<\/span><\/div><\/div>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"737\" height=\"104\" class=\"wp-image-24136\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2024\/01\/word-image-24007-13.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2024\/01\/word-image-24007-13.png 737w, https:\/\/linuxways.net\/wp-content\/uploads\/2024\/01\/word-image-24007-13-300x42.png 300w\" sizes=\"auto, (max-width: 737px) 100vw, 737px\" \/><\/p>\n<h3><strong>7<\/strong><a id=\"post-24007-kix.h2iyng7e7yyp\"><\/a><strong>: Check the Status of UFW<\/strong><\/h3>\n<p>The following command will display the status of <strong>UFW<\/strong> with all the rules on the screen:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">sudo<\/span> ufw status<\/div><\/div>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"741\" height=\"301\" class=\"wp-image-24143\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2024\/01\/word-image-24007-14.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2024\/01\/word-image-24007-14.png 741w, https:\/\/linuxways.net\/wp-content\/uploads\/2024\/01\/word-image-24007-14-300x122.png 300w\" sizes=\"auto, (max-width: 741px) 100vw, 741px\" \/><\/p>\n<p>To get more details about the rules, you can execute the <strong>verbose <\/strong>command:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">sudo<\/span> ufw status verbose<\/div><\/div>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"681\" height=\"355\" class=\"wp-image-24148\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2024\/01\/word-image-24007-15.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2024\/01\/word-image-24007-15.png 681w, https:\/\/linuxways.net\/wp-content\/uploads\/2024\/01\/word-image-24007-15-300x156.png 300w\" sizes=\"auto, (max-width: 681px) 100vw, 681px\" \/><\/p>\n<p>&nbsp;<\/p>\n<h3><strong>8: Restart UFW<\/strong><\/h3>\n<p>After making changes in the rules to secure your system, you can restart the <strong>UFW<\/strong> in Debian through the following command:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">sudo<\/span> systemctl restart ufw<\/div><\/div>\n<h3><strong>9<\/strong><a id=\"post-24007-kix.ts87v9gur6xf\"><\/a><strong>: Setup Default UFW Policy<\/strong><\/h3>\n<p>You can also set the <strong>UFW<\/strong> configurations to the default rules to improve its efficiency. When you install the <strong>UFW <\/strong>on your system, all outgoing connections are allowed and all incoming connections are blocked for your system. To do so, first, execute the following command to allow the outgoing connections:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">sudo<\/span> ufw default allow outgoing<\/div><\/div>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"767\" height=\"121\" class=\"wp-image-24152\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2024\/01\/word-image-24007-16.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2024\/01\/word-image-24007-16.png 767w, https:\/\/linuxways.net\/wp-content\/uploads\/2024\/01\/word-image-24007-16-300x47.png 300w\" sizes=\"auto, (max-width: 767px) 100vw, 767px\" \/><\/p>\n<p>Next, run the below command to block all incoming connections:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">sudo<\/span> ufw default deny incoming<\/div><\/div>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"767\" height=\"122\" class=\"wp-image-24157\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2024\/01\/word-image-24007-17.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2024\/01\/word-image-24007-17.png 767w, https:\/\/linuxways.net\/wp-content\/uploads\/2024\/01\/word-image-24007-17-300x48.png 300w\" sizes=\"auto, (max-width: 767px) 100vw, 767px\" \/><\/p>\n<p>&nbsp;<\/p>\n<h3><strong>10: Delete Rules of UFW<\/strong><\/h3>\n<p>There are two approaches for deleting a rule: one is through rule numbers and the other is using the port number. To delete a rule using a numeric number, first, get the number of the rule using the below-mentioned command:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">sudo<\/span> ufw status numbered<\/div><\/div>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"743\" height=\"303\" class=\"wp-image-24162\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2024\/01\/word-image-24007-18.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2024\/01\/word-image-24007-18.png 743w, https:\/\/linuxways.net\/wp-content\/uploads\/2024\/01\/word-image-24007-18-300x122.png 300w\" sizes=\"auto, (max-width: 743px) 100vw, 743px\" \/><\/p>\n<p>Then use the following syntax to delete a <strong>firewall <\/strong>rule:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">sudo<\/span> ufw delete <span class=\"sy0\">&lt;<\/span>rule number<span class=\"sy0\">&gt;<\/span><\/div><\/div>\n<p><strong>Example<\/strong>: The following command will delete the <strong>firewall<\/strong> rule set at 4:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">sudo<\/span> ufw delete <span class=\"nu0\">4<\/span><\/div><\/div>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"609\" height=\"145\" class=\"wp-image-24165\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2024\/01\/word-image-24007-19.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2024\/01\/word-image-24007-19.png 609w, https:\/\/linuxways.net\/wp-content\/uploads\/2024\/01\/word-image-24007-19-300x71.png 300w\" sizes=\"auto, (max-width: 609px) 100vw, 609px\" \/><\/p>\n<p>You can verify the deletion of the rule using the <strong>status <\/strong>command.<\/p>\n<p>The second approach is using the port number for deleting the rule. The fundamental syntax of rule deletion using the port number is:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">sudo<\/span> ufw delete <span class=\"br0\">&#91;<\/span>port number<span class=\"br0\">&#93;<\/span><\/div><\/div>\n<p><strong> Example: <\/strong>The following command will delete the <strong>firewall <\/strong>rule allow 22:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">sudo<\/span> ufw delete allow <span class=\"nu0\">22<\/span><\/div><\/div>\n<p>The rule that allows the connection from port 22 has been deleted:<\/p>\n<p>You can also delete all the rules of the <strong>firewall<\/strong> by using the reset command:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">sudo<\/span> ufw reset<\/div><\/div>\n<p>It will disable the <strong>UFW<\/strong> on Debian and delete all the rules you have previously defined.<\/p>\n<p>In the next section, we will discuss the installation and configuration of <strong>UFW<\/strong> on Debian 12 using the graphical application of <strong>UFW<\/strong> known as <strong>gufw<\/strong>.<\/p>\n<p>&nbsp;<\/p>\n<h2><a id=\"post-24007-_uvsmmwsf4h98\"><\/a><strong>How to Install Graphical Application of UFW on Debian 12<\/strong><\/h2>\n<p>The graphical application for <strong>UFW<\/strong> is <strong>gufw <\/strong>and it comes pre-installed on most of the Linux distributions. It allows users to manage the <strong>firewall <\/strong>rules with minimal effort. If it is not installed on your system, then run the following command to install it:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">sudo<\/span> apt <span class=\"kw2\">install<\/span> gufw <span class=\"re5\">-y<\/span><\/div><\/div>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"780\" height=\"217\" class=\"wp-image-24172\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2024\/01\/word-image-24007-21.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2024\/01\/word-image-24007-21.png 780w, https:\/\/linuxways.net\/wp-content\/uploads\/2024\/01\/word-image-24007-21-300x83.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2024\/01\/word-image-24007-21-768x214.png 768w\" sizes=\"auto, (max-width: 780px) 100vw, 780px\" \/><\/p>\n<p>The <strong>gufw <\/strong>is successfully installed on your Debian.<\/p>\n<p>&nbsp;<\/p>\n<h2><a id=\"post-24007-_ax95c1rf6axh\"><\/a><strong>How to Setup Firewall with UFW on Debian 12 Using GUI<\/strong><\/h2>\n<p>To launch the application, navigate to <strong>Activities<\/strong>, search <strong>gufw,<\/strong> and open the <strong>Firewall configuration <\/strong>application:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"767\" height=\"458\" class=\"wp-image-24176\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2024\/01\/word-image-24007-22.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2024\/01\/word-image-24007-22.png 767w, https:\/\/linuxways.net\/wp-content\/uploads\/2024\/01\/word-image-24007-22-300x179.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2024\/01\/word-image-24007-22-501x300.png 501w\" sizes=\"auto, (max-width: 767px) 100vw, 767px\" \/><\/p>\n<p>Enter the password to continue and the homepage of the <strong>gufw<\/strong> will appear on your screen. Here you can choose different options to customize the settings of the firewall with <strong>UFW<\/strong>:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"693\" height=\"548\" class=\"wp-image-24183\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2024\/01\/word-image-24007-23.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2024\/01\/word-image-24007-23.png 693w, https:\/\/linuxways.net\/wp-content\/uploads\/2024\/01\/word-image-24007-23-300x237.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2024\/01\/word-image-24007-23-150x120.png 150w\" sizes=\"auto, (max-width: 693px) 100vw, 693px\" \/><\/p>\n<p>You can see the following options on your screen:<\/p>\n<h3><strong>1: Status<\/strong><\/h3>\n<p>Turn the toggle <strong>ON <\/strong>and <strong>OFF<\/strong> to enable and disable the <strong>firewall <\/strong>on Debian:<\/p>\n<p><strong><img loading=\"lazy\" decoding=\"async\" width=\"604\" height=\"488\" class=\"wp-image-24184\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2024\/01\/word-image-24007-24.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2024\/01\/word-image-24007-24.png 604w, https:\/\/linuxways.net\/wp-content\/uploads\/2024\/01\/word-image-24007-24-300x242.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2024\/01\/word-image-24007-24-150x120.png 150w\" sizes=\"auto, (max-width: 604px) 100vw, 604px\" \/><\/strong><\/p>\n<h3><strong>2: Incoming<\/strong><\/h3>\n<p>Click on the <strong>arrow <\/strong>to allow or deny the incoming connections:<\/p>\n<p><strong><img loading=\"lazy\" decoding=\"async\" width=\"649\" height=\"480\" class=\"wp-image-24187\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2024\/01\/word-image-24007-25.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2024\/01\/word-image-24007-25.png 649w, https:\/\/linuxways.net\/wp-content\/uploads\/2024\/01\/word-image-24007-25-300x222.png 300w\" sizes=\"auto, (max-width: 649px) 100vw, 649px\" \/><\/strong><\/p>\n<h3><strong>3: Outgoing<\/strong><\/h3>\n<p>Click on the <strong>arrow <\/strong>next to <strong>Outgoing<\/strong> to allow or deny the outgoing connections:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"613\" height=\"481\" class=\"wp-image-24190\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2024\/01\/word-image-24007-26.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2024\/01\/word-image-24007-26.png 613w, https:\/\/linuxways.net\/wp-content\/uploads\/2024\/01\/word-image-24007-26-300x235.png 300w\" sizes=\"auto, (max-width: 613px) 100vw, 613px\" \/><\/p>\n<p>&nbsp;<\/p>\n<h2><a id=\"post-24007-_32zk4uu480f\"><\/a><strong>How to Uninstall UFW on Debian 12<\/strong><\/h2>\n<p>Use the following command to uninstall the <strong>UFW<\/strong> with all its configuration files on Debian 12:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">sudo<\/span> apt purge ufw <span class=\"re5\">-y<\/span><\/div><\/div>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"723\" height=\"308\" class=\"wp-image-24191\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2024\/01\/word-image-24007-27.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2024\/01\/word-image-24007-27.png 723w, https:\/\/linuxways.net\/wp-content\/uploads\/2024\/01\/word-image-24007-27-300x128.png 300w\" sizes=\"auto, (max-width: 723px) 100vw, 723px\" \/><\/p>\n<p>Run the following command on the terminal to delete the <strong>gufw<\/strong> from Debian 12:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">sudo<\/span> apt purge gufw <span class=\"re5\">-y<\/span><\/div><\/div>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"770\" height=\"279\" class=\"wp-image-24193\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2024\/01\/word-image-24007-28.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2024\/01\/word-image-24007-28.png 770w, https:\/\/linuxways.net\/wp-content\/uploads\/2024\/01\/word-image-24007-28-300x109.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2024\/01\/word-image-24007-28-768x278.png 768w\" sizes=\"auto, (max-width: 770px) 100vw, 770px\" \/><\/p>\n<p>The <strong>UFW <\/strong>and <strong>gufw <\/strong>have been successfully removed from Debian 12.<\/p>\n<p>&nbsp;<\/p>\n<h2><a id=\"post-24007-_aui19by6fbit\"><\/a><strong>Conclusion<\/strong><\/h2>\n<p>On Debian, the <strong>Firewall<\/strong> is a security system that keeps track of both incoming and outgoing traffic. The <strong>UFW<\/strong> is a simple command line tool that manages the <strong>Netfilter Firewall <\/strong>and controls the network connections based on predefined rules. You can customize the rules using the numerous available options that we have discussed in this guide. The <strong>UFW <\/strong>also has a GUI-based application known as <strong>gufw<\/strong> for managing the<strong> firewall <\/strong>of the system. We have also discussed the installation procedure and the customization options of the application in the above section of the post.<\/p>","protected":false},"excerpt":{"rendered":"<p>UFW provides an easy-to-use interface to set up Firewall on Debian 12 and you can download it from the official repository.<\/p>","protected":false},"author":115,"featured_media":24198,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-24007","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-debian"],"_links":{"self":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/24007","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\/115"}],"replies":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/comments?post=24007"}],"version-history":[{"count":0,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/24007\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media\/24198"}],"wp:attachment":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media?parent=24007"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/categories?post=24007"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/tags?post=24007"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}