Featured image of post ufw 命令

ufw 命令

列出防火墙规则

ufw status 
ufw status numbered

添加端口

ufw allow PORT

允许指定端口的TCP连接

ufw allow PORT/tcp

允许指定端口的TCP连接

ufw allow PORT/tcp
ufw allow proto tcp to any port PORT

允许指定范围的端口的TCP连接

ufw allow PORT1:PORT2/tcp

允许指定网卡的连接

ufw allow in on ETH0 to any port PORT

删除端口

ufw delete NUMBER // 通过编号删除
sudo ufw delete 1
ufw delte allow PORT // 通过规则删除
sudo ufw delete allow 80/tcp

允许指定ip的指定端口访问

ufw allow from IP/24 to any port PORT

禁止指定IP的指定端口访问

ufw deny from IP/24 to any port PORT

重置规则

ufw reset

应用配置文件

ufw app list
ufw app info
ufw allow 'VNC'

查看日志

默认存储为 /var/log/ufw*

查看是否开启日志

sudo ufw status verbose
# Status: active
# Logging: on (low)
# Default: deny (incoming), allow (outgoing), deny (routed)
# New profiles: skip

开启日志

sudo ufw logging on

查看最新的日志

sudo tail -n 10 /var/log/ufw.log

实时监控日志的更新

sudo tail -f /var/log/ufw.log

按页查看日志

sudo less /var/log/ufw.log
Licensed under CC BY-NC-SA 4.0