Skip to content

ufw - Die einfache Firewall

Linux
3 1 336
  • 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
    
  • Podman - Secrets

    Podman podman linux
    1
    0 Stimmen
    1 Beiträge
    183 Aufrufe
    Niemand hat geantwortet
  • Fedora 40 - Updates

    Linux fedora linux kde
    1
    3
    0 Stimmen
    1 Beiträge
    213 Aufrufe
    Niemand hat geantwortet
  • Nextcloud - Update auf 28.0.2

    Nextcloud nextcloud linux
    2
    0 Stimmen
    2 Beiträge
    234 Aufrufe
    FrankMF
    Für den, der sich alle Änderungen ansehen möchten -> https://github.com/nextcloud/server/releases
  • NAS 2023 - Thema Datensicherung

    Verschoben Linux proxmox linux
    2
    2
    0 Stimmen
    2 Beiträge
    202 Aufrufe
    FrankMF
    Bleibt noch etwas wichtiges. Die ganzen Konfigurationsdateien vom Proxmox Host. Sinnvoll, das man sich das sichert. #!/bin/bash # Script um mit Restic Daten automatisiert zu sichern! # Dient zum Sichern des Ordners /etc/pve! # Was soll gesichert werden? backup_pfad=/etc/pve # Programm Start restic --password-file /root/passwd -r /mnt/pve/Restic_Backups/pve backup $backup_pfad > backup_pve_001.log restic --password-file /root/passwd -r /mnt/pve/Restic_Backups/pve forget --keep-last 3 --keep-monthly 3 --prune >> backup_pve_002.log # Testen restic --password-file /root/passwd -r /mnt/pve/Restic_Backups/pve check --read-data >> backup_pve_003.log Crontab eingerichtet - fertig!
  • 10G

    Linux 10g linux
    2
    0 Stimmen
    2 Beiträge
    210 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. [image: 1635752117002-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. https://www.youtube.com/watch?v=59I-RlliRms So sieht so ein DAC Verbindungskabel aus. Die SFP+ Adapter sind direkt daran montiert. [image: 1635752308951-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
  • Proxmox - Backup Server WakeOnLan

    Proxmox proxmox linux wakeonlan
    1
    2
    0 Stimmen
    1 Beiträge
    789 Aufrufe
    Niemand hat geantwortet
  • Node.js Paketmanager npm Sicherheitsproblem!

    Linux security nodejs linux npm
    1
    0 Stimmen
    1 Beiträge
    261 Aufrufe
    Niemand hat geantwortet
  • Redis Replication

    Angeheftet Verschoben Redis linux redis
    4
    1 Stimmen
    4 Beiträge
    592 Aufrufe
    FrankMF
    Um die Verbindung zu testen, kann man folgende Befehle nutzen. redis-cli -h 10.1.1.0 -p 6379 -a <PASSWORD> und telnet 10.1.1.0 6379