How To Configure Firewall with UFW on Ubuntu 20.04 LTS

Originally published at: https://www.cyberciti.biz/faq/how-to-configure-firewall-with-ufw-on-ubuntu-20-04-lts/

How do I set up and configure firewall with UFW on Ubuntu 20.04 LTS server?

error grep
-w, --word-regexp match only whole words

grep -w ‘DPT=22’ /var/log/ufw.log |
egrep -o ‘SRC=([0-9]{1,3}[.]){3}[0-9]{1,3}’ |
awk -F’=’ ‘{ print $2 }’ | sort -u

that will work correctly