安装、启用
sudo apt install ufw #安装
sudo ufw enable #启动
sudo ufw disable #禁用
sudo ufw reload #重新载入
sudo ufw reset #回复初始化设置
sudo ufw status #防火墙状态
命令简介
Commands:
enable enables the firewall
disable disables the firewall
default ARG set default policy
logging LEVEL set logging to LEVEL
allow ARGS add allow rule
deny ARGS add deny rule
reject ARGS add reject rule
limit ARGS add limit rule
delete RULE|NUM delete RULE
insert NUM RULE insert RULE at NUM
route RULE add route RULE
route delete RULE|NUM delete route RULE
route insert NUM RULE insert route RULE at NUM
reload reload firewall
reset reset firewall
status show firewall status
status numbered show firewall status as numbered list of RULES
status verbose show verbose firewall status
show ARG show firewall report
version display version information
Application profile commands:
app list list application profiles
app info PROFILE show information on PROFILE
app update PROFILE update PROFILE
app default ARG set default application policy
命令详解
ufw allow|deny [service]
------------------------------------------------------------------------------------
ufw allow smtp #允许所有的外部IP访问本机的25/tcp (smtp)端口
ufw allow 22/tcp #允许所有的外部IP访问本机的22/tcp (ssh)端口
ufw allow 53 #允许外部访问53端口(tcp/udp)
ufw allow from ip_address #允许此IP访问所有的本机端口
ufw deny port #拒绝访问本机端口
ufw allow|deny to 172.26.106.87 #允许|禁止本地端口访问此 IP
ufw allow|deny to ip_address port 22,20,10:120 proto tcp|udp|ssh #允许|禁止 本地访问 指定IP 的某些端口
ufw allow|deny in on virbr0 to ip_address port num proto udp|tcp #允许|禁止 本地访问 指定网卡 virbr0 指定IP 的 特定端口
ufw allow|deny from 172.26.106.87 #允许|禁止 指定IP访问本地
ufw allow|deny from ip_address port 22,20,10:120 proto tcp|udp|ssh #允许|禁止 指定IP 的某些端口 访问 本地IP
ufw allow|deny out on virbr0 from ip_address port num proto udp|tcp #允许|禁止 指定ip 指定网卡 virbr0 指定IP 的 特定端口 访问本地
-------------------------------------------------------------------------------------------------
ufw allow in on virbr0 from 172.26.106.87 port 20,80,100:120 proto tcp to 172.26.106.103 port 80:100 #允许 172.26.106.87 端口 20,80,100:120 通过 TCP 协议 访问 172.26.106.103端口80:100
ufw [--dry-run] [delete] [insert NUM] allow|deny|reject|limit [in|out on INTERFACE] [log|log-all] [proto protocol] [from ADDRESS [port PORT]] [to ADDRESS [port PORT]]
#命令 [–试运行][删除][插到x号规则之前] 允许|阻止|拒绝|限制 [进|出 基于“什么网络设备”] [协议 “协议”] [来源 “地址” [端口 “端口”]] [目标 “地址” [端口 “端口”]]
网友评论