SlideShare a Scribd company logo
1/9
By Karim Buzdar July 7, 2025
How to Install UFW on Debian 12
greenwebpage.com/community/how-to-install-ufw-on-debian-12/
Uncomplicated Firewall (UFW) is a command-line interface for manipulating iptables rules
in a simplified and easy-to-understand way. One of the early tasks you should perform
once Debian is installed is to secure your system’s ports. Rather than using your classic
iptables rules, you can use easy-to-remember ufw rules to set your firewall up. That’s
fantastic for new network experts and sysadmins who just want to get their Debian 12
systems secure ASAP.
In this article, you will be able to follow steps for several ways to install UFW on Debian
12 to make sure you have an easy way of securing your system.
UFW is a good combination of function and ease of use and is the perfect choice to
secure a Debian 12 system. For the case of one server or multiple systems, UFW
provides a user-friendly way to manage your firewalls. If you are currently connected to
your server via SSH, be careful about authorizing UFW rules, or you’ll end up locked out
of your server.
Let’s follow the easiest method:
Method 1: Install UFW Using APT Package Manager (Recommended)
The easiest way to set up UFW on Debian 12 is by using the APT package manager
since UFW is included in the official Debian repositories. APT leans on the official
repositories for Debian so that UFW is downloaded securely and properly integrates with
2/9
system dependencies.
Step 1: Update Package Lists
First, update the package list to get the latest versions of your repository:
sudo apt update
Step 2: Install UFW
First, install UFW through the apt command:
sudo apt install ufw
Step 3: Verify Installation
Verify if UFW is correctly installed:
sudo ufw --version
3/9
An output like that should get written to your terminal.
Step 4: Check UFW Status
Check the status of UFW:
sudo ufw status
Initially, UFW will be inactive (disabled) after installation.
Method 2: Install UFW from Source Code
This method will install UFW directly from the source code. This is for users who prefer to
install the latest development version or to customize the installation. For those who are
more experienced and desire the newest features, or if you want to further customize the
install, then you can compile UFW from source.
Step 1: Install Dependencies
Install the necessary build tools and stuff:
sudo apt update
sudo apt install build-essential python3-dev python3-setuptools git
Step 2: Download UFW Source Code
4/9
First of all, clone the UFW repository or get the source code. Or you can also get the
recent release through the UFW website:
git clone https://git.launchpad.net/ufw
Step 3: Build and Install
Unzip ufw.zip and build/install it from source:
cd ufw
sudo python3 setup.py install
Step 4: Set Up UFW
Then, after installation, set up the required directories and files:
sudo mkdir -p /etc/ufw
sudo cp -r conf/* /etc/ufw/
sudo chmod 644 /etc/ufw/*
5/9
Step 5: Verify Installation
Make sure UFW is installed:
ufw version
Method 3: Install UFW Using Snap Package Manager
And finally, this last method, which is probably my favorite, is to install the UFW via snap.
Step 1: Install Snapd (if not already installed)
Snap is another package manager that can be used to install UFW on Debian 12.
sudo apt install snapd
Step 2: Install UFW via Snap
After that, install ufw utility through the following command:
sudo snap install ufw
Step 3: Verify Installation
Finally, verify the installed version through the following line:
sudo ufw --version
6/9
Snap UFW may behave slightly differently from APT UFW.
Post-Installation Configuration
Once you have the UFW installed with any of the above methods, you’ll want to configure
it correctly:
Now that you have UFW on your system, set it up with these few simple commands:
Enable UFW
Now, enable the utility with sudo privileges:
sudo ufw enable
Set Default Policies
Set up the default policies (recommended for most users):
sudo ufw default deny incoming
sudo ufw default allow outgoing
Allow SSH (Important for Remote Access)
If you want to be able to use SSH for possible remote access, you must allow it before
turning on UFW:
sudo ufw allow ssh
7/9
Or allow a specific SSH port:
sudo ufw allow 22/tcp
Check UFW Status
Verify your UFW configuration:
sudo ufw status verbose
How to Uninstall UFW on Debian 12?
If you need to remove UFW:
sudo apt remove ufw
To also remove configuration files:
8/9
sudo apt purge ufw
Troubleshooting Common Issues
For more advanced setups and cool UFW features, see the official UFW documentation
and carefully consider your security needs when opening firewall ports. Let’s follow some
common issues:
Issue 1: UFW Command Not Found
If you are on a VPS and running UFW and your UFW command is simply not being
found, the server’s firewall paint may be beginning to chip.
If you get “command not found,” then make sure that UFW is installed, and your PATH is
set up correctly:
which ufw
echo $PATH
Issue 2: Permission Denied
You should be using sudo while giving commands to UFW:
sudo ufw status
9/9
Issue 3: SSH Access Lost
If you lose SSH, physically access the server to turn off UFW:
sudo ufw disable
Issue 4: UFW Not Starting at Boot
Allow UFW service at boot time:
sudo systemctl enable ufw
sudo systemctl start ufw
Best Practices for UFW on Debian 12
1. Always allow SSH before enabling UFW if you’re working remotely
2. Test your rules before applying them to production systems
3. Keep logs enabled for monitoring: sudo ufw logging on
4. Regularly review your rules: sudo ufw status numbered
5. Use specific port numbers instead of service names when possible
6. Document your firewall rules for future reference
Conclusion
To install UFW (Uncomplicated Firewall) on Debian 12, you can use the apt package
manager. First, update your package lists, then install the ufw package. You can easily
install UFW on your Debian 12 server; there are a few ways to achieve it. APT package
manager is my recommendation for anybody, basically because it’s straightforward and
fits the Debian package system. Once installed, ensure that you properly configure the
UFW and add rules to DISALLOW ALL traffic through it.
© 2023 Greenwebpage.com Community All Rights Reserved by

More Related Content

PPT
Firewall(linux)
PPTX
Week 4 Linux Firewalls 1_868612559.pptx
PDF
How to install and configure firewall on ubuntu os
PPTX
Understanding Firewall by Ahmad Nauval Syahputra.pptx
DOCX
How to Install iptable on Debian 12.docx
DOCX
Creating a firewall in UBUNTU
PDF
03 linuxfirewall1
PDF
How to secure ubuntu 12.04
Firewall(linux)
Week 4 Linux Firewalls 1_868612559.pptx
How to install and configure firewall on ubuntu os
Understanding Firewall by Ahmad Nauval Syahputra.pptx
How to Install iptable on Debian 12.docx
Creating a firewall in UBUNTU
03 linuxfirewall1
How to secure ubuntu 12.04

Similar to How to Install UFW Firewall on Debian 12.pdf (9)

PDF
Debian packaging
PPTX
Introduction to linux day1
PPSX
Linux02 install SSh
PPTX
Linux Firewall (Netfilter )and tools .pptx
PPTX
Recommended Software and Modifications for Server Security
DOCX
SEED Labs – Linux Firewall Exploration Lab 1Linux Firewall.docx
DOCX
SEED Labs – Linux Firewall Exploration Lab 1Linux Firewall.docx
PDF
How to Install Python on Debian 12 Server
PDF
firewall assignment.pdf
Debian packaging
Introduction to linux day1
Linux02 install SSh
Linux Firewall (Netfilter )and tools .pptx
Recommended Software and Modifications for Server Security
SEED Labs – Linux Firewall Exploration Lab 1Linux Firewall.docx
SEED Labs – Linux Firewall Exploration Lab 1Linux Firewall.docx
How to Install Python on Debian 12 Server
firewall assignment.pdf
Ad

More from Green Webpage (20)

PDF
How to Upgrade Linux Mint From 21 to 22.pdf
PDF
How to Install VirtualBox on Linux Mint 22.pdf
PDF
How to Install VMware Workstation on Linux Mint 22.pdf
PDF
How to Install Google Chrome on Ubuntu 24.04.pdf
PDF
How to Install XRDP on Debian 12 Server.pdf
PDF
How to Install Apache on Debian 12 Server
PDF
How to Install OpenJDK on Debian 12 Server.pdf
PDF
How to Install Cuda on Debian 12 Server.pdf
PDF
How to Install GCC Compiler on Debian 12.pdf
PDF
How to Check the Kernel Version in Debian 12.pdf
PDF
How to Install and Configure MariaDB on Debian 12.pdf
PDF
How to Install phpMyAdmin on Debian 12.pdf
PDF
How to Install and Configure Webmin on Debian 12.pdf
PDF
How to Change an IP Address on Debian 12.pdf
PDF
How to Install Plex Media Server on Debian 12.pdf
PDF
How to Install KVM (Kernel-based Virtual Machine) on Debian 12
PDF
How to Install Nextcloud on Debian 12.pdf
PDF
How to Install VNC Server on Debian 12.pdf
PDF
How to Install Portainer Docker UI Web Interface on Debian 12.pdf
PDF
How to Install Java on Debian 12 Using Apt and Deb.pdf
How to Upgrade Linux Mint From 21 to 22.pdf
How to Install VirtualBox on Linux Mint 22.pdf
How to Install VMware Workstation on Linux Mint 22.pdf
How to Install Google Chrome on Ubuntu 24.04.pdf
How to Install XRDP on Debian 12 Server.pdf
How to Install Apache on Debian 12 Server
How to Install OpenJDK on Debian 12 Server.pdf
How to Install Cuda on Debian 12 Server.pdf
How to Install GCC Compiler on Debian 12.pdf
How to Check the Kernel Version in Debian 12.pdf
How to Install and Configure MariaDB on Debian 12.pdf
How to Install phpMyAdmin on Debian 12.pdf
How to Install and Configure Webmin on Debian 12.pdf
How to Change an IP Address on Debian 12.pdf
How to Install Plex Media Server on Debian 12.pdf
How to Install KVM (Kernel-based Virtual Machine) on Debian 12
How to Install Nextcloud on Debian 12.pdf
How to Install VNC Server on Debian 12.pdf
How to Install Portainer Docker UI Web Interface on Debian 12.pdf
How to Install Java on Debian 12 Using Apt and Deb.pdf
Ad

Recently uploaded (20)

PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PPT
Teaching material agriculture food technology
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Machine learning based COVID-19 study performance prediction
PPTX
Spectroscopy.pptx food analysis technology
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
Approach and Philosophy of On baking technology
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Encapsulation theory and applications.pdf
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PPTX
Programs and apps: productivity, graphics, security and other tools
“AI and Expert System Decision Support & Business Intelligence Systems”
Teaching material agriculture food technology
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Machine learning based COVID-19 study performance prediction
Spectroscopy.pptx food analysis technology
MYSQL Presentation for SQL database connectivity
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Approach and Philosophy of On baking technology
NewMind AI Weekly Chronicles - August'25 Week I
Building Integrated photovoltaic BIPV_UPV.pdf
Encapsulation theory and applications.pdf
The AUB Centre for AI in Media Proposal.docx
Encapsulation_ Review paper, used for researhc scholars
Reach Out and Touch Someone: Haptics and Empathic Computing
Digital-Transformation-Roadmap-for-Companies.pptx
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Programs and apps: productivity, graphics, security and other tools

How to Install UFW Firewall on Debian 12.pdf

  • 1. 1/9 By Karim Buzdar July 7, 2025 How to Install UFW on Debian 12 greenwebpage.com/community/how-to-install-ufw-on-debian-12/ Uncomplicated Firewall (UFW) is a command-line interface for manipulating iptables rules in a simplified and easy-to-understand way. One of the early tasks you should perform once Debian is installed is to secure your system’s ports. Rather than using your classic iptables rules, you can use easy-to-remember ufw rules to set your firewall up. That’s fantastic for new network experts and sysadmins who just want to get their Debian 12 systems secure ASAP. In this article, you will be able to follow steps for several ways to install UFW on Debian 12 to make sure you have an easy way of securing your system. UFW is a good combination of function and ease of use and is the perfect choice to secure a Debian 12 system. For the case of one server or multiple systems, UFW provides a user-friendly way to manage your firewalls. If you are currently connected to your server via SSH, be careful about authorizing UFW rules, or you’ll end up locked out of your server. Let’s follow the easiest method: Method 1: Install UFW Using APT Package Manager (Recommended) The easiest way to set up UFW on Debian 12 is by using the APT package manager since UFW is included in the official Debian repositories. APT leans on the official repositories for Debian so that UFW is downloaded securely and properly integrates with
  • 2. 2/9 system dependencies. Step 1: Update Package Lists First, update the package list to get the latest versions of your repository: sudo apt update Step 2: Install UFW First, install UFW through the apt command: sudo apt install ufw Step 3: Verify Installation Verify if UFW is correctly installed: sudo ufw --version
  • 3. 3/9 An output like that should get written to your terminal. Step 4: Check UFW Status Check the status of UFW: sudo ufw status Initially, UFW will be inactive (disabled) after installation. Method 2: Install UFW from Source Code This method will install UFW directly from the source code. This is for users who prefer to install the latest development version or to customize the installation. For those who are more experienced and desire the newest features, or if you want to further customize the install, then you can compile UFW from source. Step 1: Install Dependencies Install the necessary build tools and stuff: sudo apt update sudo apt install build-essential python3-dev python3-setuptools git Step 2: Download UFW Source Code
  • 4. 4/9 First of all, clone the UFW repository or get the source code. Or you can also get the recent release through the UFW website: git clone https://git.launchpad.net/ufw Step 3: Build and Install Unzip ufw.zip and build/install it from source: cd ufw sudo python3 setup.py install Step 4: Set Up UFW Then, after installation, set up the required directories and files: sudo mkdir -p /etc/ufw sudo cp -r conf/* /etc/ufw/ sudo chmod 644 /etc/ufw/*
  • 5. 5/9 Step 5: Verify Installation Make sure UFW is installed: ufw version Method 3: Install UFW Using Snap Package Manager And finally, this last method, which is probably my favorite, is to install the UFW via snap. Step 1: Install Snapd (if not already installed) Snap is another package manager that can be used to install UFW on Debian 12. sudo apt install snapd Step 2: Install UFW via Snap After that, install ufw utility through the following command: sudo snap install ufw Step 3: Verify Installation Finally, verify the installed version through the following line: sudo ufw --version
  • 6. 6/9 Snap UFW may behave slightly differently from APT UFW. Post-Installation Configuration Once you have the UFW installed with any of the above methods, you’ll want to configure it correctly: Now that you have UFW on your system, set it up with these few simple commands: Enable UFW Now, enable the utility with sudo privileges: sudo ufw enable Set Default Policies Set up the default policies (recommended for most users): sudo ufw default deny incoming sudo ufw default allow outgoing Allow SSH (Important for Remote Access) If you want to be able to use SSH for possible remote access, you must allow it before turning on UFW: sudo ufw allow ssh
  • 7. 7/9 Or allow a specific SSH port: sudo ufw allow 22/tcp Check UFW Status Verify your UFW configuration: sudo ufw status verbose How to Uninstall UFW on Debian 12? If you need to remove UFW: sudo apt remove ufw To also remove configuration files:
  • 8. 8/9 sudo apt purge ufw Troubleshooting Common Issues For more advanced setups and cool UFW features, see the official UFW documentation and carefully consider your security needs when opening firewall ports. Let’s follow some common issues: Issue 1: UFW Command Not Found If you are on a VPS and running UFW and your UFW command is simply not being found, the server’s firewall paint may be beginning to chip. If you get “command not found,” then make sure that UFW is installed, and your PATH is set up correctly: which ufw echo $PATH Issue 2: Permission Denied You should be using sudo while giving commands to UFW: sudo ufw status
  • 9. 9/9 Issue 3: SSH Access Lost If you lose SSH, physically access the server to turn off UFW: sudo ufw disable Issue 4: UFW Not Starting at Boot Allow UFW service at boot time: sudo systemctl enable ufw sudo systemctl start ufw Best Practices for UFW on Debian 12 1. Always allow SSH before enabling UFW if you’re working remotely 2. Test your rules before applying them to production systems 3. Keep logs enabled for monitoring: sudo ufw logging on 4. Regularly review your rules: sudo ufw status numbered 5. Use specific port numbers instead of service names when possible 6. Document your firewall rules for future reference Conclusion To install UFW (Uncomplicated Firewall) on Debian 12, you can use the apt package manager. First, update your package lists, then install the ufw package. You can easily install UFW on your Debian 12 server; there are a few ways to achieve it. APT package manager is my recommendation for anybody, basically because it’s straightforward and fits the Debian package system. Once installed, ensure that you properly configure the UFW and add rules to DISALLOW ALL traffic through it. © 2023 Greenwebpage.com Community All Rights Reserved by