Skip to content

ufw - Die einfache Firewall

Linux
  • Was ist ufw?

    Uncomplicated Firewall (ufw) — The Uncomplicated Firewall (ufw, and gufw - a Graphical User Interface version of the same) is a frontend for iptables and is particularly well-suited for host-based firewalls. Ufw provides a framework for managing netfilter, as well as a command-line interface for manipulating the firewall.

    Quelle: https://wiki.debian.org/Uncomplicated Firewall (ufw)

    ufw ist nur ein Frontend, im Hintergrund wird weiterhin iptables benutzt. Aber ufw ist wesentlich einfacher. Ja, ich kann mir nicht alles merken 😉

    Ich wollte das mal ausprobieren um zu schauen, ob das meine iptables Einstellungen ersetzen kann. Das hier behandelt ufw nur im Kontext einer Server Installation. Solltet ihr das für einen Desktop benötige, dafür gibt es gufw. Ok, auf geht's..

    Installation

    apt install ufw
    

    Standardeinstellungen

    root@test-server:~# ufw status
    Status: active
    
    To                         Action      From
    --                         ------      ----
    OpenSSH                    ALLOW       Anywhere                  
    OpenSSH (v6)               ALLOW       Anywhere (v6)
    

    Hier sieht man den Status, nachdem ich mittels Ansible einen Server in der Hetzner Cloud erstellt habe. Dazu setze ich ein paar Einstellungen, die wären.

        #####################
        # Setup UFW
        #####################
        - name: Enable UFW
           community.general.ufw:
           state: enabled
    
        - name: Set policy IN
          community.general.ufw:
            direction: incoming
            policy: deny
    
        - name: Set policy OUT
          community.general.ufw:
            direction: outgoing
            policy: allow
    
        - name: Set logging
          community.general.ufw:
            logging: 'on'
    
        - name: Allow OpenSSH rule
          community.general.ufw:
            rule: allow
            name: OpenSSH
    

    Auf der Konsole wäre das dann folgendes

    ufw default deny incoming
    ufw default allow outgoing
    ufw logging on
    ufw allow 22/tcp
    

    Ein

    ufw enable
    

    und die Firewall ist aktiv. Kann man mit

    root@test-server:~# ufw status
    Status: active
    
    To                         Action      From
    --                         ------      ----
    22/tcp                     ALLOW       Anywhere                  
    22/tcp (v6)                ALLOW       Anywhere (v6)  
    

    überprüfen. Ihr könnt auch mit

    iptables -L
    ip6tables -L
    

    die entsprechenden Einstellungen für iptables Euch anschauen.

    root@test-server:~# iptables -L
    Chain INPUT (policy DROP)
    target     prot opt source               destination         
    ufw-before-logging-input  all  --  anywhere             anywhere            
    ufw-before-input  all  --  anywhere             anywhere            
    ufw-after-input  all  --  anywhere             anywhere            
    ufw-after-logging-input  all  --  anywhere             anywhere            
    ufw-reject-input  all  --  anywhere             anywhere            
    ufw-track-input  all  --  anywhere             anywhere            
    
    Chain FORWARD (policy DROP)
    target     prot opt source               destination         
    ufw-before-logging-forward  all  --  anywhere             anywhere            
    ufw-before-forward  all  --  anywhere             anywhere            
    ufw-after-forward  all  --  anywhere             anywhere            
    ufw-after-logging-forward  all  --  anywhere             anywhere            
    ufw-reject-forward  all  --  anywhere             anywhere            
    ufw-track-forward  all  --  anywhere             anywhere            
    
    Chain OUTPUT (policy ACCEPT)
    target     prot opt source               destination         
    ufw-before-logging-output  all  --  anywhere             anywhere            
    ufw-before-output  all  --  anywhere             anywhere            
    ufw-after-output  all  --  anywhere             anywhere            
    ufw-after-logging-output  all  --  anywhere             anywhere            
    ufw-reject-output  all  --  anywhere             anywhere            
    ufw-track-output  all  --  anywhere             anywhere            
    
    Chain ufw-after-forward (1 references)
    target     prot opt source               destination         
    [..gekürzt..]
    

    Mit

    ufw reset
    

    löscht man alle Einstellungen.

    Hier noch die Ausgabe auf --help

    root@test-server:~# ufw --help
    
    Usage: ufw COMMAND
    
    Commands:
     enable                          enables the firewall
     disable                         disables the firewall
     default ARG                     set default policy
     logging LEVEL                   set logging to LEVEL
     allow ARGS                      add allow rule
     deny ARGS                       add deny rule
     reject ARGS                     add reject rule
     limit ARGS                      add limit rule
     delete RULE|NUM                 delete RULE
     insert NUM RULE                 insert RULE at NUM
     prepend RULE                    prepend RULE
     route RULE                      add route RULE
     route delete RULE|NUM           delete route RULE
     route insert NUM RULE           insert route RULE at NUM
     reload                          reload firewall
     reset                           reset firewall
     status                          show firewall status
     status numbered                 show firewall status as numbered list of RULES
     status verbose                  show verbose firewall status
     show ARG                        show firewall report
     version                         display version information
    
    Application profile commands:
     app list                        list application profiles
     app info PROFILE                show information on PROFILE
     app update PROFILE              update PROFILE
     app default ARG                 set default application policy
    
  • Um eine Rule zu löschen, macht man folgendes

    root@semaphore:/home/semaphore# ufw status numbered
    

    Status: active

    Um eine Rule zu löschen, macht man folgendes

    root@semaphore:/home/semaphore# ufw status numbered
    Status: active
    
         To                         Action      From
         --                         ------      ----
    [ 1] 22/tcp                     ALLOW IN    Anywhere                  
    [ 2] 3000/tcp                   ALLOW IN    Anywhere                  
    [ 3] 80                         ALLOW IN    Anywhere                  
    [ 4] 443                        ALLOW IN    Anywhere                  
    [ 5] 22/tcp (v6)                ALLOW IN    Anywhere (v6)             
    [ 6] 3000/tcp (v6)              ALLOW IN    Anywhere (v6)             
    [ 7] 80 (v6)                    ALLOW IN    Anywhere (v6)             
    [ 8] 443 (v6)                   ALLOW IN    Anywhere (v6)          
    

    Jetzt kann man mit der Nummer die Rule löschen.

     root@semaphore:/home/semaphore# ufw delete 2
     Deleting:
      allow 3000/tcp
     Proceed with operation (y|n)? y       
     Rule deleted
    
  • Beispiel um eingehend einen Port für eine IP-Adresse zu erlauben.

    ufw allow from 1.1.1.1 to any port 8000
    
  • Update 1.30.3 released

    Vaultwarden
    1
    0 Stimmen
    1 Beiträge
    109 Aufrufe
    Niemand hat geantwortet
  • Debian Installer Bookworm RC3 released

    Linux
    2
    0 Stimmen
    2 Beiträge
    131 Aufrufe
    FrankMF
    Und da sind wir schon bei RC4 https://lists.debian.org/debian-devel-announce/2023/05/msg00003.html
  • Manjaro KDE Plasma 21.2.6

    Linux
    16
    2
    0 Stimmen
    16 Beiträge
    617 Aufrufe
    FrankMF
    @FrankM sagte in Manjaro KDE Plasma 21.2.6: Eines betrifft die Anordnung der Icons auf dem Desktop. Die Anordnung, die ich wähle, werden immer wieder geändert. Unschön, aber den Desktop nutze ich so gut wie gar nicht. Also kann ich auch auf den Fix warten. Kann noch was dauern https://pointieststick.com/2023/03/03/this-week-in-kde-plasma-6-begins/ Desktop icons on the active activity should no longer inappropriately re-arrange themselves when the set of connected screens changes. However during the process of investigation, we discovered that the code for storing desktop file position is inherently problematic and in need of a fundamental rewrite just like we did for multi-screen arrangement in Plasma 5.27. This will be done for Plasma 6.0, and hopefully make Plasma’s long history of being bad about remembering desktop icon positions just that–history (Marco Martin, Plasma 5.27.3. Link)
  • 2,5G

    Linux
    2
    1
    0 Stimmen
    2 Beiträge
    162 Aufrufe
    FrankMF
    Gutes Video zum Zyxel Switch, was ich vorher gar nicht kannte. Hätte meine Entscheidung aber auch nicht verändert. https://www.youtube.com/watch?v=59I-RlliRms
  • Kopia - APT Repository verfügbar

    Kopia
    1
    0 Stimmen
    1 Beiträge
    215 Aufrufe
    Niemand hat geantwortet
  • Debian 10.4 released und Wireguard kaputt :(

    Linux
    1
    0 Stimmen
    1 Beiträge
    258 Aufrufe
    Niemand hat geantwortet
  • ROCKPro64 - Kamils neuer 0.10.x Release

    ROCKPro64
    1
    1
    0 Stimmen
    1 Beiträge
    241 Aufrufe
    Niemand hat geantwortet
  • NodeBB - Upgrade auf v1.9.0

    NodeBB
    2
    1
    0 Stimmen
    2 Beiträge
    865 Aufrufe
    FrankMF
    Da oben fehlt ein Schritt. cd nodebb (or path to where nodebb is installed) ./nodebb stop git fetch git checkout v1.12.x git merge origin/v1.12.x ./nodebb upgrade Beim nächsten Upgrade testen.