Christmas Offer - Every Learner Must Check Out - Flat 88% OFF on All Access Pass
00
days
:
00
hours
:
00
minutes
:
00
seconds
PyNet Labs- Network Automation Specialists

What is Wildcard Mask in Networking?

Author : PyNet Labs
Last Modified: January 23, 2024 
Blog Featured image showcasing a network topology of wildcard mask and text - What is Wildcard Mask in Networking.

Introduction

Anyone who has worked with networking devices, such as routers and switches, may have heard of the term wildcard mask. A wildcard mask is a way of specifying a range of IP addresses for different purposes, some of which are access control lists, rioting protocols such as OSPF, and network address translation. But the main question that comes to mind is what exactly is a wildcard mask and how does it work?

In this blog, we will explain wildcard mask in detail, and along with it, we will be explaining why we use wildcard mask in OSPF, and the basic difference between subnet mask and wildcard mask. Understanding of Wildcard masks are very crucial for all network engineers and are covered under the CCNA Course.

Before getting into more details, let’s first understand the basics of wildcard mask.

What is Wildcard Mask in Networking?

A wildcard mask is a 32-bit binary number that is mainly used to indicate which bits of an IP address must match and which bits do not matter. It is somewhat similar to a subnet mask, but the way it operates is opposite to a subnet mask. A subnet mask uses 1s to indicate the network bits whereas 0s to indicate the host bits. In the case of a wildcard mask, the rule is:

  • 0 means that the equivalent bit must match
  • 1 means that the equivalent bit does not matter

Below, we have taken an example for better understanding.

Let’s suppose you have an IP network address of 192.168.1.0 and want to define a range of addresses from 192.168.1.0 to 192.168.1.255, you would use a subnet mask of 255.255.255.0. The subnet mask is represented in binary as:

11111111.11111111.11111111.00000000

Now, as we discussed above wildcard mask works oppositely to the subnet mask. Hence, in this case same range would be the inverse of the subnet mask, which in binary is:

00000000.00000000.00000000.11111111

And if we write it in a decimal format, it is written as 0.0.0.255

For a better understanding, we have shown some of the most common subnet masks and their wildcard mask in the decimal format.

Subnet MaskSlash NotationWildcard Mask
255.255.255.0/240.0.0.255
255.255.255.128/250.0.0.127
255.255.255.192/260.0.0.63
255.255.255.240/280.0.0.15
255.255.255.248/290.0.0.7
255.255.254.0/230.0.1.255
255.255.0.0/160.0.255.255
255.255.224.0/190.0.31.255
255.0.0.0/80.255.255.255

Many of the students are curious about why it is used in OSPF. Let’s understand with an example.

Why We Use Wildcard Mask in OSPF?

OSPF or Open Shortest Path First is a dynamic routing protocol that mainly makes use of link-state information to calculate the best routes for IP packets within a network. One of the main features of OSPF is that it defines areas. Now, if talk about areas, these are logical groups of routers that share the same link-state information and in return reduce the amount of routing updates.

In order to define an area, one has to specify which interfaces belong to a particular area using either an IP address or a network address with a wild card mask.

Let’s take an example for better understanding.

Suppose someone wants to assign an interface GigabitEthernet0/1 on router R1 to area 0. Below are the commands one can use for it.

R1(config)#router ospf 1

R1(config-router)#network 192.168.1.1 0.0.0.0 area 0

or

R1(config)#router ospf 1

R1(config-router)#network 192.168.1.0 0.0.0.255 area 0

The first command uses the IP address of the interface with a wildcard mask of all zeros. It simply means that only that particular address matches.

Similarly, if we look into the second command, it uses the network address of the interface with a wild-card mask of all ones in the last octet. It simply signifies that any address in the subnet matches.

Now, back to the question of why use wildcard mask in OSPF.

With the help of these masks in OSPF, it offers more flexibility as well as efficiency in defining areas. One can use different wildcard masks in order to match different ranges of addresses. This totally depends on the network design.

Below, we have explained with the help of an example.

Suppose, there is a network with four subnets. These are 10.10.10.0/26, 10.10.10.64/26, 10.10.10.128/26, and 10.10.10.192/26. Now, in order to assign them to different areas, one can use the commands mentioned below.

R1(config)#router ospf 1

R1(config-router)#network 10.10.10.0  0.0.0.63 area 0

R1(config-router)#network 10.10.10.64 0.0.0.63 area 1

R1(config-router)#network 10.10.10.128 0.0.0.63 area 2

R1(config-router)#network 10.10.10.192 0.0.0.63 area 3

One can easily use a single mask to match each subnet and further assign it to different areas.

Let’s now understand what is the use of this mask in detail.

What is the Use of Wildcard Mask?

Wildcard masks can be used in various features and also constructs on networking devices. Some of these are:

1 – Access Control Lists (ACLs)

ACLs are mainly used to filter traffic on the basis of source and destination IP addresses, protocols, ports, etc. One can use this mask to specify ranges of IP addresses that one wants to permit or deny.

2 – Routing Protocols

Routing Protocols such as OSPF, EIGRP, and BGP make use of these masks to define networks or interfaces that participate in routing updates or neighbor relationships.

3 – IP summarization

It is a technique with which one can reduce the number of routes in a routing table by aggregating them into a single route with a common prefix. Wildcard masks can be used to specify which bits of the prefix are variable and which are fixed.

4 – Network Address Translation (NAT)

It is a process that assists in changing the source or destination IP address of a packet as it passes through a device. It is used for various purposes, such as conserving IP addresses, hiding internal network topology, etc. One can use these masks in order to specify the IP address range that one wants to translate.

Difference Between Subnet Mask and Wildcard Mask

Below we have explained the Subnet Mask vs Wildcard Mask in a tabular form based on different factors.

FactorsSubnet MaskWildcard Mask
PurposeSeparates IP addresses into host and network addressesAllows or denies all the traffic from a network IP address
UsageExpresses the bit length that matches the network portion of IPv4 addressesIndicates network size or subnet for routing protocols such as OSPF and ACLs
Bit MatchingMatches binary 1s with network bits and 0s with host bitsMatches binary 0s with network bits and 1s with host bits
FlexibilityRequires contiguity of bitsAllows discontiguity of bits

These are the differences between Wildcard and Subnet Masks.

Frequently Asked Questions

Q1. What is a wildcard mask used for?

The main purpose of a wildcard mask is to specify what range of IP addresses can be allowed or denied in the ACLs and with routing protocols like OSPF.

Q2. What is the difference between wildcard and subnet mask?

A wildcard mask is a bit pattern that specifies which bits in an IP address can vary. On the other hand, a subnet mask is a bit pattern that specifies which bits in an IP address belong to a network prefix and which belong to the host identifier.

Q3. What is wildcard mask in ACL?

Wildcard mask is mainly used for matching either a specific IP address or a range of IP addresses. ACLs filter based on the IP address range that is configured from a wildcard mask.

Q4. What’s a subnet mask?

A subnet mask is a binary number that defines the network and host portions of an IP address.

Conclusion

In this blog, we have explained what a wildcard mask is along with its calculation. Along with it, we also have explained why we use it in OSPF and where to use it. We have seen that wildcard mask is mainly used to define a range of IP addresses for different types of purposes in networking. We have also explained the basic difference between the subnet mask and the wildcard mask.

We hope that through this blog, we have cleared all your doubts and help understand this mask much better. Still, if you have any more queries, you can leave a comment below.

Recent Blog Post

Leave a Reply

Your email address will not be published. Required fields are marked *

linkedin facebook pinterest youtube rss twitter instagram facebook-blank rss-blank linkedin-blank pinterest youtube twitter instagram