Horzagger

Simple nftables.conf

Nov 7th, 2025
249
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 4.89 KB | Cybersecurity | 0 0
  1. #!/usr/sbin/nft -f
  2.  
  3. # English :
  4. # This is a simple nftables configuration script for the nftables.conf file (/etc/nftables.conf).
  5. # In this version, IPv6 is blocked. You can modify the script to accept incoming connections from your local network or from an IP address on the Internet — for example, to manage your machine via SSH.
  6. # Read the script carefully before using it to avoid locking yourself out.
  7. # This script is provided free of charge, without any warranty. You should not use it if you do not understand what you are doing or if you are unable to troubleshoot your own Debian-like Linux system or any other Linux system using nftables.
  8. # Before doing anything else, you should make sure to back up your important data to avoid losing it, especially if you are not sufficiently experienced.
  9. # In any case, you are solely responsible for the use of this script, and by using it, you accept all potential consequences.
  10.  
  11. # Français :
  12. # Ceci est un simple script de configuration nftables pour le fichier nftables.conf (/etc/nftables.conf).
  13. # Dans cette version, ipv6 est bloquée. Vous pouvez modifier le script pour accepter les connections entrantes, depuis votre réseau local ou une adresse IP dans les Internets, par exemple pour gérer votre machine avec ssh.
  14. # Lisez bien le script avant de l'utiliser pour ne pas vous retrouver bloqué.
  15. # Ce script est livré gratuitement sans aucune garantie et vous ne devez pas l'utiliser si vous ne comprenez pas ce que vous faites ou que vous n'êtes pas capable de dépanner vous-même votre système d'exploitation Linux Debian-like ou autre Linux utilisant nftables. Vous devriez par ailleurs avant toute chose avoir prévu de faire des sauvegardes de vos données importantes pour éviter de les perdre, notamment si vous n'êtes pas suffisamment expérimenté.
  16. # Dans tous les cas, vous êtes seul responsable de l'usage de ce script et si vous l'utilisez, vous en assumez toutes les éventuelles conséquences.
  17.  
  18. # Italian
  19. # Questo è un semplice script di configurazione di nftables per il file nftables.conf (/etc/nftables.conf).
  20. # In questa versione, IPv6 è bloccato. Puoi modificare lo script per accettare connessioni in ingresso dalla tua rete locale o da un indirizzo IP su Internet — ad esempio per gestire la tua macchina tramite SSH.
  21. # Leggi attentamente lo script prima di usarlo per evitare di bloccarti l’accesso.
  22. # Questo script è fornito gratuitamente, senza alcuna garanzia. Non dovresti usarlo se non capisci cosa stai facendo o se non sei in grado di risolvere eventuali problemi del tuo sistema Linux basato su Debian o di qualsiasi altro Linux che utilizza nftables.
  23. # Prima di tutto, dovresti assicurarti di avere un backup dei tuoi dati importanti per evitare di perderli, soprattutto se non hai molta esperienza.
  24. # In ogni caso, sei l’unico responsabile dell’uso di questo script e, usandolo, accetti tutte le eventuali conseguenze.
  25.  
  26. # Мне надоела информатика, она меня больше не интересует. Отстаньте от меня с этой чепухой.
  27. # Мені набридла інформатика, вона мене більше не цікавить. Відчепіться від мене з цими дурницями.
  28. # Ich habe genug von der Informatik, sie interessiert mich nicht mehr. Lasst mich mit diesem Blödsinn in Ruhe.
  29. # Mam dosć informatiki, nje zajimuje mje wjace. Dajće mi z tymi głuposćemi pokoj.
  30. # Mam dosć informatiki, nje zajmujo mě wěcej. Dajśo mě z toś tymi głuposćami spokoj.
  31. #********************
  32.  
  33. flush ruleset
  34.  
  35. table inet filter {
  36.  
  37.                chain input {
  38.                type filter hook input priority 0; policy drop;
  39.                tcp dport 27163 ip saddr 192.168.1.000 drop
  40.                udp dport 27163 ip saddr 192.168.1.000 drop
  41.                iif "lo" accept
  42.                ct state established,related accept
  43.                icmp type echo-request accept
  44.                icmp type time-exceeded drop
  45.    }
  46.  
  47. chain forward {
  48.                type filter hook forward priority 0; policy drop;
  49.        }
  50.  
  51.        chain output {
  52.                type filter hook output priority 0; policy accept;
  53.        }
  54. }
  55.  
  56. table ip6 filter {
  57.        chain input {
  58.                type filter hook input priority 0; policy drop;
  59.                iif "lo" accept
  60.                ct state established,related drop
  61.                icmpv6 type echo-request accept
  62.                icmpv6 type packet-too-big drop
  63.                icmpv6 type time-exceeded drop
  64.                icmpv6 type nd-neighbor-solicit drop
  65.                icmpv6 type nd-neighbor-advert drop
  66.                icmpv6 type nd-redirect drop
  67.                icmpv6 type nd-router-solicit drop
  68.        }
  69.  
  70.        chain forward {
  71.                type filter hook forward priority 0; policy drop;
  72.        }
  73.  
  74.       chain output {
  75.                type filter hook output priority 0; policy accept;
  76.        }
  77. }
  78.  
  79.  
Advertisement
Add Comment
Please, Sign In to add comment