//允许192.168.0.2主机进行ssh访问,以访问此主机上的任何IP地址 ufw allow proto tcp from 192.168.0.2 to any port 22 //允许一个网段 ufw allow proto tcp from 192.168.0.0/24 to any port 22
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 [--dry-run] route [delete] [insert NUM] allow|deny|reject|limit [in|out on INTERFACE] [log|log-all] [proto PROTOCOL] [from ADDRESS [port PORT | app APPNAME]] [to ADDRESS [port PORT | app APPNAME]] [comment COMMENT]
ufw [--dry-run] delete NUM
ufw [--dry-run] app list|info|default|update
OPTIONS --version show program's version number and exit -h, --help show help message and exit --dry-run don't modify anything, just show the changes
enable reloads firewall and enables firewall on boot.
disable unloads firewall and disables firewall on boot
reload reloads firewall
default allow|deny|reject DIRECTION change the default policy for traffic going DIRECTION, where DIRECTION is one of incoming, outgoing or routed. Note that existing rules will have to be migrated manually when changing the default policy. See RULE SYN‐ TAX for more on deny and reject.
logging on|off|LEVEL toggle logging. Logged packets use the LOG_KERN syslog facility. Systems configured for rsyslog support may also log to /var/log/ufw.log. Specifying a LEVEL turns logging on for the specified LEVEL. The default log level is 'low'. See LOGGING for details.