Ubuntu firewall ufw commands

17. janvāris, 2019
Bash
sudo ufw default deny incoming
Bash
sudo ufw default deny outgoing

Allow incoming requests from specific ip address to specific port
For example only from [ip] access to ssh

Bash
ufw allow from [ip] to any port 22 proto tcp

Allow outgoing requests to specific port. For example allow outgoing email requests

Bash
ufw allow out 465
ufw allow out 587

Web, allow incoming and outgoing web trafic
Allow outgoing to port 80 on tcp

Bash
ufw allow out proto tcp to any port 80

Allow incoming on port 80

Bash
ufw allow in proto tcp to any port 80

Show all rules numbered. Useful for deleting specific rule

Bash
ufw status numbered

Delete rule by number

Bash
ufw delete [number]
JavaScript
ufw insert 1 allow out to [ip] port 9418 proto tcp
Bash
ufw insert 1 allow out 587