OnCallReadyStart learning

ufw: program for managing a netfilter firewall

ufw [--force] enable|disable|reload | ufw default allow|deny|reject [incoming|outgoing|routed] | ufw status [verbose|numbered] | ufw [delete] [insert NUM] allow|deny|reject|limit RULE | ufw delete NUM | ufw app list|info

Options you will use

--version
show program's version number and exit
--force
answer yes to the confirmation (enable under ssh, reset, delete NUM)
enable
reloads firewall and enables firewall on boot (ENABLED=yes in /etc/ufw/ufw.conf). Under ssh it asks first.
disable
unloads firewall and disables firewall on boot
reload
reloads firewall
default allow|deny|reject DIRECTION
change the default policy for traffic going DIRECTION: incoming, outgoing or routed (/etc/default/ufw). Existing rules are not migrated.
logging on|off|LEVEL
toggle logging (LOG_KERN: journalctl -k shows the [UFW BLOCK] lines); levels low (default), medium, high, full
reset
disables and resets firewall to installation defaults (the old .rules files are kept with a timestamp)
status [verbose|numbered]
show status of firewall and ufw managed rules; 'Anywhere' = any address
show added
the rules as the commands that added them
allow|deny|reject|limit ARGS
add a rule: simple syntax PORT[/PROTOCOL] or APPNAME, full syntax [proto PROTOCOL] [from ADDRESS [port PORT]] [to ADDRESS [port PORT]] [comment COMMENT]
delete RULE|NUM
deletes the corresponding RULE (NUM from status numbered asks first)
insert NUM RULE
insert the corresponding RULE as rule number NUM
prepend RULE
prepend the corresponding RULE to the top of the ruleset
app list | app info PROFILE
application profiles from /etc/ufw/applications.d (OpenSSH = 22/tcp)

Examples

$ sudo ufw allow from 10.64.0.2 to any port 22 proto tcp

SSH only from the admin address - add it BEFORE enable

$ sudo ufw allow from 10.64.0.10 to any port 10250 proto tcp

the kubelet API only from the control plane

$ sudo ufw --force enable

turn it on without the ssh question

$ sudo ufw status numbered

the rules with the numbers delete NUM uses

$ sudo ufw limit ssh

allow, but reject an address that opens 6 or more connections within 30 seconds

Gotchas

Try ufw in a real terminal Free, in your browser - a real Ubuntu terminal to try it in, with missions that check your work.