banner
xingli

xingli

猫娘爱好者

ufw Firewall Tutorial

ufw Firewall Tutorial#

Uninstall the package using apt-get --purge remove package name

Ubuntu Firewall#

You can enable UFW on Linux by following these steps:

  1. First, check if UFW is installed. Enter the following command in the terminal:

sudo ufw status

If it prompts "command not found," it means UFW is not installed on this system. You need to execute the following command to install UFW:

sudo apt-get install ufw

  1. To activate UFW, set the default UFW policies to deny:

sudo ufw default deny incoming

sudo ufw default allow outgoing

  1. Open the necessary ports. For example, open SSH port 22 (modify as needed):

sudo ufw allow 22/tcp

  1. Finally, enable UFW and check the status:

sudo ufw enable

sudo ufw status

If you see "Status: active" in the output, it means UFW has been successfully enabled.

sudo ufw allow 22
// Open port 22
sudo ufw reload
// Restart UFW firewall
sudo ufw status
// Check firewall status
sudo netstat -tunlp | grep 22
// View information about port 22
sudo ufw disable
// Disable firewall
sudo sudo apt-get install ufw
// Install firewall
sudo ufw enable
// Enable firewall
sudo ufw delete allow 21
// Close port 21
sudo ufw allow 8001/tcp
// Specify opening port 8001 with TCP protocol
sudo ufw delete allow 8001/tcp
// Close port 8001

Resolving Port Occupancy#

  1. Enter the following command to view all service ports and display the PID number.
netstat -ap

To stop this process, you can use the kill command.

kill 123
// Stop the process with PID 123 and its associated port.

To view port 8080, you can use the grep command:

netstat -ap | grep 3000

To view port 8888, enter the following command in the terminal:

lsof -i:8888
Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.