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
    

  • KDE Plasma 6 - RC1

    Linux
    3
    0 Stimmen
    3 Beiträge
    110 Aufrufe
    FrankMF

    Heute die letzte Unstable Edition von KDE Neon installiert. Es gab folgende Version.

    neon-unstable-20240201-2132.iso

    Meldet sich bei mir immer noch nur als DEV Version und nicht als RC2 🤔 Wenn einer einen Tipp für mich hat....

    Der Installer soll mich ja nicht mehr interessieren, aber mir ist aufgefallen, das er jetzt den Standort hinbekommt.

    Ansonsten läuft es soweit rund. Habt ihr schon mal einen Firefox ohne Addblocker benutzt? Grausam! Kann mir gar nicht vorstellen, so was in meinem Leben nochmal zu benutzen.

  • Semaphore - Die API

    Verschoben Ansible
    2
    0 Stimmen
    2 Beiträge
    132 Aufrufe
    FrankMF

    Ich hasse schlecht lesbaren Code, scheint man sich bei Python so anzugewöhnen. Habe da nochmal was mit der langen Zeile getestet.

    stages: - deploy deploy: stage: deploy script: # $SEMAPHORE_API_TOKEN is stored in gitlab Settings/ CI/CD / Variables - >- curl -v XPOST -H 'Content-Type: application/json' -H 'Accept: application/json' -H "Authorization: Bearer $SEMAPHORE_API_TOKEN " -d '{"template_id": 2}' https://<DOMAIN>/api/project/2/tasks only: - master # Specify the branch to trigger the pipeline (adjust as needed)

    Hier noch was Dr. ChatGPT dazu schreibt

    631de9d4-b04d-4043-bfff-c5f2d1b6eea7-grafik.png

    Erledigt - läuft 🙂 Und verstanden habe ich es auch.

  • OpenWrt - Basics der Firewall

    Linux
    1
    0 Stimmen
    1 Beiträge
    93 Aufrufe
    Niemand hat geantwortet
  • 10G

    Linux
    2
    0 Stimmen
    2 Beiträge
    125 Aufrufe
    FrankMF

    Bedingt durch ein paar Probleme mit der Forensoftware, habe ich einen kleinen Datenverlust erlitten. Dazu gehören auch hier einige Beiträge. Dann versuche ich das mal zu rekonstruieren.

    Oben hatten wir das SFP+ Modul ja getestet. Als nächsten Schritt habe ich die ASUS XG-C100F 10G SFP+ Netzwerkkarte in meinen Hauptrechner verbaut.

    20211028_162455_ergebnis.jpg

    Die Verbindung zum Zyxel Switch erfolgt mit einem DAC-Kabel. Im Video zum Zyxel Switch wurde schön erklärt, das die DAC Verbindung stromsparender als RJ45 Adapter sind. Somit fiel die Wahl auf die DAC Verbindungen. Hier nochmal das Video.

    So sieht so ein DAC Verbindungskabel aus. Die SFP+ Adapter sind direkt daran montiert.

    20211028_170118_ergebnis.jpg

    ethtool root@frank-MS-7C37:/home/frank# ethtool enp35s0 Settings for enp35s0: Supported ports: [ FIBRE ] Supported link modes: 100baseT/Full 1000baseT/Full 10000baseT/Full 2500baseT/Full 5000baseT/Full Supported pause frame use: Symmetric Receive-only Supports auto-negotiation: Yes Supported FEC modes: Not reported Advertised link modes: 100baseT/Full 1000baseT/Full 10000baseT/Full 2500baseT/Full 5000baseT/Full Advertised pause frame use: Symmetric Advertised auto-negotiation: Yes Advertised FEC modes: Not reported Speed: 10000Mb/s Duplex: Full Port: FIBRE PHYAD: 0 Transceiver: internal Auto-negotiation: on Supports Wake-on: pg Wake-on: g Current message level: 0x00000005 (5) drv link Link detected: yes iperf3 ----------------------------------------------------------- Server listening on 5201 ----------------------------------------------------------- Accepted connection from 192.168.3.207, port 44570 [ 5] local 192.168.3.213 port 5201 connected to 192.168.3.207 port 44572 [ ID] Interval Transfer Bitrate Retr Cwnd [ 5] 0.00-1.00 sec 1.10 GBytes 9.43 Gbits/sec 46 1.59 MBytes [ 5] 1.00-2.00 sec 1.10 GBytes 9.42 Gbits/sec 0 1.60 MBytes [ 5] 2.00-3.00 sec 1.10 GBytes 9.42 Gbits/sec 3 1.60 MBytes [ 5] 3.00-4.00 sec 1.10 GBytes 9.42 Gbits/sec 0 1.60 MBytes [ 5] 4.00-5.00 sec 1.10 GBytes 9.42 Gbits/sec 0 1.61 MBytes [ 5] 5.00-6.00 sec 1.10 GBytes 9.42 Gbits/sec 0 1.63 MBytes [ 5] 6.00-7.00 sec 1.10 GBytes 9.42 Gbits/sec 0 1.63 MBytes [ 5] 7.00-8.00 sec 1.09 GBytes 9.41 Gbits/sec 0 1.68 MBytes [ 5] 8.00-9.00 sec 1.10 GBytes 9.42 Gbits/sec 0 1.68 MBytes [ 5] 9.00-10.00 sec 1.10 GBytes 9.42 Gbits/sec 0 1.68 MBytes [ 5] 10.00-10.02 sec 22.5 MBytes 9.45 Gbits/sec 0 1.68 MBytes - - - - - - - - - - - - - - - - - - - - - - - - - [ ID] Interval Transfer Bitrate Retr [ 5] 0.00-10.02 sec 11.0 GBytes 9.42 Gbits/sec 49 sender
  • Hetzner Cloud - Firewall BETA

    Linux
    1
    0 Stimmen
    1 Beiträge
    325 Aufrufe
    Niemand hat geantwortet
  • 0 Stimmen
    1 Beiträge
    170 Aufrufe
    Niemand hat geantwortet
  • Logger

    Linux
    1
    0 Stimmen
    1 Beiträge
    393 Aufrufe
    Niemand hat geantwortet
  • Minicom

    Linux
    1
    0 Stimmen
    1 Beiträge
    476 Aufrufe
    Niemand hat geantwortet