Hirdetés

Új hozzászólás Aktív témák

  • Siriusb
    veterán

    Vannak előre definiált számokhoz tartozó stringek. Ilyen pl a filter is, aminek az értéke 0. Én jobban szeretek számot használni. Anúgy a gyári alapbeállítás nekem az volt, hogy minden, minden irányba engedett, vagyis befelé is jöhetett minden. Az általam először leírt merőben más.
    Egy folyamatosan kint levő komolyabb szerveren érdemes még ezeket is használni:

    table netdev drop-bad-packets {
    chain ingress {
    type filter hook ingress device ens19 (ez nyilván másnak más) priority -500;

    # ip fragments
    ip frag-off & 0x1fff != 0 counter drop

    # drop tcp "xmas" packets (bad flag combo)
    tcp flags & (fin | psh | urg) == fin | psh | urg counter drop

    # drop tcp packets with no flags
    tcp flags & (fin|syn|rst|psh|ack|urg) == 0x0 counter drop

    # drop tcp packets with mss below minimum
    tcp flags syn tcp option maxseg size 1-535 counter drop
    }
    }

    table inet drop-bad-ct-states {
    chain prerouting {
    type filter hook prerouting priority -150;

    # drop packets in "invalid" connection-tracking state
    ct state invalid counter drop

    # drop tcp packets for new connections that aren't syn packets
    ct state new tcp flags & (fin|syn|rst|ack) != syn counter drop

    # drop new connections over rate limit (ez nagyon függ attól, hogy mit csinálsz a gépeden). Minél több mindent, és hektikus a terheltség, annál inkább használhatatlan ez.
    ct state new limit rate over 20/second burst 41 packets counter drop
    }
    }

    Ezenfelül még lehet tiltani a BOGONS ip-ket, mert értelmes adat onnan nem jöhet, de az már egy home szerveren jócskán túlmutat. Igazság szerint ha nem valami fontos, cég szintű dolgokat tárolsz, akkor a felső sorokra se nagyon van szükséged, max a drop-bad-ct-states táblára.

    Köszönöm!

    Arch-on így néz ki az alapbeállítás:
    ❯ cat /etc/nftables.conf
    #!/usr/bin/nft -f
    # vim:set ts=2 sw=2 et:

    # IPv4/IPv6 Simple & Safe firewall ruleset.
    # More examples in /usr/share/nftables/ and /usr/share/doc/nftables/examples/.

    table inet filter
    delete table inet filter
    table inet filter {
     chain input {
       type filter hook input priority filter
       policy drop

       ct state invalid drop comment "early drop of invalid connections"
       ct state {established, related} accept comment "allow tracked connections"
       iifname lo accept comment "allow from loopback"
       ip protocol icmp accept comment "allow icmp"
       meta l4proto ipv6-icmp accept comment "allow icmp v6"
       tcp dport ssh accept comment "allow sshd"
       pkttype host limit rate 5/second counter reject with icmpx type admin-prohibited
       counter
     }
     chain forward {
       type filter hook forward priority filter
       policy drop
     }
    }

Új hozzászólás Aktív témák