Linux is the best-known and most-used open-source operating system. As an operating system,
Linux is software that sits underneath all of the other software on a computer, receiving requests
from those programs and relaying these requests to the computer’s hardware.
A Linux distribution is a selection of coordinated software around the Linux kernel, which in some
cases is also a more or less adapted distribution kernel that is usually maintained in close
coordination with Upstream itself.
In computing, a firewall is a network security system that monitors and controls the incoming and
outgoing network traffic based on predetermined security rules. A firewall typically establishes a
barrier between a trusted network and an untrusted network, such as the Internet.
Requirements
★ Root privileges
★ UFW
Check the current status of the firewall in ubuntu
★ Type the following command:sudo ufw status verbose
★ Type Your Password and Press Enter.
★ Output Results will show you UFW Status is Active or Inactive.
★ If Output results are Inactive then you need to activate the UFW. Type the following command: sudo ufw enable. This will enable firewall and now you can open or block any port in ubuntu.
How To Open a TCP port in Ubuntu?
★ To allow incoming TCP Port, Type the following command: sudo ufw allow (port)/tcp
★ For example, To allow incoming TCP packets on port 22, enter:sudo ufw allow 22/tcp
★ Let’s check the configuration, Type the following command:sudo ufw status verbose
How To Deny/Block port access in Ubuntu?
★ To deny TCP Port, Type the following command:sudo ufw deny (port)/tcp
★ For example, To deny TCP packets on port 22, enter:sudo ufw deny 22/tcp
★ Let’s check the configuration, Type the following command:sudo ufw status verbose