sk4hrr
1
Bonjour,
Je ne parviens pas à faire fonctionner les instructions include dans mon fichier /etc/nftables.conf. Auriez-vous une idée de pourquoi ?
Un exemple de ma configuration :
sk4hrr@infra-gw-2138:~$ sudo cat /etc/nftables.conf
#!/usr/sbin/nft -f
# Ansible managed
flush ruleset
table inet filter {
chain input {
type filter hook input priority 0;
# accept any localhost traffic
iif lo accept
# accept traffic originated from us
ct state established,related accept
# accept neighbour discovery otherwise IPv6 connectivity breaks.
ip6 nexthdr icmpv6 icmpv6 type { nd-neighbor-solicit, nd-router-advert, nd-neighbor-advert } accept
# include specifics rules
include "/srv/nftables/rules/"
# count and drop any other traffic
counter drop
}
}
# include more tables
include "/srv/nftables/tables/"
sk4hrr@infra-gw-2138:~$ find /srv/nftables/
/srv/nftables/
/srv/nftables/tables
/srv/nftables/tables/ipv6.conf
/srv/nftables/tables/ipv4.conf
/srv/nftables/rules
/srv/nftables/rules/wireguard-wg0.conf
La documentation faisant référence à include : Scripting - nftables wiki
Zargos
2
Bonjour,
est-ce que le script a les droit pour lire les fichier inclus dans les répertoires absolus que tu as utilisés?
sk4hrr
3
Qu’appelles-tu script ?
Sinon, les droits me semblent bon :
sk4rr@infra-gw-2138:~$ ls -lah /srv/nftables/
total 0
drwxr-xr-x 1 root root 22 Oct 12 11:06 .
drwxr-xr-x 1 root root 16 Sep 28 10:29 ..
drwxr-xr-x 1 root root 36 Oct 12 10:14 rules
drwxr-xr-x 1 root root 36 Oct 13 12:09 tables
sk4rr@infra-gw-2138:~$ ls -lah /srv/nftables/rules/
total 4.0K
drwxr-xr-x 1 root root 36 Oct 12 10:14 .
drwxr-xr-x 1 root root 22 Oct 12 11:06 ..
-rw-r--r-- 1 root root 76 Oct 8 23:58 wireguard-wg0.conf
sk4rr@infra-gw-2138:~$ ls -lah /srv/nftables/tables/
total 8.0K
drwxr-xr-x 1 root root 36 Oct 13 12:09 .
drwxr-xr-x 1 root root 22 Oct 12 11:06 ..
-rw-r--r-- 1 root root 313 Oct 12 11:32 ipv4.conf
-rw-r--r-- 1 root root 949 Oct 12 11:07 ipv6.conf
sk4hrr
4
J’avais visiblement oublié un cas qui semble corriger le problème :
# include specifics rules
include "/srv/nftables/rules/*.conf"
Bizarrement, l’instruction suivante de la documentation ne fonctionne pas :
# include all files in a given directory using an absolute path
include "/etc/nftables/"
Ou alors ça attends un type de fichier bien précis…
Zargos
5
A minima, il te faut un asterisk, un simple répertoire ne suffit pas.