Skip to content

Instantly share code, notes, and snippets.

@mauvehed
Last active January 1, 2025 14:29
Show Gist options
  • Save mauvehed/f57265756478f1b3d53b48b807fb2b47 to your computer and use it in GitHub Desktop.
Save mauvehed/f57265756478f1b3d53b48b807fb2b47 to your computer and use it in GitHub Desktop.

Revisions

  1. mauvehed revised this gist Jan 1, 2025. 1 changed file with 49 additions and 0 deletions.
    49 changes: 49 additions & 0 deletions ufw_quick_start.md
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,8 @@

    ## Quck Start

    https://www.digitalocean.com/community/tutorials/how-to-set-up-a-firewall-with-ufw-on-ubuntu

    Should be `yes`:
    ```sh
    grep IPV6 /etc/default/ufw
    @@ -40,3 +42,50 @@ sudo ufw allow ssh
    sudo ufw allow 22
    ```

    HTTP on port 80, which is what unencrypted web servers use, using `sudo ufw allow http` or `sudo ufw allow 80`

    HTTPS on port 443, which is what encrypted web servers use, using `sudo ufw allow https` or `sudo ufw allow 443`

    Apache with both HTTP and HTTPS, using `sudo ufw allow ‘Apache Full’`

    Nginx with both HTTP and HTTPS, using `sudo ufw allow ‘Nginx Full’`

    ### Port Ranges

    ```sh
    sudo ufw allow 6000:6007/tcp
    ```

    ```sh
    sudo ufw allow 6000:6007/udp
    ```

    ```sh
    sudo ufw allow from 203.0.113.4 to any port 22
    ```

    ### Interfaces

    ```sh
    sudo ufw allow in on eth0 to any port 80
    ```

    ### Denying

    ```sh
    sudo ufw deny http
    ```

    ```sh
    sudo ufw deny from 203.0.113.4
    ```

    ### Delete Rule

    ```sh
    sudo ufw status numbered
    ```

    ```sh
    sudo ufw delete 2
    ```
  2. mauvehed created this gist Jan 1, 2025.
    42 changes: 42 additions & 0 deletions ufw_quick_start.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,42 @@

    ## Quck Start

    Should be `yes`:
    ```sh
    grep IPV6 /etc/default/ufw
    ```

    ```sh
    sudo ufw default deny incoming
    ```

    ```sh
    sudo ufw default allow outgoing
    ```

    ```sh
    sudo ufw allow OpenSSH
    ```

    ```sh
    sudo ufw show added
    ```

    ```sh
    sudo ufw enable
    ```

    ### Examples

    ```sh
    sudo ufw allow OpenSSH
    ```

    ```sh
    sudo ufw allow ssh
    ```

    ```sh
    sudo ufw allow 22
    ```