Ubuntu installation UFW firewall
For general users, just the following settings:
sudo apt-get install UFW
sudo UFW enable
sudo ufw default deny
The above three commands are safe enough if you need to open certain services and then use sudo ufw allow to open them. enabled
sudo ufw enable
sudo ufw default deny
#运行以上两条命令后, opens the firewall, and opens automatically when the system starts.
Open/Disable
turn on or off a port, for example:
sudo ufw allow SMTP #允许所有的外部IP访问本机的25/tcp (SMTP) port
sudo ufw allow 22/tcp #允许所有的外部IP访问本机的22/tcp (SSH) port
sudo ufw allow #允许外部访问53端口 (tcp/udp)
sudo ufw allow from 192.168.1.100 #允许此IP访问所有的本机端口
sudo ufw allow Proto UDP 192.168.0.1 port to 192.168.0.2 Port
sudo ufw deny SMTP #禁止外部访问smtp服务
View firewall Status
Add:
#开启/Shutdown firewall (the default setting is ' Disable ')
UFW enable|disable
#转换日志状态
UFW logging On|off
#设置默认策略 (for example, "mostly open "vs" mostly closed ")
UFW default Allow|deny
#许可或者屏蔽某些入埠的包 (you can see the list of services [see below] in" status ")
#可以用" protocols: Ports " To specify a service name that exists in/etc/services, or through the meta-data of the package. The ' allow ' argument will add the entry to the/etc/ufw/maps, while ' deny ' is the opposite. The basic syntax is as follows:
UFW allow|deny [service]
#显示防火墙和端口的侦听状态, see/var/lib/ufw/maps. The numbers in parentheses will not be displayed.
UFW Status
UFW Use Example:
#允许 53 Port
$ sudo ufw allow
#禁用 53 port
$ sudo ufw delete allow
#允许 80 port
$ sudo ufw allow 80/tcp
#禁用 80 Port
$ sudo ufw delete allow 80/tcp
#允许 SMTP port
$ sudo ufw allow SMTP
#删除 SMTP port
$ sudo UFW Delete Allow SMTP
#允许某特定 IP
$ sudo ufw allow from 192.168.254.254
#删除上面的规则
$ sudo ufw delete allow From 192.168.254.254
Note
Reason why LAN Ping does not work on Mac host:
1. Network connection or network instability
2. Mac computer lock screen or shutdown
3. Firewall settings
4. ICMP protocol settings