Error: conflicting intervals specified - Bullseye 0.9.8
Hi,
I get the following error with the above nft version, lan being the interface name:
add element ip6 nat fwdtoip_tcp.lan { 1-65534 : 2001:db8:27b:10:ff9b::, 1-65534 : 2001:db8:27b:ff9b::c0a8:ad1}
with
add map ipv6_addr nat fwdtoip_tcp.lan { type inet_service : ipv6_addr\; flags interval\; }
What's wrong here ? My goal being to redirect all (or range ports) external traffic to another server.
Thanks for any hint
Signature · 1 line
Daniel
Quoted 8 lines · Daniel
Hi,
I get the following error with the above nft version, lan being the interface name:
add element ip6 nat fwdtoip_tcp.lan { 1-65534 : 2001:db8:27b:10:ff9b::, 1-65534 : 2001:db8:27b:ff9b::c0a8:ad1}
Quoted 7 lines
with
add map
ipv6_addrnat fwdtoip_tcp.lan { typeinet_service: ipv6_addr\; flags interval\; }What's wrong here ? My goal being to redirect all (or range ports) external traffic to another server.
Could you develop what your use-case is?
Keys uniquely identify an entry in a map, if you define two entries with the same key, you hit this conflict interval error.
Hello
Le 16/09/2021 à 11:29, Pablo Neira Ayuso a écrit :
Quoted 9 lines · Daniel
Quoted 8 lines
Hi,
I get the following error with the above nft version, lan being the interface name:
add element ip6 nat fwdtoip_tcp.lan { 1-65534 : 2001:db8:27b:10:ff9b::, 1-65534 : 2001:db8:27b:ff9b::c0a8:ad1}
Quoted 8 lines
Quoted 7 lines
with
add map
ipv6_addrnat fwdtoip_tcp.lan { typeinet_service: ipv6_addr\; flags interval\; }What's wrong here ? My goal being to redirect all (or range ports) external traffic to another server.
Could you develop what your use-case is?
The above example says -in my mind ;)- that everything coming from outside on ip
2001:db8:27b:10:ff9b:: should be redirect (symmetrical) to ip 2001:db8:27b:ff9b::c0a8:ad1
Quoted 3 lines
Keys uniquely identify an entry in a map, if you define two entries with the same key, you hit this conflict interval error.
I see this like forward port:ip to port:anotherip
Signature · 1 line
Daniel
Quoted 24 lines · Daniel
Hello
Le 16/09/2021 à 11:29, Pablo Neira Ayuso a écrit :
Quoted 9 lines · Daniel
Quoted 8 lines
Hi,
I get the following error with the above nft version, lan being the interface name:
add element ip6 nat fwdtoip_tcp.lan { 1-65534 : 2001:db8:27b:10:ff9b::, 1-65534 : 2001:db8:27b:ff9b::c0a8:ad1}
Quoted 8 lines
Quoted 7 lines
with
add map
ipv6_addrnat fwdtoip_tcp.lan { typeinet_service: ipv6_addr\; flags interval\; }What's wrong here ? My goal being to redirect all (or range ports) external traffic to another server.
Could you develop what your use-case is?
The above example says -in my mind ;)- that everything coming from outside on ip
Quoted 6 lines
2001:db8:27b:10:ff9b:: should be redirect (symmetrical) to ip 2001:db8:27b:ff9b::c0a8:ad1
Quoted 2 lines
Keys uniquely identify an entry in a map, if you define two entries with the same key, you hit this conflict interval error.
I see this like forward port:ip to port:anotherip
so you want to redirect all ports except a few of them?
add map x mymap { type ipv4_addr : ipv4_addr ; }
add rule x y ip protocol { tcp, udp } th dport 1-65534 dnat to ip saddr map @mymap
This allows you to dnat depending on the IP source address, skipping 0 and 65535 for TCP and UDP.
I'm not sure yet if this is what you need though
Le 16/09/2021 à 14:58, Pablo Neira Ayuso a écrit :
[...]
Quoted 5 lines
Keys uniquely identify an entry in a map, if you define two entries
Quoted 2 lines
Quoted 1 line
with the same key, you hit this conflict interval error.
I see this like forward port:ip to port:anotherip
so you want to redirect all ports except a few of them?
Quoted 7 lines
add map x mymap { type
ipv4_addr:ipv4_addr; }
add rule x y ip protocol { tcp, udp } th dport 1-65534 dnat to ip saddr map @mymapThis allows you to dnat depending on the IP source address, skipping 0 and 65535 for TCP and UDP.
I'm not sure yet if this is what you need though
That's my goal, thanks !
Signature · 1 line
Daniel
Le 16/09/2021 à 14:58, Pablo Neira Ayuso a écrit :
Quoted 8 lines
[...]
so you want to redirect all ports except a few of them?add map x mymap { type
ipv4_addr:ipv4_addr; }
add rule x y ip protocol { tcp, udp } th dport 1-65534 dnat to ip saddr map @mymapThis allows you to dnat depending on the IP source address, skipping 0 and 65535 for TCP and UDP.
I don't get I so lets be more explicite with an example.
I want to redirect udp port 10000-20000 to another IP (typically asterisk RTP ports from host to a VM) What I have today which work with single ports (bash script, yes I know ;))
$fwtables add map $1 nat fwdtoip_tcp.$IFACE { type inet_service : $mytype\; flags interval\; } $fwtables add map $1 nat fwdtoip_udp.$IFACE { type inet_service : $mytype\; flags interval\; } $fwtables add map $1 nat fwdtoport_tcp.$IFACE { type inet_service : inet_service\; flags interval\;} $fwtables add map $1 nat fwdtoport_udp.$IFACE { type inet_service : inet_service\; flags interval\;} $fwtables add map $1 nat redirect_tcp.$IFACE { type inet_service : inet_service\; flags interval\;} $fwtables add map $1 nat redirect_udp.$IFACE { type inet_service : inet_service\; flags interval\;}
where $1 is ip or ip6, $mytype is ipv4_addr or ipv6_addr
Then from a list of ports I extract each value -including ranges like above exemple- and do
If src address != to dst address
$fwtables add element $1 nat fwdtoip_$myproto.$IFACE { $tmpsport : $mydaddr }
$fwtables add element $1 nat fwdtoport_$myproto.$IFACE { $tmpsport : $tmpdport } ; this is not accepted when a range is given like 10000-20000
If src address = dst address
$fwtables add element $1 nat redirect_$myproto.$IFACE { $tmpsport : $tmpdport }
where $1 is ip or ip6, $myproto is udp or tcp, $tmpsport port or range of port to redirect, $myaddr is destination ip. $tmpdport can be equal or a different value from $tmpsport
Finally rules
$fwtables add rule ip nat prerouting ip daddr == $myaddripv4 dnat tcp dport map @fwdtoip_tcp.$IFACE : tcp dport map @fwdtoport_tcp.$IFACE $fwtables add rule ip nat prerouting ip daddr == $myaddripv4 dnat udp dport map @fwdtoip_udp.$IFACE : udp dport map @fwdtoport_udp.$IFACE $fwtables add rule ip nat prerouting ip daddr == $myaddripv4 meta l4proto tcp dnat to : tcp dport map @redirect_tcp.$IFACE $fwtables add rule ip nat prerouting ip daddr == $myaddripv4 meta l4proto udp dnat to : udp dport map @redirect_udp.$IFACE
This works perfectly with single ports but as soon as I want to redirect a range of ports it fail.
Where is my mistake ? Is it to complicate to achieve something which should be easy ?
Thanks for your support and ideas
Signature · 1 line
Daniel
Quoted 59 lines · Daniel
Le 16/09/2021 à 14:58, Pablo Neira Ayuso a écrit :
Quoted 8 lines
[...]
so you want to redirect all ports except a few of them?add map x mymap { type
ipv4_addr:ipv4_addr; }
add rule x y ip protocol { tcp, udp } th dport 1-65534 dnat to ip saddr map @mymapThis allows you to dnat depending on the IP source address, skipping 0 and 65535 for TCP and UDP.
I don't get I so lets be more explicite with an example.
I want to redirect udp port 10000-20000 to another IP (typically asterisk RTP ports from host to a VM) What I have today which work with single ports (bash script, yes I know ;))
nft add map $1 nat fwdtoip_tcp.$IFACE { type
inet_service:
$mytype\; flags interval\; }
nft add map $1 nat fwdtoip_udp.$IFACE { typeinet_service:
$mytype\; flags interval\; }
nft add map $1 nat fwdtoport_tcp.$IFACE { typeinet_service:
inet_service\; flags interval\;}
nft add map $1 nat fwdtoport_udp.$IFACE { typeinet_service:
inet_service\; flags interval\;}
nft add map $1 nat redirect_tcp.$IFACE { typeinet_service:
inet_service\; flags interval\;}
nft add map $1 nat redirect_udp.$IFACE { typeinet_service:
inet_service\; flags interval\;}where $1 is ip or ip6, $mytype is
ipv4_addroripv6_addrThen from a list of ports I extract each value -including ranges like above exemple- and do
If src address != to dst address
nft add element $1 nat fwdtoip_$myproto.$IFACE { $tmpsport : $mydaddr }
nft add element $1 nat fwdtoport_$myproto.$IFACE { $tmpsport :
$tmpdport } ; this is not accepted when a range is given like 10000-20000If src address = dst address
nft add element $1 nat redirect_$myproto.$IFACE { $tmpsport :
$tmpdport }where $1 is ip or ip6, $myproto is udp or tcp, $tmpsport port or range of port to redirect, $myaddr is destination ip. $tmpdport can be equal or a different value from $tmpsport
Finally rules
nft add rule ip nat prerouting ip daddr == $myaddripv4 dnat tcp dport map @fwdtoip_tcp.$IFACE : tcp dport map @fwdtoport_tcp.$IFACE nft add rule ip nat prerouting ip daddr == $myaddripv4 dnat udp dport map @fwdtoip_udp.$IFACE : udp dport map @fwdtoport_udp.$IFACE nft add rule ip nat prerouting ip daddr == $myaddripv4 meta l4proto tcp dnat to : tcp dport map @redirect_tcp.$IFACE
nft add rule ip nat prerouting ip daddr == $myaddripv4 meta l4proto udp dnat to : udp dport map @redirect_udp.$IFACE
Quoted 5 lines
This works perfectly with single ports but as soon as I want to redirect a range of ports it fail.
Where is my mistake ? Is it to complicate to achieve something which should be easy ?
You require nftables 1.0.0 for the snippet below:
table ip nat {
map fwdtoip_th {
type ipv4_addr . inet_service : interval ipv4_addr . inet_service
flags interval
elements = { 1.2.3.4 . 10000-20000 : 192.168.3.4 . 30000-40000 }
}
chain prerouting {
type nat hook prerouting priority dstnat; policy accept;
meta l4proto { tcp, udp } dnat to ip daddr . th dport map @fwdtoip_th
}
}Hi Pablo,
sorry for delay, I had to install 1.0.0 from snap on my Ubuntu 20.04.
Le 21/09/2021 à 02:13, Pablo Neira Ayuso a écrit :
Quoted 66 lines · Daniel
Quoted 58 lines
Le 16/09/2021 à 14:58, Pablo Neira Ayuso a écrit :
Quoted 8 lines
[...]
so you want to redirect all ports except a few of them?add map x mymap { type
ipv4_addr:ipv4_addr; }
add rule x y ip protocol { tcp, udp } th dport 1-65534 dnat to ip saddr map @mymapThis allows you to dnat depending on the IP source address, skipping 0 and 65535 for TCP and UDP.
I don't get I so lets be more explicite with an example.
I want to redirect udp port 10000-20000 to another IP (typically asterisk RTP ports from host to a VM) What I have today which work with single ports (bash script, yes I know ;))
nft add map $1 nat fwdtoip_tcp.$IFACE { type
inet_service:
$mytype\; flags interval\; }
nft add map $1 nat fwdtoip_udp.$IFACE { typeinet_service:
$mytype\; flags interval\; }
nft add map $1 nat fwdtoport_tcp.$IFACE { typeinet_service:
inet_service\; flags interval\;}
nft add map $1 nat fwdtoport_udp.$IFACE { typeinet_service:
inet_service\; flags interval\;}
nft add map $1 nat redirect_tcp.$IFACE { typeinet_service:
inet_service\; flags interval\;}
nft add map $1 nat redirect_udp.$IFACE { typeinet_service:
inet_service\; flags interval\;}where $1 is ip or ip6, $mytype is
ipv4_addroripv6_addrThen from a list of ports I extract each value -including ranges like above exemple- and do
If src address != to dst address
nft add element $1 nat fwdtoip_$myproto.$IFACE { $tmpsport : $mydaddr }
nft add element $1 nat fwdtoport_$myproto.$IFACE { $tmpsport :
$tmpdport } ; this is not accepted when a range is given like 10000-20000If src address = dst address
nft add element $1 nat redirect_$myproto.$IFACE { $tmpsport :
$tmpdport }where $1 is ip or ip6, $myproto is udp or tcp, $tmpsport port or range of port to redirect, $myaddr is destination ip. $tmpdport can be equal or a different value from $tmpsport
Finally rules
nft add rule ip nat prerouting ip daddr == $myaddripv4 dnat tcp dport map @fwdtoip_tcp.$IFACE : tcp dport map @fwdtoport_tcp.$IFACE nft add rule ip nat prerouting ip daddr == $myaddripv4 dnat udp dport map @fwdtoip_udp.$IFACE : udp dport map @fwdtoport_udp.$IFACE nft add rule ip nat prerouting ip daddr == $myaddripv4 meta l4proto tcp dnat to : tcp dport map @redirect_tcp.$IFACE
nft add rule ip nat prerouting ip daddr == $myaddripv4 meta l4proto udp dnat to : udp dport map @redirect_udp.$IFACEQuoted 5 lines
This works perfectly with single ports but as soon as I want to redirect a range of ports it fail.
Where is my mistake ? Is it to complicate to achieve something which should be easy ?
You require nftables 1.0.0 for the snippet below:
Quoted 12 lines
table ip nat {
map fwdtoip_th {
type ipv4_addr . inet_service : interval ipv4_addr . inet_service
flags interval
elements = { 1.2.3.4 . 10000-20000 : 192.168.3.4 . 30000-40000 }
}
chain prerouting {
type nat hook prerouting priority dstnat; policy accept;
meta l4proto { tcp, udp } dnat to ip daddr . th dport map @fwdtoip_th
}
}I can't get it, map is OK but creating rule fail
map in nat prerouting:
map fwdtoip_th {
type ipv4_addr . inet_service : interval ipv4_addr . inet_service flags interval
elements = { 192.168.10.24 . 58194-58198 : 192.168.10.254 . 58194-58198 } }
Now I add the rule
sudo nft add rule ip nat prerouting meta l4proto { tcp, udp } dnat to ip daddr . th dport map @fwdtoip_th ; from your example
and error is
Error: datatype mismatch: expected IPv4 address, expression has type concatenation of (IPv4 address, internet network service) add rule ip nat prerouting meta l4proto { tcp, udp } dnat to ip daddr . th dport map @fwdtoip_th
OK, after to ip should be the daddr so I insert it
sudo nft add rule ip nat prerouting meta l4proto { tcp, udp } dnat to ip daddr daddr . th dport map @fwdtoip_th
and error is
Error: syntax error, unexpected newline
add rule ip nat prerouting meta l4proto { tcp, udp } dnat to ip daddr daddr . th dport map @fwdtoip_th
What's wrong ?
Thanks for your help
Signature · 1 line
Daniel
Le 28/09/2021 à 13:05, Daniel a écrit :
Quoted 41 lines
Hi Pablo,
sorry for delay, I had to install 1.0.0 from snap on my Ubuntu 20.04.
Le 21/09/2021 à 02:13, Pablo Neira Ayuso a écrit :
[...]Quoted 9 lines
You require nftables 1.0.0 for the snippet below:
table ip nat {
mapfwdtoip_th{
typeipv4_addr.inet_service: intervalipv4_addr.inet_serviceflags interval
elements = { 1.2.3.4 . 10000-20000 : 192.168.3.4 . 30000-40000 } }Quoted 5 lines
chain prerouting {
type nat hook prerouting priority dstnat; policy accept; meta l4proto { tcp, udp } dnat to ip daddr . th dport map @fwdtoip_th }
}I can't get it, map is OK but creating rule fail
map in nat prerouting:
map
fwdtoip_th{
typeipv4_addr.inet_service: intervalipv4_addr.inet_serviceflags interval
elements = { 192.168.10.24 . 58194-58198 : 192.168.10.254 .
58194-58198 }
}Now I add the rule
sudo nft add rule ip nat prerouting meta l4proto { tcp, udp } dnat to ip daddr . th dport map @fwdtoip_th ; from your example
and error is
Error: datatype mismatch: expected IPv4 address, expression has type concatenation of (IPv4 address, internet network service) add rule ip nat prerouting meta l4proto { tcp, udp } dnat to ip daddr . th dport map @fwdtoip_th
Quoted 8 lines
OK, after to ip should be the daddr so I insert it
sudo nft add rule ip nat prerouting meta l4proto { tcp, udp } dnat to ip daddr daddr . th dport map @fwdtoip_th
and error is
Error: syntax error, unexpected newline
add rule ip nat prerouting meta l4proto { tcp, udp } dnat to ip daddr daddr . th dport map @fwdtoip_th
Something is wrong when calling a named map (in this case). If I do
sudo nft add rule ip nat prerouting meta l4proto { tcp, udp } dnat to ip daddr . th dport map { 192.168.10.24 . 10000-20000 : 192.168.10.254 . 3000-40000 }
everything is fine. But if I call the map like
sudo nft add rule ip nat prerouting meta l4proto { tcp, udp } dnat to ip daddr . th dport map @fwdtoip_th
I get
Error: datatype mismatch: expected IPv4 address, expression has type concatenation of (IPv4 address, internet network service) add rule ip nat prerouting meta l4proto { tcp, udp } dnat to ip daddr . th dport map @fwdtoip_th
Expression recognize that map is a concatenation but not that the "to ip daddr . th dport" should also be treated as concatenation
Signature · 1 line
Daniel
Quoted 1 line · Daniel
Le 28/09/2021 à 13:05, Daniel a écrit :
[...]
Quoted 7 lines
everything is fine. But if I call the map like
sudo nft add rule ip nat prerouting meta l4proto { tcp, udp } dnat to ip daddr . th dport map @fwdtoip_th
I get
Quoted 7 lines
Error: datatype mismatch: expected IPv4 address, expression has type concatenation of (IPv4 address, internet network service)
add rule ip nat prerouting meta l4proto { tcp, udp } dnat to ip daddr . th dport map @fwdtoip_thExpression recognize that map is a concatenation but not that the "to ip daddr . th dport" should also be treated as concatenation
Fix: https://patchwork.ozlabs.org/project/netfilter-devel/patch/[email protected]/