Skip to contentSkip to conversation

Proper way to ipsec filtering

DISCUSSION Kamil Jońca 2 participants 3 messages Apr 17, 2022 – Apr 18, 2022

lore
Share & tools
lore
#0 lore raw

What is the best way to create rules used to ipsec traffic filtering?

So far I have bunch rules created per reqid like that:
table ip filter { # handle 13

chain INPUT { # handle 1

                type filter hook input priority filter; policy drop;
                iif "eth0" ipsec in reqid 1 counter packets 100672 bytes 11492891 jump ipsec-in-1 comment "ed19af3c-f504-11e9-b59d-00e081736ba6/1/in" # handle 326
                [...]

}

[...]
chain ipsec-in-1 { # handle 323
ip saddr yyy ip daddr xxxx/24 counter packets 50871 bytes 5614784 jump c1 # handle 325 ip protocol ipencap ip daddr zzzz counter packets 49801 bytes 5878107 accept # handle 324
}

}

And insert / remove rules from INPUT (and add / delete ipsec-in-* chains) during connecting disconnecting clients.
This was I configured when I migrated from iptables some time ago. But I believe this is not the best method for nftables. So has anybody suggestion what is the best practicte to handle this situation? I tried to use maps/vmaps but reqid cannot be use as index.

Am I missing something?
KJ

Signature · 1 line
http://stopstopnop.pl/stop_stopnop.pl_o_nas.html
#1 lore raw
Quoted 9 lines · Kamil Jońca

What is the best way to create rules used to ipsec traffic filtering?

So far I have bunch rules created per reqid like that:
table ip filter { # handle 13

chain INPUT { # handle 1

                type filter hook input priority filter; policy drop;
                iif "eth0" ipsec in reqid 1 counter packets 100672 bytes 11492891 jump ipsec-in-1 comment "ed19af3c-f504-11e9-b59d-00e081736ba6/1/in" # handle 326
                [...]

[..]

Quoted 3 lines

But I believe this is not the best method for nftables. So has anybody suggestion what is the best practicte to handle this situation? I tried to use maps/vmaps but reqid cannot be use as index.

Thats a bug / missing feature, it should be possible to use reqid in concatenated keys too. I've sent a patch for this:

https://patchwork.ozlabs.org/project/netfilter-devel/patch/[email protected]/

#2 lore raw

Florian Westphal <[email protected]> writes:

[...]

Quoted 5 lines

Thats a bug / missing feature, it should be possible to use reqid in concatenated keys too. I've sent a patch for this:

https://patchwork.ozlabs.org/project/netfilter-devel/patch/[email protected]/

Well, I cloned repo, and compiled against my debian test sid box. Seems to work as expected.

Thank you.
So now I have to wait when debian adopt it. :)
Thanks again.

KJ

Signature · 1 line
http://wolnelektury.pl/wesprzyj/teraz/