Skip to contentSkip to conversation

inconsistent address treatment.

DISCUSSION Stephen Clark 4 participants 17 messages Dec 23, 2010 – Jan 8, 2011 netfilter

lore
Share & tools
lore
#0 lore raw

Hello,

Why the inconsistency in the way addresses are treated. I can use -d 2.2.2.2/32
but not --to-source 205.201.149.214/32

iptables -t nat -A POSTROUTING -o eth1 -s 10.0.128.0/17 -d 2.2.2.2/32 -j SNAT --to-source 205.201.149.214/32

Signature · 5 lines
"They that give up essential liberty to obtain temporary safety,
deserve neither liberty nor safety."  (Ben Franklin)

"The course of history shows that as a government grows, liberty
decreases."  (Thomas Jefferson)
#1 lore raw

Hello,

Quoted 4 lines · Stephen Clark

Why the inconsistency in the way addresses are treated. I can use -d 2.2.2.2/32
but not --to-source 205.201.149.214/32

Because -d takes a prefix and --to-source takes an address range. --
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#13 lore raw
In reply to Stephen Clark
Quoted 7 lines · Stephen Clark

Hello,

Why the inconsistency in the way addresses are treated. I can use -d 2.2.2.2/32 but not --to-source 205.201.149.214/32

iptables -t nat -A POSTROUTING -o eth1 -s 10.0.128.0/17 -d 2.2.2.2/32 -j SNAT --to-source 205.201.149.214/32

What inconsistency?

#2 lore raw
In reply to Pascal Hambourg
Quoted 10 lines · Pascal Hambourg

Hello,

Quoted 4 lines · Stephen Clark

Why the inconsistency in the way addresses are treated. I can use -d 2.2.2.2/32
but not --to-source 205.201.149.214/32

Because -d takes a prefix and --to-source takes an address range.

So? you can't parse

205.201.149.214/32-205.201.149.218/32

Signature · 12 lines
"They that give up essential liberty to obtain temporary safety,
deserve neither liberty nor safety."  (Ben Franklin)

"The course of history shows that as a government grows, liberty
decreases."  (Thomas Jefferson)



--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#14 lore raw
In reply to Jan Engelhardt
Quoted 5 lines · Jan Engelhardt
Quoted 2 lines · Stephen Clark

Hello,

Quoted 8 lines
Quoted 6 lines

Why the inconsistency in the way addresses are treated. I can use -d 2.2.2.2/32 but not --to-source 205.201.149.214/32

iptables -t nat -A POSTROUTING -o eth1 -s 10.0.128.0/17 -d 2.2.2.2/32 -j SNAT --to-source 205.201.149.214/32

What inconsistency?

If you try the above command you get a complaint about

--to-source 205.201.149.214/32
you have to use
--to-source 205.201.149.214

iptables 1.4.5.

Quoted 6 lines

--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Signature · 5 lines
"They that give up essential liberty to obtain temporary safety,
deserve neither liberty nor safety."  (Ben Franklin)

"The course of history shows that as a government grows, liberty
decreases."  (Thomas Jefferson)
#3 lore raw
In reply to Stephen Clark
Quoted 8 lines · Stephen Clark
Quoted 7 lines · Pascal Hambourg
Quoted 4 lines · Stephen Clark

Why the inconsistency in the way addresses are treated. I can use -d 2.2.2.2/32
but not --to-source 205.201.149.214/32

Quoted 5 lines
Quoted 1 line

Because -d takes a prefix and --to-source takes an address range.

So? you can't parse

205.201.149.214/32-205.201.149.218/32

a.b.c.d/32 is a prefix notation, even though it represents a single address. IMO it does not make sense to use a prefix notation in an interval, so I don't see why the parser should handle it. AFAICS, other commands such as 'ip' from iproute don't accept /32 prefixes where a single address is expected either.
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#15 lore raw
In reply to Stephen Clark
Quoted 10 lines · Stephen Clark
Quoted 9 lines · Jan Engelhardt
Quoted 7 lines · Stephen Clark

Why the inconsistency in the way addresses are treated. I can use -d 2.2.2.2/32
but not --to-source 205.201.149.214/32

iptables -t nat -A POSTROUTING -o eth1 -s 10.0.128.0/17 -d 2.2.2.2/32 -j SNAT --to-source 205.201.149.214/32

Quoted 7 lines
Quoted 2 lines

What inconsistency?

If you try the above command you get a complaint about

--to-source 205.201.149.214/32
you have to use
--to-source 205.201.149.214

Ah "that" sort of "inconsensitency". No, that is not an inconsistency. -d takes an addr[/mask] or a addr[/prefixlen] or a list thereof, while -m iprange and DNAT's --to-source take addr[-addr].

Each is subtly different. And documented.

#4 lore raw
In reply to Pascal Hambourg
Quoted 16 lines · Pascal Hambourg
Quoted 14 lines · Stephen Clark
Quoted 10 lines · Pascal Hambourg
Quoted 5 lines · Stephen Clark

Why the inconsistency in the way addresses are treated. I can use -d 2.2.2.2/32

    but not --to-source 205.201.149.214/32

Because -d takes a prefix and --to-source takes an address range.

So? you can't parse

Quoted 8 lines
Quoted 2 lines

205.201.149.214/32-205.201.149.218/32

a.b.c.d/32 is a prefix notation, even though it represents a single address. IMO it does not make sense to use a prefix notation in an interval, so I don't see why the parser should handle it. AFAICS, other commands such as 'ip' from iproute don't accept /32 prefixes where a single address is expected either.

Well It is just one more idiosyncrasy one has to remember, when to me there is no obvious reason for it to be so. It also means if you are writing some kind of automated tool to create rules for iptables from a set of address objects then you have remember, Oh I have to drop the /32 if this object is used as an argument for --to-source. That means everyone that trys to develop an automated tool has to deal with this anomaly instead of being dealt with in one place, the parser for iptables.

Signature · 12 lines
"They that give up essential liberty to obtain temporary safety,
deserve neither liberty nor safety."  (Ben Franklin)

"The course of history shows that as a government grows, liberty
decreases."  (Thomas Jefferson)



--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#16 lore raw
In reply to Jan Engelhardt
Quoted 28 lines · Jan Engelhardt
Quoted 13 lines · Stephen Clark
Quoted 11 lines · Jan Engelhardt
Quoted 8 lines · Stephen Clark

Why the inconsistency in the way addresses are treated. I can use -d 2.2.2.2/32
but not --to-source 205.201.149.214/32

iptables -t nat -A POSTROUTING -o eth1 -s 10.0.128.0/17 -d 2.2.2.2/32 -j SNAT --to-source 205.201.149.214/32

Quoted 9 lines
Quoted 3 lines

What inconsistency?

If you try the above command you get a complaint about

--to-source 205.201.149.214/32
you have to use
--to-source 205.201.149.214

Ah "that" sort of "inconsensitency". No, that is not an inconsistency.

(quoted diff) +0 -2
-d takes an addr[/mask] or a addr[/prefixlen] or a list thereof, while
-m iprange and DNAT's --to-source take addr[-addr].
Quoted 7 lines

Each is subtly different. And documented.
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Just because it is documented doesn't mean it is not inconsistent.

Signature · 5 lines
"They that give up essential liberty to obtain temporary safety,
deserve neither liberty nor safety."  (Ben Franklin)

"The course of history shows that as a government grows, liberty
decreases."  (Thomas Jefferson)
#5 lore raw
In reply to Stephen Clark
Quoted 5 lines · Stephen Clark
Quoted 5 lines
Quoted 4 lines
Quoted 1 line

Because -d takes a prefix and --to-source takes an address range.

So? you can't parse
205.201.149.214/32-205.201.149.218/32

Quoted 8 lines
Quoted 5 lines

a.b.c.d/32 is a prefix notation, even though it represents a single address. IMO it does not make sense to use a prefix notation in an interval, so I don't see why the parser should handle it. AFAICS, other commands such as 'ip' from iproute don't accept /32 prefixes where a single address is expected either.

Well It is just one more idiosyncrasy one has to remember, when to me there is no obvious reason

Historical reasons.

Possible extra explanations:

- DNAT was added later than the -s argument, and someone thought it's better to use a range, since a range can be more expressive than addr[/prefixlen] for the same memory usage.
- On the other hand, since iptables also accepts addr[/mask], and it also allows /masks that are not representable as a /prefixlen, it is not necessarily specifying a contiguous range which may be useless to use with DNAT to some.

#6 lore raw
Quoted 20 lines · Jan Engelhardt
Quoted 5 lines · Stephen Clark
Quoted 5 lines
Quoted 4 lines
Quoted 1 line

Because -d takes a prefix and --to-source takes an address range.

So? you can't parse
205.201.149.214/32-205.201.149.218/32

Quoted 8 lines
Quoted 5 lines

a.b.c.d/32 is a prefix notation, even though it represents a single address. IMO it does not make sense to use a prefix notation in an interval, so I don't see why the parser should handle it. AFAICS, other commands such as 'ip' from iproute don't accept /32 prefixes where a single address is expected either.

Well It is just one more idiosyncrasy one has to remember, when to me there is no obvious reason

Historical reasons.

Possible extra explanations:

Quoted 7 lines

- DNAT was added later than the -s argument, and someone thought it's better to use a range, since a range can be more expressive than addr[/prefixlen] for the same memory usage.
- On the other hand, since iptables also accepts addr[/mask], and it also allows /masks that are not representable as a /prefixlen, it is not necessarily specifying a contiguous range which may be useless to use with DNAT to some.

FWIW: we (Squid project) use the syntax "ip[-ip][/mask]". This is simple enough to parse and is a bit more flexible.

/2c

AYJ

#7 lore raw
Quoted 29 lines · Amos Jeffries
Quoted 20 lines · Jan Engelhardt
Quoted 5 lines · Stephen Clark
Quoted 5 lines
Quoted 4 lines
Quoted 1 line

Because -d takes a prefix and --to-source takes an address range.

So? you can't parse
205.201.149.214/32-205.201.149.218/32

Quoted 8 lines
Quoted 5 lines

a.b.c.d/32 is a prefix notation, even though it represents a single address. IMO it does not make sense to use a prefix notation in an interval, so I don't see why the parser should handle it. AFAICS, other commands such as 'ip' from iproute don't accept /32 prefixes where a single address is expected either.

Well It is just one more idiosyncrasy one has to remember, when to me there is no obvious reason

Historical reasons.

Possible extra explanations:

Quoted 7 lines

- DNAT was added later than the -s argument, and someone thought it's better to use a range, since a range can be more expressive than addr[/prefixlen] for the same memory usage.
- On the other hand, since iptables also accepts addr[/mask], and it also allows /masks that are not representable as a /prefixlen, it is not necessarily specifying a contiguous range which may be useless to use with DNAT to some.

Quoted 2 lines

FWIW: we (Squid project) use the syntax "ip[-ip][/mask]". This is simple enough to parse and is a bit more flexible.

Indeed, but we don't have the space for it ;-)
There are just two uint32s available in the current struct ipt_ip, so it's either ip-ip or ip/mask.
Of course, in the near future, the ipv4 match can be extended just like other extensions (revision bump).

#8 lore raw
Quoted 33 lines · Jan Engelhardt
Quoted 30 lines · Amos Jeffries
Quoted 28 lines · Jan Engelhardt
Quoted 5 lines · Stephen Clark
Quoted 5 lines
Quoted 5 lines
Quoted 2 lines

Because -d takes a prefix and --to-source takes an address range.

So? you can't parse
205.201.149.214/32-205.201.149.218/32

Quoted 9 lines
Quoted 6 lines

a.b.c.d/32 is a prefix notation, even though it represents a single address. IMO it does not make sense to use a prefix notation in an interval, so I don't see why the parser should handle it. AFAICS, other commands such as 'ip' from iproute don't accept /32 prefixes where a single address is expected either.

Well It is just one more idiosyncrasy one has to remember, when to me there is no obvious reason

Historical reasons.

Possible extra explanations:

- DNAT was added later than the -s argument, and someone thought it's better to use a range, since a range can be more expressive than addr[/prefixlen] for the same memory usage.
- On the other hand, since iptables also accepts addr[/mask], and it also allows /masks that are not representable as a /prefixlen, it is not necessarily specifying a contiguous range which may be useless to use with DNAT to some.

Quoted 10 lines
Quoted 3 lines

FWIW: we (Squid project) use the syntax "ip[-ip][/mask]". This is simple enough to parse and is a bit more flexible.

Indeed, but we don't have the space for it ;-)
There are just two uint32s available in the current struct ipt_ip, so it's either ip-ip or ip/mask.
Of course, in the near future, the ipv4 match can be extended just like other extensions (revision bump).

That is a reasonable answer.

Signature · 5 lines
"They that give up essential liberty to obtain temporary safety,
deserve neither liberty nor safety."  (Ben Franklin)

"The course of history shows that as a government grows, liberty
decreases."  (Thomas Jefferson)
#10 lore raw
Quoted 6 lines · Pascal Hambourg
Quoted 2 lines · Amos Jeffries

FWIW: we (Squid project) use the syntax "ip[-ip][/mask]".

I'm being curious : what is the meaning of "ip-ip/mask" when both the range and mask are present ?

Sounds like

192.168.0.64-192.168.191/255.255.255.253
<=>
192.168.0.{64 65 68 69 72 73 76 77 77...}

Well, it's probably of use... to someone.
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#11 lore raw
Quoted 9 lines · Jan Engelhardt
Quoted 6 lines · Pascal Hambourg
Quoted 2 lines · Amos Jeffries

FWIW: we (Squid project) use the syntax "ip[-ip][/mask]".

I'm being curious : what is the meaning of "ip-ip/mask" when both the range and mask are present ?

Quoted 7 lines

Sounds like

192.168.0.64-192.168.191/255.255.255.253
<=>
192.168.0.{64 65 68 69 72 73 76 77 77...}

Well, it's probably of use... to someone.

For yourselves I was thinking limit it to CIDR masks. As in:
192.168.0.0/24 ==> 19.168.0.0-192.168.0.255
192.168.1.0-192.168.10.0/23 ==> 192.168.1.0-192.168.11.255 192.168.0.0-192.168.100.0/24 ==> 192.168.0.0-192.168.100.255

Netmasks get a bit tricky and as you say you don't have enough storage space to hold the mask as well.

AYJ
Ps. sorry for the slow reply, holidays.
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#12 lore raw
Quoted 8 lines · Amos Jeffries
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

FWIW: we (Squid project) use the syntax "ip[-ip][/mask]".

I'm being curious : what is the meaning of "ip-ip/mask" when both the range and mask are present ?

Sounds like

The scheme (a-b)/msk:

Quoted 6 lines
Quoted 6 lines

192.168.0.64-192.168.191/255.255.255.253
<=>
192.168.0.{64 65 68 69 72 73 76 77 77...}

Well, it's probably of use... to someone.

Squid's a-lastof(b/plen):

Quoted 3 lines

For yourselves I was thinking limit it to CIDR masks. As in:
192.168.1.0-192.168.10.0/23 ==> 192.168.1.0-192.168.11.255

If, for any combination of a,b,plen in your a-lastof(b/plen), you get a contiuguous range [and that does seem to be the case], it is redundant to store plen, since that can just be expressed by an appropriate contiguous range a-c.

That said, a-b/plen does look confusing, because one might also assume (a-b)/plen:

192.168.1.0-192.168.10.0/23 => 192.168.0.0-192.168.11.255 (Because 192.168.1.0/23's top is 192.168.0.0)