Linux – UFW Firewall Setup (ufw)

UFW is a simple firewall application that is included with Ubuntu nd can be installed on other distributions of Linux.

Note: For the demonstrations to work you may need to change settings or hardware configurations within your virtualization software. I had to connect my host machine to a hard word connection for Rules for specific IP Addresses to work.

  • sudo ufw status – shows current status of ufw
  • sudo ufw enable – Enables ufw firewall
    • By default ALL incoming traffic is blocked
    • sudo ufw disable – Disables ufw
  • sudo ufw status verbose – Shows all Rules currently configured for ufw
  • sudo ufw allow 21 – Allows specific port
  • sudo ufw allow ssh – Allows ports for a specific service
  • sudo ufw status numbered – Shows rules in numbered order so that you can delete specific rules
  • sudo ufw delete 1 – Deletes rule based on number
  • sudo ufw allow from 192.168.1.2 – Allows traffic from a specific IP address to all ports
  • sudo ufw allow from 192.168.1.0/24 – Allows traffic from a subnet to all ports
  • sudo ufw allow from 192.168.1.2 to any port 22 – Allows traffic from a specific IP address to a specific port
  • sudo ufw allow from 192.168.1.0/24 to any port 22 – Allows traffic from a subnet to a specific port
  • sudo ufw reset – Deletes all rules and disables ufw

Be the first to comment

Leave a Reply