Disable and enable firewall in Ubuntu
1. Ubuntu uses the UFW firewall by default and supports interface operations.
Run the UFW command on the command line to see a series of operations that can be performed. Enable<span style="white-space:pre"></span><span style="color:#ff0000;">sudo ufw enable<span style="white-space:pre"></span>sudo ufw default deny</span>
After running the preceding two commands, the firewall is enabled and automatically enabled when the system starts. Disable all external access to the local machine, but the local access to the external is normal.
2. enable/disable
sudo ufw allow|deny [service]
Open or close a port, for example:
Sudo UFW allow SMTP allows all external IP addresses to access the local port 25/tcp (SMTP ).
Sudo UFW allow 22/tcp allows all external IP addresses to access the local port 22/tcp (SSH)
Sudo UFW allow 53 allows external access to port 53 (TCP/UDP)
Sudo UFW allow from 192.168.1.100 allows this IP address to access all local ports
sudo ufw allow proto udp 192.168.0.1 port 53 to 192.168.0.2 port 53
Sudo UFW deny SMTP prohibit external access to the SMTP service
Sudo UFW Delete allow SMTP delete a rule created above
Disable and enable firewall in Ubuntu