How To Configure Firewall with UFW on Ubuntu
The Remote Desktop Protocol (RDP) is a protocol developed by Microsoft for remote access to a computer running the Windows operating system. With the help of the protocol, screen displays and control commands can be transmitted in encrypted form over IP networks such as the Internet. RTP implementations also exist for other operating systems.
In this article, we will guide you through the steps to install and set up a firewall on Ubuntu with UFW.
By default, Ubuntu has a built-in firewall: UFW, which stands for “Uncomplicated Firewall” – ie uncomplicated firewall. For beginners in the Linux world, it is often difficult to use the alternative “IPTables” to block IPs or ports in order to configure the firewall correctly. UFW makes this step easier for you and forms an interface to the IPTables in Ubuntu. You can find out how to use UFW correctly below.
- Ubuntu Server
How to configure UFW via terminal
UFW is an interface to IPTables, which should simplify the process of configuring a firewall. If you want to back up the network or monitor the incoming and outgoing connections of your server, you cannot avoid a firewall. UFW is a practical tool that can be controlled and configured via the terminal in Ubuntu:
1. Step: requirements
To follow our instructions, UFW must be installed on your Linux system. The tool should already be installed by default. If this is not the case, UFW can be installed with the following command:
sudo apt-get install ufw
2nd. Step: set up standard guidelines
Before you create your own rules for the firewall, you should first define how incoming and outgoing data traffic is handled. By default, all incoming connections are denied and all outgoing connections are permitted. If any incoming connection were allowed, everyone could reach your server from outside. To ensure that the default settings are set correctly, enter the following commands one after the other:These settings would be sufficient for a PC. However, if you have a server and have to release various services for incoming connections, you have to create rules for this:
sudo ufw default deny incoming
sudo ufw default allow outgoing
3rd. Step: set rules and allow connections
If you activate UFW at this time, all incoming connections would be denied by default. However, if you want to allow certain connections, you must allow them via a created rule. An example of this are SSH connections ( Secure Shell ). You can access and manage your server from outside via SSH. So if you want to allow the service, enter the following command:The process works analogously for ftp or http. You can also enter its port number instead of specifying the service. For example, enter port 22 for SSH:Via the command “” you can refuse a connection.The rule can be deleted completely via:
sudo ufw allow ssh
sudo ufw allow 22
sudo ufw deny ssh
sudo ufw delete allow ssh or. If you made a mistake in creating the rules, you can reset the rules to the factory settings. It works over:Tip: All services can be found at Etc/. To do this, enter “less / etc / services” to have them listed.
sudo ufw delete deny ssh
sudo ufw reset
4th. Step: activate UFW and check the status
Once you have created all the firewall rules you need for incoming and outgoing connections, it is time to activate UFW. To do this, use the command via the command. you can also deactivate the service if necessary. Now that the firewall is active, it is advisable to check the status of the firewall in order to see the rules created. Enter the following command for a detailed list:
sudo ufw enable
sudo ufw disable
sudo ufw status verbose
5. Step: Allow special port areas and IPs
UFW enables access to port areas instead of individual ports. Here you have to specify the protocol – i.e. UDP or TCP – for which the rules should apply. If the range of ports you want to allow ranges from 6000 to 6010, you must execute the following commands for UDP and TCP in the terminal: It is also possible to specify permitted IP addresses with UFW. Would you like Allow connections from the private IP address 192.169.256.50, execute the following command: You can also allow certain ports for an IP address. To do this, if a connection is to be established via SSH to the above IP address, you must release port 22. This works with the following command:
sudo ufw allow 6000:6010/udp
sudo ufw allow 6000:6010/tcp
sudo ufw allow from 192.169.256.50
sudo ufw allow from 192.169.256.50
to any port 22
Your firewall is now configured. If you have followed our instructions, SSH connections will be allowed. If you would like to allow other connections, create appropriate rules for this.