Zum Inhalt springen

ferm

Aus wiki.archlinux.de

ferm - ausgesprochen „firm“, steht für „For Easy Rule Making“. Es dient dazu Firewall-Regeln basierend auf iptables konfigurieren und beim Systemstart laden.

Installation

Das Programm ist als ferm in extra verfügbar, und kann von dort mittels Pacman installiert werden.

pacman -S ferm

Nach der installation muss der Service noch aktiviert werden

systemctl enable ferm.service        # Service nur aktivieren …
systemctl enable --now ferm.service  # … oder Service aktivieren und direkt starten

Konfiguration

Die Konfigurationsdatei /etc/ferm.conf enthält bereits Firewall-Regeln für ein Desktop-System. Weitere Beispiele sind in /usr/share/doc/ferm/examples/ zu finden.

Bei bereits geladenen Firewall-Regeln kann man diese in die ferm-Konfiguration übernehmen

import-ferm > /etc/ferm.conf

Befehl

Dies lädt die Firewall-Regeln in das netfilter framework des Kernels.

ferm /etc/ferm.conf

Man kann dies wie folgt überprüfen.

iptables -L -v
ip6tables -L -v

Beispielkonfiguration

table filter {
    chain INPUT {
        policy DROP;

        # connection tracking
        mod state state INVALID DROP;
        mod state state (ESTABLISHED RELATED) ACCEPT;

        # allow local connections
        interface lo ACCEPT;

        # respond to ping
        proto icmp icmp-type echo-request ACCEPT;

        # ident connections are also allowed
        proto tcp dport auth ACCEPT;

        # the rest is dropped by the above policy
    }

    # outgoing connections are not limited
    chain OUTPUT policy ACCEPT;

    # this is not a router
    chain FORWARD policy DROP;
}

domain ip6 table filter {
    chain INPUT {
        policy DROP;

        # connection tracking
        mod state state INVALID DROP;
        mod state state (ESTABLISHED RELATED) ACCEPT;

        # allow local connections
        interface lo ACCEPT;

        # allow ICMP (for neighbor solicitation, like ARP for IPv4)
        proto ipv6-icmp ACCEPT;

        # ident connections are also allowed
        proto tcp dport auth ACCEPT;

        # the rest is dropped by the above policy
    }

    # outgoing connections are not limited
    chain OUTPUT policy ACCEPT;

    # this is not a router
    chain FORWARD policy DROP;
}