This post will serve us to classify with Access Control Lists, if a host IP it’s odd or even. It’s a very common question when you are preparing any Cisco certification.

Despite a difficult question to resolve, it’s very simple. People who work frecuently with Cisco devices, are used to classify network traffic by using port numbers, specific hosts and full subnets. But not so frecuently to classify using even or odd IP addresses.

To determine whether a host is even or odd, we take the last octect in the network address, and then the less significant bit. So what we have:

  • If it’s zero, even host.
  • If it’s one, odd host.

Like so:

192.168.40.1    - 00000001
192.168.20.5    - 00000101
192.168.33.78   - 01001110
192.168.115.180 - 10110100

The method used by an ACL to classify traffic is the wildcard, ie, the inverse of the mask. Hence, all bits in the wildcard set to zero will be taken in account, while the ones set to one will not be taken in account. Since we need to look at the last bit, the wildcard for the ACL will be:

0.0.0.254

Now we can build the correct ACLs for this classfication. For example, to get all the even hosts in the subnet 192.168.40.0/24 and all the odd in the 172.16.10.0/24 subnet, we’ll use the following:

access-list 101 permit ip 192.168.40.0 0.0.0.254
access-list 102 permit ip 172.16.10.1 0.0.0.254