Skip to main content

Ufw Cheat Sheet

#

Ufw

Ufw

##

Basic commands
-

`
    sudo ufw status`
     status
      Check status (usually "inactive" by default).
    - `sudo ufw status numbered`
     numbered
      List rules with ID numbers (great for deleting).
    - `sudo ufw enable`
     enable
      Turn the firewall **ON**
    -ON `sudo ufw disable`
     disable
      Turn the firewall **OFF**
    -OFF `sudo ufw reload`
     reload
      ✔Apply changes after editing rules.
    ###

    Defaults


          ```shell
        sudo ufw default deny incoming
        sudo uwf default allow outgoing
     

    ```
    ###

    Allow **HTTP**HTTP (80)


          ```shell
        sudo ufw allow http
       ```
     
      or
       ```shell
        sudo ufw allow 80
     

    ```
    ###

    Allow **HTTPS**HTTPS (443)


          ```shell
        sudo ufw allow https
       ```
     
      or 
       ```shell
        sudo ufw allow 443
     

    ```
    ###

    Allow a Port **Range**
    Range


          ```shell
        sudo ufw allow 8000:8100/tcp
     

    ```
    ###

    Allow entire **subnet**subnet to all ports


          ```shell
        sudo ufw allow from 192.168.1.0/24
     

    ```
    ###

    Allow a specific **IP**
    IP


          ```shell
        sudo ufw allow from 192.168.1.50
     

    ```
    ###

    Allow IP to a specific **port**
    port


          ```shell
        sudo ufw allow from 192.168.1.50 to any port 22
     

    ```
    ###

    Allow **subnet**subnet to specific **port**port with specific **protocol**protocol with **comment**
    comment


          ```shell
        sudo ufw allow from 192.168.10.0/24 to any port 5900 proto tcp comment \
        "Allow VNC from .10.0/24 subnet"
     

    ```