Differences between VPS and Dedicated Servers
VPS and dedicated servers are two types of web hosting services that can both be used for hosting websites, databases,…
How to Transfer Files from Windows to Linux Using WinSCP
In the world of computing, the seamless transfer of files between different operating systems is essential for efficient collaboration and…
Why Regular Data Backup Is Important in Web Hosting
Data Loss Can Have Severe Consequences In today’s digital world, businesses heavily rely on data, such as customer data and…
IPv4 vs IPv6: What are the differences?
Introduction In this blog, we’ll delve into IPv4 vs IPv6, and explore the meanings of IP, IPv4, and IPv6, and…
Dedicated IP vs Shared IP: What are the differences?
Introduction In this blog post, we’ll explore the meaning and differences between Dedicated and Shared IP, plus, how IP works,…
How to Use TraceRoute on Windows or Linux
Introduction If you’re having network connectivity problems, you can run a traceroute to pinpoint exactly where your connection is failing.…
7 Ways to Secure Your VPS
Why Securing VPS is Important While VPS instances are generally considered safer than shared hosting due to their isolated nature,…
8 Major Benefits of VPS Hosting
Introduction If you’re looking to host a website for your business, it’s important to consider the different hosting options available…
What to Do with a VPS
What is a VPS? A Virtual Private Server (VPS) is a virtualized server that operates within a larger physical server.…
How to Fix Common Remote Desktop Connection Problems
Introduction When encountering remote desktop connection failures on a Windows remote server, there are various troubleshooting steps you can try…
How to Prevent SSH Brute-Force Attacks on Linux Using Fail2ban
What Is Fail2ban? Fail2ban is an open-source intrusion prevention software that helps protect Linux servers from unauthorized access attempts. It…
How to Prevent Brute-force Login Attacks on MSSQL
Introduction If you are running Microsoft SQL Server, you may be aware that your SA account is subject to a…
Windows Server VPS vs Windows Desktop VPS: Choosing the Best Windows VPS Hosting
Introduction At B2BHOSTINGCLUB, Windows VPS offerings are categorized into Windows Server VPS and Windows Desktop VPS. If you’re uncertain about…
How to Install Windows Subsystem for Linux (WSL) on Windows 10
What is WSL? WSL stands for Windows Subsystem for Linux. It is a compatibility layer developed by Microsoft that allows…
How to Use VNC to Access a Remote Windows Server
What is VNC? VNC stands for Virtual Network Computing. It is a graphical desktop sharing system that allows you to…
How to Install and Run ChatGPT as a Windows App
Introdcution ChatGPT is an artificial intelligence (AI) chatbot built on OpenAI’s large language models. It is a web app, and…
How to Install and Use Tabby Terminal on Windows
What is Tabby? Tabby is an infinitely customizable cross-platform terminal app for local shells, serial, SSH, and Telnet connections. It…
How to Connect to Ubuntu Linux with SSH Keys Using PuTTy from Windows
Introduction It is generally recommended to use SSH key authentication whenever possible, especially for servers or systems accessible over the…
8 Reasons to Choose Windows 10 Over Windows 11
Introdcution Sometimes it’s not a good idea to upgrade your technology, no matter how shiny the new version looks. Here…
How to Configure a Firewall on Windows VPS
Introduction Configuring a firewall on a Windows VPS (Virtual Private Server) is an essential step in establishing a robust and…
Installing Xfce Desktop Environment and XRDP service on Remote Ubuntu 22.04
Prerequisites You already log in to your remote Linux server Once your server is deployed, the login credentials are usually…
Installing KDE Plasma Desktop Environment and XRDP service on Remote Ubuntu 22.04
Prerequisites You already log in to your remote Linux server Once your server is deployed, the login credentials are usually…
Installing Cinnamon Desktop Environment and XRDP service on Remote Ubuntu 22.04
Prerequisites You already log in to your remote Linux server Once your server is deployed, the login credentials are usually…
Linux GUI Options: 9 Best Linux Desktop Environments to Use
A Linux desktop environment is a graphical user interface (GUI) that provides a cohesive and user-friendly environment for users to…
How to Use VNC to Access a Remote Linux Server
Steps to Use VNC to Access a Remote Linux Server Prerequisites You already get the server login credentials Once your…
How to Transfer Files from Windows to Linux Using CMD
Introduction While there are various methods available for file transfers from a Windows system to a Linux system, using the…
How to Install the ModSecurity Apache Module
What is ModSecurity? ModSecurity is an open-source web application firewall (WAF) module for the Apache HTTP Server (Apache) and other…
How to Install the Apache Web Server on Ubuntu 20.04
What is Web Server? A web server is a software application or a computer system that serves web content over…
How To Monitor Linux System Logs with Logwatch
Introduction System logs contain valuable information about the activities and events occurring on your Linux server. However, manually reviewing these…
9 Benefits of Linux VPS Hosting
Introduction Linux VPS hosting, leveraging its renowned stability, robustness, and flexibility, becomes the optimal choice for businesses seeking to enhance…
How to Install and Use Screen on Ubuntu Servers
Introduction Have you ever experienced the frustration of working on the command line via an SSH connection, only to have…
How to Configure a Linux VPS Firewall with IPTables
Introduction Securing your Linux VPS with a firewall is an important step to protect it from unauthorized access and attacks.…
How To Install and Config UFW Firewall on Ubuntu 22.04
Introduction What is the Use of UFW in Ubuntu Linux? The UFW (Uncomplicated Firewall) is a frontend for iptables and…
How to Use the ps aux Command in Linux
Introduction In the world of Linux, the command-line interface (CLI) is a powerful tool that allows users to interact directly…
4 Detailed Ways to Check The MySQL Version in Linux
Introduction MySQL is a widely used open-source database management system that powers numerous websites and organizations. It was initially released…
How to Set up Two-Factor Authentication for Linux Server
Introduction Setting up two-factor authentication (2FA) for a Linux server provides an additional layer of security and helps protect against…
How to Install PHP Composer on Ubuntu 20.04
Introduction PHP Composer is a dependency management tool for PHP. It is widely used in the PHP development community to…
How to Install PHP 8.1 for Nginx On Ubuntu 20.04
Introduction PHP is arguably one of the most widely used server-side programming languages. It’s the language of choice when developing…
Go Unlimited With B2BHOSTINGCLUB
Go Unlimited With B2BHostingClub – The Ultimate Hosting Solution for Growing Businesses In today’s digital world, every business—whether small, medium,…
How to Identify and Improve Your 404 Pages
In the fast-paced world of online business, user experience is everything. A single bad interaction can send a potential customer…
How to Upgrade an Existing cPanel Account to Reseller/Master Reseller in WHM
How to Upgrade an Existing cPanel Account to Reseller/Master Reseller in WHM – Complete Guide In this complete guide, we’ll…
How to Create Reseller or Master Reseller Account in WHM/cPanel – Complete Guide
Introduction If you’re running a web hosting business through B2BHostingClub, offering Reseller and Master Reseller hosting plans can significantly boost…
Use of Rsync Command in Linux with Example
What is Rsync Command In Linux? The Rsync command in Linux is mostly used to copy and synchronize files and…
































![Introduction What is the Use of UFW in Ubuntu Linux? The UFW (Uncomplicated Firewall) is a frontend for iptables and is particularly well-suited for host-based firewalls. UFW provides a framework for managing netfilter, as well as a command-line interface for manipulating the firewall. UFW is a great firewall tool that is designed to be run on hosts or servers. It allows or blocks incoming and outgoing connections to and from the server. You can block ports, IPs or even entire subnets using UFW. It is not as flexible as iptables but is vastly easier for basic operations. UFW vs IPTables When it comes to configuring firewall on Ubuntu server, you have two primary options: ufw and iptables. Both tools provide firewall functionality but differ in terms of ease of use and complexity. UFW is a front-end for iptables that aims to simplify the process of configuring a firewall. It provides a user-friendly command-line interface and allows you to manage firewall rules using human-readable syntax. UfW provides a set of default rules that are easy to understand and configure. IPTables provides granular control over network traffic by allowing you to define rules based on various criteria such as IP addresses, ports, protocols, and more. IPTables gives you more flexibility, but it's also slightly more complicated to configure. So use whichever one you're most happy with. If you use iptables, remember that it only affects IPv4 - you need to also use ip6tables if your server has IPv6. In this article, we will show you how to install and config the UFW firewall on Ubuntu 22.04. How to Install UFW Firewall To install UFW on Ubuntu, follow these 3 steps. Step 1: SSH into the Linux system To install UFW, you need to SSH into the system. Step 2: Update system check settings $ sudo apt update $ sudo apt upgrade To check if ufw is installed, you can use the which command: $ which ufw And if the result doesn’t show output, it means ufw is not installed and you should install it like below. Step 3: Install UFW $ sudo apt-get install ufw After your ufw installation is complete, use the command below to check. The initial default after installation, UFW will be disabled because it has not been activated and you have to enable it manually. $ sudo ufw status verbose ----------------------------- Output Status: inactive Step 4: Enable UFW, Activate UFW After Installation To enable UFW and start enforcing the firewall rules, run: $ sudo ufw enable To temporarily disable UFW, run: $ sudo ufw disable How to Config UFW Firewall Use ufw to manage firewall rules, add/delete/restore/reset ufw rules. 1. UFW Check Status To check the current status of UFW, run the following command: $ sudo ufw status This will show you if UFW is active or inactive, the default input and output policies, and any rules that have been created. A fresh Ubuntu 22.04 installation will have UFW inactive by default. 2. UFW Allow Port To allow incoming connections on a specific port, you need to allow that port using UFW. For example, to allow HTTP traffic on port 80, run: $ sudo ufw allow 80/tcp This will allow all incoming TCP connections on port 80. You can also specify the IP address to allow only for a specific host: $ sudo ufw allow from 192.168.1.100 to any port 80 To allow both TCP and UDP protocols on port 123, run: $ sudo ufw allow 123/tcp $ sudo ufw allow 123/udp 3. UFW Allow Multiple Ports To allow multiple ports at once, specify the starting and ending ports: $ sudo ufw allow 2000:2100/tcp This will allow all ports from 2000 to 2100. You can also specify ports in a comma-separated list: $ sudo ufw allow 80,443,8080/tcp $ sudo ufw allow 22,25,110/tcp 4. UFW Allow HTTP/HTTPS Traffic It is a common requirement to allow incoming HTTP and HTTPS traffic. You can do that with: $ sudo ufw allow 'Apache Full' This will allow HTTP traffic on port 80 and HTTPS traffic on port 443. 5. UFW Allow SSH To allow incoming SSH connections on port 22, run: $ sudo ufw allow 22/tcp This is required to manage your Ubuntu server remotely using SSH. 6. UFW Allow DNS Traffic DNS uses UDP protocol on port 53. To allow incoming DNS queries, run: $ sudo ufw allow 53/udp 7. UFW Allow VNC To allow incoming VNC connections (usually port 5900 ), run: $ sudo ufw allow 5900/tcp 8. UFW Deny Port To block specific ports or protocols, use deny instead of allow. For example, to block incoming SMTP traffic: $ sudo ufw deny 25/tcp Closing tcp and udp ports, replace 80 with the desired port number: $ sudo ufw deny 80 For a port range you use the syntax: $ ufw deny 1234:2345 $ ufw deny 1234:2345/tcp $ ufw deny 1234:2345/udp 9. UFW Set Default Policies By default, the UFW incoming policy is set to deny, which means all incoming traffic is blocked. You can change this policy using: $ sudo ufw default deny incoming # To deny all incoming traffic $ sudo ufw default allow incoming # To allow all incoming traffic Similarly, you can set the default outgoing policy using: $ sudo ufw default deny outgoing $ sudo ufw default allow outgoing It is recommended to keep the default incoming policy as deny for security. 10. UFW Checking Logs You can enable logging with the command: $ sudo ufw logging on Log levels can be set by running sudo ufw logging low|medium|high, selecting either low, medium, or high from the list. The default setting is low. UFW keeps logs of denied connections in /var/log/ufw.log. You can view the log file using: $ sudo less /var/log/ufw.log To enable verbose logging, run: $ sudo ufw logging verbose Then UFW will log all allowed and denied connections. 11. UFW Delete Rules The syntax is as follows to list all of the current rules in a numbered list format: $ sudo ufw status numbered Status: active To Action From -- ------ ---- [ 1] 22/tcp ALLOW IN Anywhere [ 2] 80/tcp ALLOW IN Anywhere # accept Apache [ 3] 443/tcp ALLOW IN Anywhere # accept HTTPS connections [ 4] 1194/udp ALLOW IN Anywhere # OpenVPN server [ 5] 3000:4000/tcp ALLOW IN Anywhere [ 6] 3000:4000/udp ALLOW IN Anywhere To delete 6th rule type the command: $ sudo ufw delete 6 You can also delete rules for a specific port: $ sudo ufw delete allow 80 To flush all UFW rules and restore the default policy, run: $ sudo ufw reset 12. UFW Restore to default For some reason, you need to restore/delete all existing rules to return to the original defaults, use the reset option to do the following: $ sudo ufw disable $ sudo ufw reset $ sudo ufw enable This will: - Disable UFW - Flush existing rules - Re-enable UFW with the default configuration This ensures UFW works with the default settings again. 13. UFW Enable IPv6 Make sure the directive IPV6=yes do exists in /etc/default/ufw file. For instance: $ cat /etc/default/ufw Conclusion UFW is a powerful tool that can greatly improve the security of your servers when properly configured. This reference guide covers some common UFW rules that are often used to configure a firewall on Ubuntu. Your firewall is now configured to allow (at least) SSH connections. Be sure to allow any other incoming connections that your server needs, while limiting any unnecessary connections, so your server will be functional and secure. I hope this helps you configure and manage UFW firewall on Ubuntu 22.04. Let me know if you have any other questions!](https://b2bhostingclub.com/blog/wp-content/uploads/2026/01/How-To-Install-and-Config-UFW-Firewall-on-Ubuntu-22.04.png)









