安装ufw
1 sudo apt update 2 sudo apt install ufw
开启防火墙
ufw enable
关闭防火墙
ufw disable
查看策略:
ufw status verbose ufw status numbered
恢复默认策略:
1 ufw default deny incoming 2 ufw default allow outgoing 3 ufw default reject routed
重置UFW(将删除所有自定义策略并关闭UFW)
ufw reset
添加允许连接的商端口:
ufw allow [port]
放行指定范围的端口:
1 ufw allow 10010:10086/tcp 2 ufw allow 10010:10086/udp
允许指定ip访问
1 # 放行ip 2 ufw allow 221.123.1.1 3 ufw allow 221.123.1.1 to any port 22 4 5 # 放行ip段 6 ufw allow 221.123.1.0/24 7 ufw allow 221.123.1.0/24 to any port 22
拒绝连接
1 ufw deny http 2 ufw deny from 221.123.1.1
删除规则
# 按编号删除 ufw delete [num] # 按实际规则删除 ufw delete allow http # or ufw delete allow 80
标签:221.123,ip,防火墙,port,allow,Debian,ufw From: https://www.cnblogs.com/cxd4321/p/18166750