Skip to contentSkip to conversation

Strange thing with iptables

DISCUSSION Szabolcs Gyurko 5 participants 7 messages Sep 9, 2004 – Sep 11, 2004 netfilter

lore
Share & tools
lore
#0 lore raw

Hi all,

I found a strange issue with the iptables. One of my friend showed me a rule which looked like:

iptables -A FORWARD -s $machine/255.255.0.255 -j ACCEPT

What I was surprised on is the netmask. Is this a feature or a bug? I mean this is quite strange netmask for me.

Thanks for any answers,

Signature · 1 line
Szabolcs Gyurko
#1 lore raw
Quoted 7 lines · Szabolcs Gyurko

Hi all,

I found a strange issue with the iptables. One of my friend showed me a rule
which looked like:

Quoted 5 lines

iptables -A FORWARD -s $machine/255.255.0.255 -j ACCEPT

What I was surprised on is the netmask. Is this a feature or a bug? I mean this is quite strange netmask for me.

It's a feature :)
It doesn't make the current code any more complicated. And ther are actually people using it to do weird stuff...

Signature · 1 line
/Martin
#2 lore raw
Quoted 11 lines · Martin Josefsson
Quoted 7 lines

which looked like:

iptables -A FORWARD -s $machine/255.255.0.255 -j ACCEPT

What I was surprised on is the netmask. Is this a feature or a bug? I mean this is quite strange netmask for me.

It's a feature :)
It doesn't make the current code any more complicated. And ther are actually people using it to do weird stuff...

Do you mean that one can use arbitrary bitmasks wherever netfilter wants a netmask value? So, one might select all IPs with the LSB set with 0.0.0.1/0.0.0.1?

Alexey

#3 lore raw

Sure. That is what seems to me an absolute discarding of the ipv4 rules. But it's a feature, so...

Quoted 19 lines · Alexey Toptygin
Quoted 11 lines · Martin Josefsson
Quoted 7 lines

which looked like:

iptables -A FORWARD -s $machine/255.255.0.255 -j ACCEPT

What I was surprised on is the netmask. Is this a feature or a bug? I mean this is quite strange netmask for me.

It's a feature :)
It doesn't make the current code any more complicated. And ther are actually people using it to do weird stuff...

Do you mean that one can use arbitrary bitmasks wherever netfilter wants a netmask value? So, one might select all IPs with the LSB set with 0.0.0.1/0.0.0.1?

Alexey

Signature · 1 line
Szabolcs Gyurko
#4 lore raw
Quoted 2 lines · Szabolcs Gyurko

Sure. That is what seems to me an absolute discarding of the ipv4 rules. But it's a feature, so...

Search google for "netmask 255.255.0.255" and read the first two hits (netfilter archive from 2001 October :-).
(And do not top-post, please :-().

Quoted 14 lines
Quoted 11 lines · Alexey Toptygin
Quoted 9 lines · Martin Josefsson
Quoted 8 lines

which looked like:

iptables -A FORWARD -s $machine/255.255.0.255 -j ACCEPT

What I was surprised on is the netmask. Is this a feature or a bug? I mean
this is quite strange netmask for me.

Quoted 7 lines
Quoted 7 lines
Quoted 3 lines

It's a feature :)
It doesn't make the current code any more complicated. And ther are actually people using it to do weird stuff...

Do you mean that one can use arbitrary bitmasks wherever netfilter wants a netmask value?
So, one might select all IPs with the LSB set with 0.0.0.1/0.0.0.1?

Best regards,
Jozsef
-
E-mail : [email protected], [email protected] PGP key : http://www.kfki.hu/~kadlec/pgp_public_key.txt
Address : KFKI Research Institute for Particle and Nuclear Physics

          H-1525 Budapest 114, POB. 49, Hungary
#5 lore raw
In reply to Alexey Toptygin
Quoted 7 lines · Alexey Toptygin
Quoted 3 lines

It's a feature :)
It doesn't make the current code any more complicated. And ther are actually people using it to do weird stuff...

Do you mean that one can use arbitrary bitmasks wherever netfilter wants a netmask value?
So, one might select all IPs with the LSB set with 0.0.0.1/0.0.0.1?

Yes you can.
Although this might change in the (distant) future when diffrent algorithms are used for rule-lookup.

Signature · 1 line
/Martin
#6 lore raw
In reply to Martin Josefsson

Hi,

Quoted 10 lines · Martin Josefsson
Quoted 6 lines

iptables -A FORWARD -s $machine/255.255.0.255 -j ACCEPT

What I was surprised on is the netmask. Is this a feature or a bug? I mean this is quite strange netmask for me.

It's a feature :)
It doesn't make the current code any more complicated. And ther are actually people using it to do weird stuff...

I second this. I actually had to use the same principle on some equipment (alteon) which also supports this, and it saved me a lot of filters when writing anti-spoofing rules on a port where two IP networks coexist.

Cheers,
Willy