Skip to contentSkip to conversation

nftables: How to add bordering ip-ranges to a named set

DISCUSSION Matthias Taube 2 participants 3 messages Jul 6, 2016 – Jul 8, 2016

lore
Share & tools
lore
#0 lore raw

Hi,

if I define a named set in nftables

Quoted 2 lines

nft 'add set inet filter black2 {type ipv4_addr; flags interval; }' nft add element inet filter black2 { 192.168.1.1/24 }

it is not possible to add bordering ip-ranges:

Quoted 4 lines

nft add element inet filter black2 { 192.168.2.1/24 } <cmdline>:1:1-49: Error: Could not process rule: File exists add element inet filter black2 { 192.168.2.1/24 } ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

but if I add the ranges in ONE command it works:

Quoted 1 line

nft add element inet filter black2 { 192.168.1.1/24, 192.168.2.1/24 }

then the ranges are put together to one ip-range:

Quoted 8 lines
# nft list set inet filter black2
table inet filter {
	set black2 {
		type ipv4_addr
		flags interval
		elements = { 192.168.1.0-192.168.2.255}
	}
}

How it is possible to create a set to flexible add and delete bordering ip-ranges?

mfg
Matthias

#1 lore raw
Quoted 25 lines · Matthias Taube

Hi,

if I define a named set in nftables

Quoted 2 lines

nft 'add set inet filter black2 {type ipv4_addr; flags interval; }' nft add element inet filter black2 { 192.168.1.1/24 }

it is not possible to add bordering ip-ranges:

Quoted 4 lines

nft add element inet filter black2 { 192.168.2.1/24 } <cmdline>:1:1-49: Error: Could not process rule: File exists add element inet filter black2 { 192.168.2.1/24 } ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

but if I add the ranges in ONE command it works:

Quoted 1 line

nft add element inet filter black2 { 192.168.1.1/24, 192.168.2.1/24 }

then the ranges are put together to one ip-range:

Quoted 8 lines
# nft list set inet filter black2
table inet filter {
	set black2 {
		type ipv4_addr
		flags interval
		elements = { 192.168.1.0-192.168.2.255}
	}
}
Quoted 2 lines

How it is possible to create a set to flexible add and delete bordering ip-ranges?

This is fixed in the upcoming 4.7, you can give a try to 4.7-rc6. You also have to install nft 0.6.

#2 lore raw

Am 07.07.2016 um 20:33 schrieb Pablo Neira Ayuso:

Quoted 2 lines

This is fixed in the upcoming 4.7, you can give a try to 4.7-rc6. You also have to install nft 0.6.

Thanks for the info. I will wait until this version is in debian sid.