firewall

  • Hallo zusammen,


    ich nutze zuhause Sonos-Lautsprecher, welche allerdings nur das SMBv1 verwenden. Aus Sicherheitsgründen gibt es bei mir im Netz nur noch min SMBv2 (in der Regel aber SMBv3). Da unsere Kinder allerdings gerne Hörbücher und Hörspiele hören, diese auf meiner Haupt-NAS (mit SMBv3) liegen, können diese Sonos-Geräte aus Sicherheitsgründen nicht darauf zugreifen.


    Deshalb habe ich auf einen Pi2 OMV 4.1.28 installiert.
    Samba wurde schon mit Allow-Hosts und Deny-Hosts so konfiguriert, dass nur die Sonosboxen mit einem User lesend auf den USB-Stick zugreifen können. Ein separater User hat R/W um die Audiodateien mittels PC auf den USB-Stick zu kopieren. SSH ist in der Regel deaktiviert (nur bei Bedarf wird dies temporär aktiviert).


    Ich möchte nun mit der Firewall (iptables) diesen Pi so absichern, dass nur die Sonosboxen und der eine Windowsclient auf diesen Pi zugreifen können (Einschränkung anhand der IP sowohl über die INPUT-Chain, ais auch über die OUTPUT-Chain).
    Der Moderator @tekkb hat schon interessante Beiträge bzgl. Firewall eingestellt.
    Leider beziehen diese sich immer nur auf die INPUT-Chain und nicht auf die OUTPUT-Chain.


    Da ich mit Thema iptables nur rudimentär vertraut bin, wäre ich dankbar, wenn mit jemand darstellen könnte, welche Regeln ich wie anlegen muss, damit der Pi sowohl eingehend, als auch ausgehend nur mit diesen 3 Clients kommunizieren kann, wobei die Update-Funktion über das Internet (http, ftp) auch gewährleistet sein sollte.


    Vielen Dank für eure Hilfe.


    Gruss
    Frank

  • My Post again in English (Google Translater):


    Hello everybody,


    I use Sonos speakers at home, which only use the SMBv1. For security reasons, there are only min SMBv2 in my network (but usually SMBv3). However, since our children like to listen to audio books and radio plays that are on my main NAS (with SMBv3), these Sonos devices cannot access them for security reasons.


    That's why I installed on a Pi2 OMV 4.1.28.Samba has already been configured with Allow hosts and Deny hosts so that only the Sonos boxes can read the USB stick with one user. A separate user has R / W to copy the audio files via PC to the USB stick. SSH is usually deactivated (this is only activated temporarily if necessary).


    I would now like to secure this Pi with the firewall (iptables) in such a way that only the Sonos boxes and the one Windows client can access this Pi (restriction based on the IP both via the INPUT chain and also via the OUTPUT chain).
    The moderator @tekkb has already posted interesting articles regarding firewalls.
    Unfortunately, these only ever relate to the INPUT chain and not to the OUTPUT chain.


    Since I am only rudimentarily familiar with the topic iptables, I would be grateful if someone could explain which rules I have to create and how, so that the Pi can only communicate with these 3 clients both inbound and outbound, with the update function via the internet (http, ftp) should also be guaranteed.


    My rules inthe OUPTUT-Chain:Chain INPUT (policy ACCEPT 0 packets, 0 bytes)
    pkts bytes target prot opt in out source destination
    149K 18M ACCEPT all -- any any anywhere anywhere ctstate RELATED,ESTABLISHED
    5246 315K ACCEPT all -- lo any anywhere anywhere
    72 3744 ACCEPT all -- any any "Gerät1" pi
    2 120 ACCEPT all -- any any "Gerät2" pi
    2 120 ACCEPT all -- any any "Gerät2" pi
    .
    .
    .
    137K 48M REJECT all -- any any anywhere anywhere reject-with icmp-port-unreachable


    - Everything that was initiated by the pi is allowed back in
    - Loopback
    -The individual devices
    - Everything else is blockedSo (similar)


    I imagine it synonymous for "OUTPUT" before.


    Many thanks for your help.


    GreetingFrank

  • I think it should work (roughly) as you demonstrate, only the update function is missing.


    [If you use DHCP, don't forget this]


    The problem is, you don't know what IP addresses are needed for this, and even if you would, they would change over time.


    So I would refine it like this:


    - ACCEPT ESTABLISHED,RELATED
    - ACCEPT Loopback
    - ACCEPT individual local devices
    - REJECT local network, e.g. 10.20.0.0/16
    - ACCEPT all internet (only in the OUTPUT chain!)
    - REJECT all


    That means, the rpi can initiate any outgoing connections, and the replies are taken care of with ESTABLISHED,RELATED. For ftp this probably requires conntrack.


    To refine further, identify ports:


    - ACCEPT ESTABLISHED,RELATED
    - ACCEPT Loopback
    - ACCEPT individual local devices (but only for samba (and sonos?) ports: I think 445, 137-139, maybe others, see /etc/services)
    - REJECT local network, e.g. 10.20.0.0/16
    - ACCEPT all internet (only in the OUTPUT chain!) (but only for update related ports, I guess 80, 443, 21)
    - REJECT all


    That also means essentially that rpi can "surf the web". To prevent this (I think this may be a little pedantic), route/redirect everything via a proxy, and let the proxy block anything that isn't debian update related (sounds complex).


    Maybe don't forget ipv6, if the rpi does that.

Jetzt mitmachen!

Sie haben noch kein Benutzerkonto auf unserer Seite? Registrieren Sie sich kostenlos und nehmen Sie an unserer Community teil!