Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[X-post] Debian Bookworm: Errore nelle righe di nftables

1 view
Skip to first unread message

^Bart

unread,
Jul 19, 2023, 10:08:43 AM7/19/23
to
Salve,

sto cercando di passare da iptables ad nftables quindi ho provato a
leggermi della documentazione di quest'ultimo ed a scrivere qualcosa ma
ho degli errori di sintassi, di seguito il contenuto del mio file:

#!/bin/bash
#Router script, forward wi-fi to eth for firewall update

#set static ip on eth0
ip a add XXX.XX.XXX.XXX/255.255.255.248 dev enp3s0

#set ipv4 forward
echo 1 > /proc/sys/net/ipv4/ip_forward

#set ip rules by iptables
#iptables -I FORWARD -i enp3s0 -o wlp2s0 -j ACCEPT
#iptables -t nat -I POSTROUTING -o wlp2s0 -j MASQUERADE

#load modules
modprobe nft_nat
modprobe nft_masq

#set ip rules with nftables version 1
nft add table inet gw
#nft flush table inet gw
nft add chain inet gw gw_chain '{ type filter hook input priority 0; }'
#nft flush chain inet gw gw_chain
nft add rule inet gw gw_chain ip filter FORWARD iifname "enp3s0" oifname
"wlp2s0" accept
nft add rule inet gw gw_chain ip nat postrouting oifname "wlp2s0" masquerade

#set ip rules with nftables version 2
#nft add table inet gw
#nft flush table inet gw
#nft add chain inet gw gw_chain '{type filter hook input priority 0; }'
#nft flush chain inet gw gw_chain
#nft insert rule inet gw gw_chain ip filter FORWARD iifname "enp0s25"
oifname "wlp2s0" counter accept
#nft insert rule inet gw gw_chain ip nat POSTROUTING oifname "wlp2s0"
counter masquerade

Come già accennato essendo "nuovo" di nftables di sicuro avrò fatto un
errore concettuale ma ora devo capire quale... :\

Saluti.
^Bart

evanmac

unread,
Jul 21, 2023, 11:19:50 AM7/21/23
to
il giorno 19 Jul 2023 alle 15:08:42 GMT+1, "^Bart"
<gabriel...@hotmail.com> scrisse:

> ho degli errori di sintassi

riportare esattamente gli errori che ti saltano fuori aiuterebbe il debug...

--
this is a random signature

Giuseppe Della Bianca

unread,
Jul 22, 2023, 11:15:57 AM7/22/23
to
https://wiki.nftables.org/wiki-nftables/index.php/
Moving_from_iptables_to_nftables

Il Wed, 19 Jul 2023 16:08:42 +0200, ^Bart ha scritto:

> Salve,
>
> sto cercando di passare da iptables ad nftables quindi ho provato a
> leggermi della documentazione di quest'ultimo ed a scrivere qualcosa ma
> ho degli errori di sintassi, di seguito il contenuto del mio file:
]zac[

^Bart

unread,
Jul 23, 2023, 5:18:08 PM7/23/23
to
> riportare esattamente gli errori che ti saltano fuori aiuterebbe il debug...

Ci ho lavorato un po' con calma ed ho risolto nel seguente modo:

lush ruleset

table inet filter {
chain input {
type filter hook input priority 0; policy accept;
}
chain forward {
type filter hook forward priority 0; policy accept;
iifname "wlan0" oifname "eth0" accept
}
chain output {
type filter hook output priority 0; policy accept;
}
}

table nat {
chain prerouting {
type nat hook prerouting priority 0; policy accept;
}
chain postrouting {
type nat hook postrouting priority 100;
oifname "wlan0" masquerade
}
}

Saluti.
^Bart
0 new messages