Re: Wildcard Mask to match noncontiguous bits

From: Robert Cuello (smdmokay@yahoo.com)
Date: Mon Mar 26 2007 - 12:46:40 ART


Thank you,
   
  It really helped.
   
  Robert

maureen schaar <maureen.schaar@gmail.com> wrote:
  I have no good reference, but I can give you some examples to
hopefully make it clear.

In a wildcard mask, a 0 bit means that it must match to the
corresponding bit in the network. A 1 means the opposite.

So:
0 = must match
1 = may or may not match (don't care bit)

If I want to match all odd networks at the /24 boundary for 10.1.1.0,
we have to do the math on the third octet:

1 = 0 0 0 0 0 0 0 1

Now to result in an odd or even network, only the last bit is interesting.

0 = 0 0 0 0 0 0 0 0
1 = 0 0 0 0 0 0 0 1
2 = 0 0 0 0 0 0 1 0
3 = 0 0 0 0 0 0 1 1
4 = 0 0 0 0 0 1 0 0
5 = 0 0 0 0 0 1 0 1
etc.

The other bits can be anything we like, so we apply the following wc mask:

1 1 1 1 1 1 1 1 0 = 254

For odd networks, this results in 10.1.1.0 0.0.254.255
For even networks, this results in 10.1.0.0 0.0.254.255

Another example. If you need to match 10.1.4.0 and 10.1.20.0 in a
one-line access-list, do the following:

4 = 0 0 0 0 0 1 0 0
20 = 0 0 0 1 0 1 0 0

When you write it down binary, you see that only one bit is different.
So this bit can be either zero or one, we don't care --> apply a 1 in
the wc mask for this bit position.

This results in a wc mask: 0 0 0 1 0 0 0 0 = 16

--> 10.1.4.0 0.0.16.0 will match both 10.1.4.0 and 10.1.20.0.

If we want to match networks:
10.1.0.0 ( 0 0 0 0 0 0 0 0 )
10.1.2.0 ( 0 0 0 0 0 0 1 0 )
10.1.16.0 ( 0 0 0 1 0 0 0 0 )
10.1.18.0 ( 0 0 0 1 0 0 1 0 )

We see all four networks are only different on exactly two bit
positions. It the wc mask we apply a 1 (don't care) for these two
bits.

--> 0 0 0 1 0 0 1 0 = 18

This would result in 10.1.0.0 0.0.18.0

Hope this helps.

Maureen

On 3/24/07, Robert Cuello wrote:
> Hello all,
>
> I'm looking for some good resorces with wildcard masks. Especifically, to do things like only match only odd or even networks. I cannot find anythig on the Cisco website besides the statement:
> "Unlike subnet masks, which require contiguous bits indicating network and subnet to be ones, wildcard masks allow noncontiguous bits in the mask."
>
> Thanks
>
>
> ---------------------------------
> Get your own web address.
> Have a HUGE year through Yahoo! Small Business.
>
> _______________________________________________________________________
> Subscription information may be found at:
> http://www.groupstudy.com/list/CCIELab.html
>

 
---------------------------------
TV dinner still cooling?
Check out "Tonight's Picks" on Yahoo! TV.



This archive was generated by hypermail 2.1.4 : Sun Apr 01 2007 - 06:35:53 ART