Chapter 7 Firewall for FortiOS 5.0 : Firewall objects : Addresses : Wildcard Addressing
  
Wildcard Addressing
Wildcard addresses are addresses that identify ranges of IP addresses, reducing the amount of firewall addresses and security policies required to match some of the traffic on your network. Wildcard addresses are an advanced feature, usually required only for complex networks with complex firewall filtering requirements. By using these wildcard addresses in the firewall configuration, administrators can eliminate creating multiple, separate IP based address objects and then grouping them to then apply to multiple security policies.
A wildcard address consists of an IP address and a wildcard netmask, for example, 192.168.0.56 255.255.0.255. In this example, the IP address is 192.168.0.56 and the wildcard netmask is 255.255.0.255. The IP address defines the networks to match and the wildcard netmask defines the specific addresses to match on these networks.
In a wildcard netmask, zero means ignore the value of the octet in the IP address, which means the wildcard firewall address matches any number in this address octet. This also means that the number included in this octet of IP address is ignored and can be any number. Usually, if the octet in the wildcard netmask is zero, the corresponding octet in the IP address is also zero.
In a wildcard netmask, a number means match addresses according to how the numbers translate into binary addresses. For example, the wildcard netmask is 255; the wildcard address will only match addresses with the value for this octet that is in the IP address part of the wildcard address. So, if the first octet of the IP address is 192 and the first octet of the wildcard netmask is 255, the wildcard address will only match addresses with 192 in the first octet.
In the above example, the wildcard address 192.168.0.56 255.255.0.255 would match the following IP addresses:
192.168.0.56, 192.168.1.56, 192.168.2.56,..., 192.168.255.56
The wildcard addresses 192.168.0.56 255.255.0.255 and 192.168.1.56 255.255.0.255 define the same thing since the 0 in the wildcard mask means to match any address in the third octet.
If we use the wildcard address 172.0.20.10 255.0.255.255, it would match the following IP addresses:
172.1.20.10, 172.2.20.10, 172.3.20.10,..., 172.255.20.10
In a wildcard netmask, a number other than 255 matches multiple addresses for this octet. You can perform a binary conversion to calculate the addresses that would be matched by a given value. For example, to create the IP address and wildcard netmask to match the following network addresses:
192.168.32.0/24
192.168.33.0/24
192.168.34.0/24
192.168.35.0/24
192.168.36.0/24
192.168.37.0/24
192.168.38.0/24
192.168.39.0/24
Table 45 shows how to write the third octet for these networks according to the octet bit position and address value for each bit.
Table 45: Octet bit position and address value for each bit
Decimal
128
64
32
16
8
4
2
1
32
0
0
1
0
0
0
0
0
33
0
0
1
0
0
0
0
1
34
0
0
1
0
0
0
1
0
35
0
0
1
0
0
0
1
1
36
0
0
1
0
0
1
0
0
37
0
0
1
0
0
1
0
1
38
0
0
1
0
0
1
1
0
39
0
0
1
0
0
1
1
1
 
M
M
M
M
M
D
D
D
Since the first five bits match, the networks can be summarized into one network (192.168.32.0/21 or 192.168.32.0 255.255.248.0). All eight possible combinations of the three low-order bits are relevant for the network ranges. The wildcard address that would match all of these subnet addresses can be written as 192.168.32.0 255.255.248.0.
Wildcard addresses are similar to routing access list wildcard masks. You add routing access lists containing wildcard masks using the config router access list command. However, router access list wildcard masks use the inverse of the masking system used for firewall wildcard addresses. For the router access list wildcard masks, zero (0)means match all IP addresses and one (1)means ignore all IP addresses. So to match IP addresses 192.168.0.56, 192.268.1.56, 192.168.2.56,... 192.168.255.56 you would use the following router access IP address prefix and wildcard mask: 192.168.0.56 0.0.255.0.
Wildcard firewall addresses are configured only in the CLI. The following is an example of how to configure a wildcard firewall address.
config firewall address
edit example_wildcard_address
set type wildcard
set wildcard 192.168.0.56 255.255.0.255
end