Access-List to match Even or Odd networks


Here is a simple tip to write an access-list for even or odd networks.

Lets say we are asked to permit all odd or permit all even for 192.168.1.0/24 ?

We’ll play the game with last octet or I should say the least significant bit of last octet.

-If it is 0, the IP address will be Even

-If it is 1, the IP address will be Odd

192.168.1.00000001 = 192.168.1.1 – odd

192.168.1.00000011 = 192.168.1.3  – odd

192.168.1.00000010 = 192.168.1.2   even

192.168.1.00000100 = 192.168.1.4   even

FOR Even Networks

The IP address will be 192.168.1.0

With the wild card mask as 0.0.0.254

254 = 11111110

Here, 0 means DO CARE of the last bit in IP address (must be ZERO)

Hence ACL will be

access-list 1 permit 192.168.1.0  0.0.0.254

For Odd Networks

The IP address will be 192.168.1.1

With the wild card mask as 0.0.0.254

254 = 11111110

Here, 0 means DO CARE of the last bit in IP address (must be ONE)

Hence ACL will be

access-list 1 permit 192.168.1.1 0.0.0.254

Advertisements