# Allow port
sudo ufw allow $PORT_NUMBER
sudo ufw allow $PORT_NUMBER/tcp
# note: must allow the modified port of ssh first before restarting SSH
# Allow IP
sudo ufw allow from $IP_ADDRESS
# Allow IP range
sudo ufw allow from $IP/$CIDR
# Allow IP range on one port
sudo ufw allow from $IP/$CIDR to any port $PORT_NUMBER
# Block incoming requests from IP
sudo ufw insert 1 deny from $IP_ADDRESS
# note: insert 1 for on top of rule list, ufw follows the order of the rules
sudo ufw deny from $IP_ADDRESS # when there is no rule
# Block outgoing requests to IP
sudo ufw deny out from any to $IP_ADDRESS
# note: ssh is always an alias of 22
sudo ufw allow ssh
#sudo ufw allow 22