Linux command
ufw 命令
安全
权限或系统影响较大,执行前请核对目标。
常用示例
Enable
sudo ufw enable
Disable
sudo ufw disable
Example
sudo ufw status numbered
Allow
sudo ufw allow 5432 comment "Service"
Example
sudo ufw allow proto tcp from 192.168.0.4 to any port 22
Deny
sudo ufw deny 80
Example
sudo ufw deny proto udp from any to any port 8412:8500
Set default
sudo ufw default deny incoming
Allow
sudo ufw allow OpenSSH
Delete
sudo ufw delete [rule_number]
Example
sudo ufw route allow in on [eth0] out on [eth1]
说明
ufw (Uncomplicated Firewall) is a frontend for iptables/nftables designed to make firewall configuration easier. It provides a user-friendly interface for managing netfilter firewall rules while supporting both simple and complex rule specifications.
参数
- enable
- Enable the firewall and load rules on boot
- disable
- Disable the firewall and unload rules
- reload
- Reload the firewall configuration
- reset
- Reset to installation defaults
- status
- Show firewall status and rules
- status verbose
- Show detailed status with logging and default policies
- status numbered
- Show rules with line numbers for deletion
- --dry-run
- Show changes without applying them
- --force
- Execute without confirmation prompts
FAQ
What is the ufw command used for?
ufw (Uncomplicated Firewall) is a frontend for iptables/nftables designed to make firewall configuration easier. It provides a user-friendly interface for managing netfilter firewall rules while supporting both simple and complex rule specifications.
How do I run a basic ufw example?
Run `sudo ufw enable` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does enable do in ufw?
Enable the firewall and load rules on boot