# Nftables: include ne fonctionne pas

**URL:** <https://www.debian-fr.org/t/nftables-include-ne-fonctionne-pas/85499>\
**Category:** Support Debian\
**Created:** [Octobre 13, 2021, 9:14 UTC](https://www.debian-fr.org/t/nftables-include-ne-fonctionne-pas/85499 "2021-10-13T09:14:54Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![sk4hrr](https://www.debian-fr.org/letter_avatar_proxy/v4/letter/s/7bcc69/32.png) [@sk4hrr](https://www.debian-fr.org/u/sk4hrr)\
**Post date:** [Octobre 13, 2021, 9:14 UTC](https://www.debian-fr.org/t/nftables-include-ne-fonctionne-pas/85499/1 "2021-10-13T09:14:55Z")

</div>

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 :

```bash
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](https://wiki.nftables.org/wiki-nftables/index.php/Scripting#Including_files)

---

<div class="post-metadata">

**Author:** ![Zargos](https://www.debian-fr.org/user_avatar/www.debian-fr.org/zargos/32/10889_2.png) [@Zargos](https://www.debian-fr.org/u/Zargos)\
**Post date:** [Octobre 14, 2021, 1:12 UTC](https://www.debian-fr.org/t/nftables-include-ne-fonctionne-pas/85499/2 "2021-10-14T13:12:28Z")

</div>

Bonjour,  
est-ce que le script a les droit pour lire les fichier inclus dans les répertoires absolus que tu as utilisés?

---

<div class="post-metadata">

**Author:** ![sk4hrr](https://www.debian-fr.org/letter_avatar_proxy/v4/letter/s/7bcc69/32.png) [@sk4hrr](https://www.debian-fr.org/u/sk4hrr)\
**Post date:** [Octobre 15, 2021, 2:58 UTC](https://www.debian-fr.org/t/nftables-include-ne-fonctionne-pas/85499/3 "2021-10-15T14:58:46Z")

</div>

Qu’appelles-tu script ?  
Sinon, les droits me semblent bon :

```bash
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

```

---

<div class="post-metadata">

**Author:** ![sk4hrr](https://www.debian-fr.org/letter_avatar_proxy/v4/letter/s/7bcc69/32.png) [@sk4hrr](https://www.debian-fr.org/u/sk4hrr)\
**Post date:** [Octobre 15, 2021, 3:53 UTC](https://www.debian-fr.org/t/nftables-include-ne-fonctionne-pas/85499/4 "2021-10-15T15:53:55Z")

</div>

J’avais visiblement oublié un cas qui semble corriger le problème :

```auto
    # include specifics rules
    include "/srv/nftables/rules/*.conf"

```

Bizarrement, l’instruction suivante de la documentation ne fonctionne pas :

```auto
# 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…

---

<div class="post-metadata">

**Author:** ![Zargos](https://www.debian-fr.org/user_avatar/www.debian-fr.org/zargos/32/10889_2.png) [@Zargos](https://www.debian-fr.org/u/Zargos)\
**Post date:** [Octobre 15, 2021, 4:26 UTC](https://www.debian-fr.org/t/nftables-include-ne-fonctionne-pas/85499/5 "2021-10-15T16:26:16Z")

</div>

> [@sk4hrr](#):
>
> ```auto
> # include all files in a given directory using an absolute path
> include "/etc/nftables/"
> 
> ```

A minima, il te faut un asterisk, un simple répertoire ne suffit pas.
