Skip to content

Instantly share code, notes, and snippets.

@carlessanagustin
Forked from drAlberT/CS_ufw.md
Last active March 7, 2018 17:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save carlessanagustin/84e0a334a6c9bae4b12e9919ce64f63d to your computer and use it in GitHub Desktop.
Save carlessanagustin/84e0a334a6c9bae4b12e9919ce64f63d to your computer and use it in GitHub Desktop.
UFW Cheatsheet

UFW cheat sheet

Usage

ufw [--dry-run] enable|disable|reload
ufw [--dry-run] default allow|deny|reject [incoming|outgoing]
ufw [--dry-run] 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'.
ufw [--dry-run] reset
ufw [--dry-run] status [verbose|numbered]
ufw [--dry-run] show REPORT
ufw [--dry-run] [delete] [insert NUM] allow|deny|reject|limit [in|out] [log|log-all] PORT[/protocol]
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]]
ufw [--dry-run] delete NUM
ufw [--dry-run] app list|info|default|update

Examples

ufw allow ssh | 22
ufw allow proto tcp to 0.0.0.0/0 port 22
ufw allow from 15.15.15.0/24 to any port 22

ufw deny from 15.15.15.51
ufw deny in on eth0 from 15.15.15.51
ufw allow proto tcp from any to any port 80,443
ufw deny out 25
ufw status <numbered>
ufw delete <rule_number>
ufw insert 1 <your_rule>
ufw status verbose
ufw status numbered verbose
ufw app list
ufw allow in on eth0 log from any to any app SSH-22022
ufw [delete] allow in proto udp from 193.204.114.105 to 12.34.56.78 port 123
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment