turn off/on ubuntu firewall

Enable ufw
sudo ufw enable
sudo ufw default deny
After running the above two commands, the firewall is turned on and automatically turned on when the system starts. Close all external access to the machine, but the machine accesses external normally.

Enable and disable
sudo ufw allow|deny [service]
Open or close a port, for example:
sudo ufw allow smtp allows all external IPs to access the 25/tcp (smtp) port of the machine
sudo ufw allow 22/tcp allows all external IP access to local port 22/tcp (ssh)
sudo ufw allow 53 Allow external access to port 53 (tcp/udp)
sudo ufw allow from 192.168.1.100 Allow this IP 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 Forbid external access to the smtp service
sudo ufw delete allow smtp Delete a rule established above

Check the firewall status
sudo ufw status

Allow a specific IP
sudo ufw allow from xxx.xxx.xx.xxx

Remove license for smtp port

sudo ufw delete allow smtp


Original address: http://www.idcbest.com/help/html/meirigiaodian/338.html

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325651057&siteId=291194637