• ufw e samba

    From Piviul@21:1/5 to All on Wed Nov 29 15:10:01 2023
    Ciao a tutti, sto provando a configurare ufw per il traffico samba.
    Questa è la mia situazione:

    # ufw status | grep -i samba
    Samba                      ALLOW       192.168.64.0/20
    # sudo ufw app info Samba
    Profile: Samba
    Title: LanManager-like file and printer server for Unix
    Description: The Samba software suite is a collection of programs that implements the SMB/CIFS protocol for unix systems, allowing you to serve files and printers to Windows, NT, OS/2 and DOS clients. This protocol is sometimes also referred to as the LanManager or NetBIOS protocol.

    Ports:
      137,138/udp
      139,445/tcp
    # grep UFW.*SPT=137 /var/log/syslog | tail -n 5 2023-11-29T14:47:05.935411+01:00 psala-lx kernel: [197355.101935] [UFW
    BLOCK] IN=enp5s0 OUT= MAC=c8:60:00:5a:05:2d:38:ca:84:38:6e:b1:08:00 SRC=192.168.70.78 DST=192.168.64.90 LEN=90 TOS=0x00 PREC=0x00 TTL=64
    ID=30123 DF PROTO=UDP SPT=137 DPT=56517 LEN=70 2023-11-29T14:47:05.935433+01:00 psala-lx kernel: [197355.102151] [UFW
    BLOCK] IN=enp5s0 OUT= MAC=c8:60:00:5a:05:2d:00:13:20:d9:95:66:08:00 SRC=192.168.72.230 DST=192.168.64.90 LEN=90 TOS=0x00 PREC=0x00 TTL=128 ID=1523 PROTO=UDP SPT=137 DPT=56517 LEN=70
    2023-11-29T14:47:06.435385+01:00 psala-lx kernel: [197355.604213] [UFW
    BLOCK] IN=enp5s0 OUT= MAC=c8:60:00:5a:05:2d:8e:37:e8:8a:56:18:08:00 SRC=192.168.64.2 DST=192.168.64.90 LEN=90 TOS=0x00 PREC=0x00 TTL=64
    ID=9779 DF PROTO=UDP SPT=137 DPT=42617 LEN=70 2023-11-29T14:47:06.435400+01:00 psala-lx kernel: [197355.604509] [UFW
    BLOCK] IN=enp5s0 OUT= MAC=c8:60:00:5a:05:2d:8e:37:e8:8a:56:18:08:00 SRC=192.168.64.2 DST=192.168.64.90 LEN=90 TOS=0x00 PREC=0x00 TTL=64
    ID=9780 DF PROTO=UDP SPT=137 DPT=42617 LEN=70 2023-11-29T14:47:06.435401+01:00 psala-lx kernel: [197355.604869] [UFW
    BLOCK] IN=enp5s0 OUT= MAC=c8:60:00:5a:05:2d:ca:8b:e7:d0:ac:ef:08:00 SRC=192.168.64.3 DST=192.168.64.90 LEN=96 TOS=0x00 PREC=0x00 TTL=64
    ID=32884 DF PROTO=UDP SPT=137 DPT=42617 LEN=76
    Evidentemente sbaglio qualcosa ma cosa?

    Piviul

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Johan Haggi@21:1/5 to All on Sat Dec 2 17:10:02 2023
    sab 2 dicembre 2023, alle 16:29 (GMT+0100), io ho scritto:
    [...]
    * la configurazuine che uso (e funziona) l'ho fatta 2 anni fa e non
    ricordo perchè l'ho fatta così (mi sembra di ricordare che Anywhere sia
    dovuto alla ricerca da parte dei TV su udp non su l'IP 192.168.1.8 del
    PC ma su un multicast tipo 224.qualcosa).

    sul PC con samba ho:
    # /usr/sbin/ufw status
    To Action From
    -- ------ ----
    [...]
    192.168.1.8 139/tcp ALLOW IN 192.168.1.0/24 # smbd 192.168.1.8 445/tcp ALLOW IN 192.168.1.0/24 # smbd Anywhere ALLOW IN 192.168.1.0/24 137/udp # nmbd Anywhere ALLOW IN 192.168.1.0/24 138/udp # nmbd [...]

    Quel anywhere mi suonava strano , controllato con
    ufw show listening e sullo script le porte udp (tutte) sono aperte solo a
    137 e 138 dalla rete locale, questi i comandi:

    MY_NET_IP="192.168.1.0/24"
    HERE_IP="192.168.1.8"

    /usr/sbin/ufw allow from "${MY_NET_IP}" to "${HERE_IP}" port 139 proto tcp comment "smbd"
    /usr/sbin/ufw allow from "${MY_NET_IP}" to "${HERE_IP}" port 445 proto tcp comment "smbd"
    /usr/sbin/ufw allow from "${MY_NET_IP}" port 137 proto udp comment "nmbd"
    /usr/sbin/ufw allow from "${MY_NET_IP}" port 138 proto udp comment "nmbd"


    Rileggo inoltre il tou log e vedo che il problema dovrebbe proprio essere quello:
    2023-11-29T14:47:05.935411+01:00 psala-lx kernel: [197355.101935] [UFW
    BLOCK] IN=enp5s0 OUT= MAC=c8:60:00:5a:05:2d:38:ca:84:38:6e:b1:08:00 SRC=192.168.70.78 DST=192.168.64.90 LEN=90 TOS=0x00 PREC=0x00 TTL=64
    ID=30123 DF PROTO=UDP SPT=137 DPT=56517 LEN=70

    rifiuto proto udp da 192.168.70.78 porta 137 (il tuo client samba??)
    a 192.168.64.90 porta 56517 (il tuo server samba??)
    --
    Cura ut valeas
    Johan Haggi
    postridie Kalendas Decembres MMDCCLXXVI ab Urbe condita
    OpenPGP key: https://keys.openpgp.org/search?q=orsogrigio%40disr.it Fingerprint: 60B3 42CB E145 F8E9 8132 6CDD 194E 4326 B645 F109

    -----BEGIN PGP SIGNATURE-----

    iHUEABYKAB0WIQRgs0LL4UX46YEybN0ZTkMmtkXxCQUCZWtUZwAKCRAZTkMmtkXx CaqKAQDfaGTOUkYYLfNozZmRBNc555Oewwc+UV+tx5Xd8ZrLXAEAqt++ZpsivO3Y +e/VBryEIOHND2r8jniZNm+jT3IAfgU=
    =ZGAI
    -----END PGP SIGNATURE-----

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Johan Haggi@21:1/5 to All on Sat Dec 2 16:40:01 2023
    mer 29 novembre 2023, alle 15:00 (GMT+0100), Piviul ha scritto:
    Ciao a tutti, sto provando a configurare ufw per il traffico samba. Questa è la mia situazione:

    # ufw status | grep -i samba
    Samba                      ALLOW       192.168.64.0/20
    # sudo ufw app info Samba
    Profile: Samba
    Title: LanManager-like file and printer server for Unix
    Description: The Samba software suite is a collection of programs that implements the SMB/CIFS protocol for unix systems, allowing you to serve files and printers to Windows, NT, OS/2 and DOS clients. This protocol is sometimes also referred to as the LanManager or NetBIOS protocol.

    Ports:
      137,138/udp
      139,445/tcp
    [...]

    PREMESSE IMPORTANTI
    * di firewall non sono un esperto
    * di samba non so praticamente nulla
    * uso samba solo per condividere back-up di DVD da un PC a kodi su
    smart-tv
    * la configurazuine che uso (e funziona) l'ho fatta 2 anni fa e non
    ricordo perchè l'ho fatta così (mi sembra di ricordare che Anywhere sia
    dovuto alla ricerca da parte dei TV su udp non su l'IP 192.168.1.8 del
    PC ma su un multicast tipo 224.qualcosa).

    sul PC con samba ho:
    # /usr/sbin/ufw status
    To Action From
    -- ------ ----
    [...]
    192.168.1.8 139/tcp ALLOW IN 192.168.1.0/24 # smbd 192.168.1.8 445/tcp ALLOW IN 192.168.1.0/24 # smbd Anywhere ALLOW IN 192.168.1.0/24 137/udp # nmbd Anywhere ALLOW IN 192.168.1.0/24 138/udp # nmbd
    [...]
    --
    Cura ut valeas
    Johan Haggi
    postridie Kalendas Decembres MMDCCLXXVI ab Urbe condita
    OpenPGP key: https://keys.openpgp.org/search?q=orsogrigio%40disr.it Fingerprint: 60B3 42CB E145 F8E9 8132 6CDD 194E 4326 B645 F109

    -----BEGIN PGP SIGNATURE-----

    iHUEABYKAB0WIQRgs0LL4UX46YEybN0ZTkMmtkXxCQUCZWtNWAAKCRAZTkMmtkXx CZRNAP9Wc/Vz3DsOPQgMJXkPAcME6E7hWxMSWCglhJfCkI+ybgEA2xI/51eVlw+W 4PjAURi9kUbQ4SHR9ziV5J696yyo7g4=
    =hKU1
    -----END PGP SIGNATURE-----

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)