Introduction to Subnetting 

Intro to Subnetting by Aaron G. Rombaut

Introduction: Subnetting is a way for network administrators to use available network address space without waste. A general rule of thumb in networking is to remember a subnet = broadcast domain = vlan.

Discussion: An IPv4  address consists of four octets in dotted decimal notation. Each octet contains eight bits ranging in value from 0 to 255. A common IPv4 address many home users may be familiar with is 192.168.1.1. This by itself is called a host or node address. This address is given to a network node on a network and identifies it. It is a made up number given by a network administrator and resides at layer 3 of the OSI model. With the information given, however, we don’t know the network it resides on.

In order to find out the network the host address is on, we need to know the subnet mask. A common subnet mask home users may be familiar with is 255.255.255.0. Once we have the IP address and the subnet mask, it’s simply a matter of performing a binary calculation.

Tip: When you see a ‘255’ in a subnet mask, you carry the octet value from the IP address

Tip: When you see a ‘0’ in a subnet mask, you mark that octet with a ‘0’

Example: Using the 192.168.1.1 IP address and 255.255.255.0 subnet mask, I will demonstrate the tips given.

IP Address: 192.168.1.1
Subnet Mask: 255.255.255.0
Network Address: 192.168.1.0

A more difficult example would be as follows:

IP Address: 192.168.1.45
Subnet Mask: 255.255.255.248

The subnet mask given here is a subnet of the previous example. Notice that the last octet of the subnet mask has increased from 0 to 248. This increase indicates that the network administrator has borrowed host bits to make the network smaller.

A visual representation of 255.255.255.0 is nnnnnnnn.nnnnnnnn.nnnnnnnn.hhhhhhhh where ‘n’ represents network bits and ‘h’ represents host bits. A visual representation of the subnetted network’s subnet mask is nnnnnnnn.nnnnnnnn.nnnnnnnn.nnnnnhhh. Notice that in the fourth octet, there are five ‘n’ bits and only three ‘h’ bits? This indicates that the administrator ‘borrowed’ host bits to make a smaller network.

To calculate the Network Address here, the first tip still applies, you still carry the 192.168.1 part of the address since the subnet mask in those lined up octets are 255. Where it gets interesting is the fourth octet. This is actually called the interesting octet.

As mentioned in the beginning, an IP address is made up of four octets in dotted decimal notation. Each octet contains eight bits ranging from 0 to 255. I will break this up to illustrate.

First layout your eight bit placeholders.

_  _  _  _  _  _  _  _

The value of each of these placeholders is as follows, 128 64 32 16 8 4 2 1. Since bits are binary, you can only use a ‘1’ or a ‘0’. In order to convert the decimal number 45 given in the example to binary, you simply mark the appropriate value in the placeholder that gives you the sum. For instance, 128 does not go in 45, so you would mark a ‘0’ in the ‘128’ placeholder. 64 also does not go in 45, so again, you would mark a ‘0’. 32 does go into 45, so in this case, you would place a ‘1’ in the 32 placeholder. You continue doing this until you have met the decimal number. If there are any open placeholders to the right, you finish them with ‘0’.

The binary representation for decimal 45 is 00101101. This is the hardest part of learning how to subnet.

For subnet masks, it’s much easier as the bits have to be contiguous. This means that you will not have an octet consisting of 1, 0, and then more ones. Remember the range for an octet is 0 to 255. A ‘0’ octet is where all binary bits are turned off. So, the binary representation of decimal ‘0’ is 00000000. A ‘255’ octet is where all binary bits are turned on. So, the binary representation of decimal ‘255’ is 11111111. Since subnet masks consist of contiguous ‘1’, then there is a finite number of addresses to remember.

Tip: remember the eight permutations for subnet masks

128.0.0.0 (128 + 0 + 0 + 0 + 0 + 0 + 0 + 0)
192.0.0.0 (128 + 64 + 0 + 0 + 0 + 0 + 0 + 0)
224.0.0.0 (128 + 64 + 32 + 0 + 0 + 0 + 0 + 0)
240.0.0.0 (128 + 64 + 32 + 16 + 0 + 0 + 0 + 0)
248.0.0.0 (128 + 64 + 32 + 16 + 8 + 0 + 0 + 0)
252.0.0.0 (128 + 64 + 32 + 16 + 8 + 4 + 0 + 0)
254.0.0.0 (128 + 64 + 32 + 16 + 8 + 4 + 2 + 0)
255.0.0.0 (128 + 64 + 32 + 16 + 8 + 4 +2 + 1 )

Putting it all together: So now that we know our binary representation for decimal 45, we also know our binary representation for the subnet mask. Place the binary 45 above the binary 248. From here, you will apply binary AND rules to get the result. The result of this operation is the network (or subnet) address.

00101101 – 48
11111000 – 248

Tip: When you see a ‘1’ and a ‘1’, the result is ‘1’
Tip: When you see a ‘1’ and a ‘0’, the result is ‘0’
Tip: When you see a ‘0’ and a ‘0’, the result is ‘0’

The result of the above calculation is 00101000. Now you convert this back to decimal. 0 + 0 + 32 + 0 + 8 + 0 + 0 + 0 = 40, therefore, the network address is 192.168.1.40 for the IP Address 192.168.1.45 with a subnet mask of 255.255.255.248. Easy, right?

Learning the Magic Number Method

Remember when I said to learn the eight subnet mask permutations? It’s going to be very important for quickly finding subnetting answers. This method does not require you to convert decimal to binary and then back to decimal.

Let’s use the following example:
IP Address: 192.168.20.34
Subnet Mask: 255.255.255.224

First, lay out the eight permutations again:
128 192 224 240 248 252 254 255

Next, lay out the octet placeholder values:
128 64 32 16 8 4 2 1

Let me also mention that the tips regarding ‘255’ or ‘0’ in the subnet mask still apply to figuring out the network address.

So, with what we know up to this point, we have the network address as 192.168.20.something. The something in this case is our interesting octet as well. The subnet mask is where we will focus our attention. Notice that the fourth octet in the subnet mask is ‘224’? Now look at what place this is in with regards to an octet, in this case the third place from the left. We always work from left to right, the most significant bit (MSB) to least significant bit (LSB). The third value of the octet is ’32’, so in a zero-based network (the router uses the ‘0’ subnet), you would have:

0
32
64
96

256

Basically, you start with ‘0’ and count in intervals from your ‘magic number’. The magic number is the value of the placeholder where your subnet mask is. You are looking for the number before the interesting octet value of the IP Address, in this case ’34’, and the value after. So in this case, ’34’ is between ’32’ and ’64’, therefore our Network Address is 192.168.20.32.
If you are on a test and forget your octet values, you can simply deduct the value of the subnet octet from 256. The reason you use 256 is because there are 256 possible values including zero. In our example, 256 – subnet octet value of 224 = 32. This is our magic number and also the number you increment by. See, the magic number method is tons easier and much faster, especially when you are sitting for a networking certification!

Practice Questions

Decimal to Binary Conversions
23
223
255
123
12

Binary to Decimal Conversions
00100010
11111111
10101010
11010110
11001100

Binary AND Operations
11010110
11101010

10101010
11110101

10100111
11010110

11010101
10111011

11000011
11111100

Find the Network Address

IP Address: 192.168.1.234
Subnet Mask: 255.255.255.0

192.168.168.23
255.255.255.128

172.10.10.123
255.255.0.0

10.25.123.47
255.0.0.0

10.10.20.30
255.255.255.252

Using Local SPAN to Troubleshoot and Resolve Problems

A Switched Port Analyzer, or SPAN, is a way that you can monitor traffic. Back when networks used hubs, all traffic was visible because a hub just repeated the traffic out every port except the one it came in on. When switches were introduced, SPAN functionality was introduced to accommodate.

It is common to set a SPAN port up to a device with Wireshark to analyze network traffic. If you are going to monitor the traffic from a single management workstation, you will need two network interfaces cards (NIC) since SPAN traffic is not able traverse the same line as data. If you are only using the management station to monitor the traffic, you can use the single NIC. SPAN actually copies the data from one port to another that you specify. You can monitor egress traffic, ingress traffic, or a combination of the two.

Configure

When you configure a SPAN session, your source and destination ports cannot be the same. You will configure the source, what you want to monitor, to a destination interface, where you will monitor. The following is an example of the syntax you would use to configure a SPAN session.

Switch#configure terminal
Switch(config)#monitor session session-id source interface-id
Switch(config)#monitor session session-id destination interface-id

Verify

Switch#show monitor

ICMP Echo-Based IP SLA

Internet Control Message Protocol (ICMP) is a commonly used utility to test Layer 3 connectivity between devices. A Service Level Agreement (SLA) is a target that must be met; there is no set criteria for an SLA. ICMP echo-based IP SLA is a way to monitor end-to-end response time between Cisco devices using IPv4 or IPv6. According to Cisco, “Response time is computed by measuring the time taken between sending an ICMP Echo request message to the destination and receiving an ICMP Echo reply.” Using IP SLA ICMP echo to test far-end devices is much more practical than pinging manually.

Configure

Router#configure terminal
Router(config)#ip sla operation-number
Router(config-ip-sla)#icmp-echo {destination-ip-address | destination-hostname} [source-ip {ip-address | hostname} | source-interface interface-name
Router(config-ip-sla-echo)#frequency 300
Router(config-ip-sla-echo)#end

The ‘ip sla operation-number’ begins configuration for an IP SLA operation and enters IP SLA configuration mode. Icmp-echo defines an ICMP Echo operation and enters IP SLA ICMP Echo configuration mode.  The frequesncy sets the rate at which a specified IP SLAs operation repeats.

Verify

You can verify the IP SLA configuration with the following show commands.

show ip sla configuration
show ip sla statistics

Reference


https://www.cisco.com/c/en/us/td/docs/ios-xml/ios/ipsla/configuration/15-mt/sla-15-mt-book/sla_icmp_echo.html

CCNA ICND2 Study Guide, 3rd Edition by Todd Lammle

Add and Remove VLANs on a Trunk

Where access ports allow for only one data VLAN and one voice VLAN, a trunk port can carry one or more VLANs. Generally, you would use a trunk to connect switches together where you need to carry traffic. In some cases, you would configure a trunk port to connect to a server, such as a virtual server. If the device needs to use more than one VLAN, then you will want to configure the port as a trunk port.

Configure

The following commands will set up the interface to trunk mode exclusively. This will turn off Dynamic Trunking Protocol (DTP). Depending on the hardware you are on, you may need to set the encapsulation mode. Most newer equipment and code should default to using 802.1Q encapsulation, though.

Switch#configure terminal
Switch(config)#interface interface-id
Switch(config-if)#switchport trunk encapsulation {dot1q | isl}
Switch(config-if)#switchport mode trunk

In order to add and remove VLANs on a trunk, you need to go to the interface and specify whether you want to add or remove VLANs.

To add one or more VLANs to the trunk:

Switch#configure terminal
Switch(config)#interface interface-id
Switch(config-if)#switchport trunk allowed vlan add vlan-id,vlan-id,vlan-id

To remove one or more VLANs from the trunk, you replace the add parameter with remove. It may appear odd that the allowed parameter is in the command but think of it like this, you are removing an allowed VLAN from the trunk.

Switch#configure terminal
Switch(config)#interface interface-id
Switch(config-if)#switchport trunk allowed vlan remove vlan-id,vlan-id,vlan-id

Verify

To verify what interfaces are trunks and what VLANs are configured, you would use the following command:

Switch#show interfaces trunk

You may also want to check the switchport configuration for the interface.

Switch#show interfaces interface-id switchport
Name: interface-id
Switchport: Enabled
Administrative Mode: trunk
Operational Mode: trunk
Administrative Trunking Encapsulation: dot1q
Operational Trunking Encapsulation: dot1q
Negotiation of Trunking: On
Access Mode VLAN: 1 (default)
Trunking Native Mode VLAN: 1 (default)
Voice VLAN: none
Administrative private-vlan host-association: none
Administrative private-vlan mapping: none
Administrative private-vlan trunk native VLAN: none
Administrative private-vlan trunk encapsulation: dot1q
Administrative private-vlan trunk normal VLANs: none
Administrative private-vlan trunk private VLANs: none
Operational private-vlan: none
Trunking VLANs Enabled: All
Pruning VLANs Enabled: 2-1001
Capture Mode Disabled
Capture VLANs Allowed: ALL
Protected: false
Unknown unicast blocked: disabled
Unknown multicast blocked: disabled
Appliance trust: none

Troubleshoot

When you try to set the interface to trunk mode, you may encounter an error message regarding the trunk encapsulation. This occurs on older hardware, but you may still see it. You just need to set the trunk encapsulation first, then go back to configuring the interface as a trunk.

Switch(config-if)#switchport mode trunk
Command rejected: An interface whose trunk encapsulation is "Auto" can not be configured to "trunk" mode.

Trunks will carry multiple VLANs only if they are created. If you look at the output of the show interfaces trunk command and do not see the VLANs you expect, ensure the VLANs are created on the device.

Assigning Switch Ports to VLANs

Interfaces on Cisco switches can belong to two VLANs, one for data traffic and one for voice traffic. You set the interface to be an access port. This also turns off trunking and VLAN Trunking Protocol (VTP).

Configure

The following command will configure an access port. An access port is intended for data traffic.

Switch#configure terminal
Switch(config)#interface interface-id
Switch(config-if)#switchport mode access
Switch(config-if)#switchport access vlan vlan-id

In order to configure a voice VLAN, you follow the exact same procedure as above, but this time, use the voice vlan keyword in place of the access keyword. The following command will configure a voice port. A voice port is intended for voice traffic.

Switch#configure terminal
Switch(config)#interface interface-id
Switch(config-if)#switchport voice vlan vlan-id

Verify

The following command will output switchport statistics for the interface you choose.

Switch#show interfaces interface-id switchport

The above command will output the following:

Name: interface-id
Switchport: Enabled
Administrative Mode: static access
Operational Mode: static access
Administrative Trunking Encapsulation: negotiated
Operational Trunking Encapsulation: native
Negotiation of Trunking: Off
Access Mode VLAN: vlan-id (vlan-name)
Trunking Native Mode VLAN: 1 (default)
Voice VLAN: vlan-id

You can also look at the running-config output for the interface.

!
interface interface-id
switchport access vlan vlan-id
switchport mode access
switchport nonegotiate
switchport voice vlan vlan-id
!

Troubleshooting

An issue you may run into is seeing  an inactive VLAN entry when you check the status of the switchport.

Switch#show interfaces interface-id switchport
Name: interface-id 
Switchport: Enabled 
Administrative Mode: static access 
Operational Mode: static access 
Administrative Trunking Encapsulation: negotiated 
Operational Trunking Encapsulation: native 
Negotiation of Trunking: Off 
Access Mode VLAN: vlan-id (inactive) 
Trunking Native Mode VLAN: 1 (default) 
Voice VLAN: vlan-id

This occurs when a VLAN was assigned to an interface and then the VLAN was deleted. This could be a result of administrative error or with configuring a protocol like VLAN Trunking Protocol (VTP). If you are not careful, you could plug a switch into the network that will delete the current vlan.dat file. When the VLAN is deleted, the assigned VLAN does not go away. As you can see from the above output, you can see that where the name of the VLAN is usually displayed, instead, you see the word inactive. No traffic flows and the packets are dropped.

Default Virtual Local Area Network (VLAN)

The default virtual local area network (VLAN) is 1 by default on any Cisco switch. It is a special VLAN in that it cannot be changed or deleted. It is a management VLAN that carries control protocols such as Cisco Discovery Protocol (CDP), VLAN Trunking Protocol (VTP), Port Aggregation Protocol (PagP), and Dynamic Trunking Protocol (DTP).

The default VLAN is different than the native VLAN. The native VLAN is a VLAN in which traffic is not tagged in a trunk.

Configure

There isn’t anything to configure for the default VLAN since VLAN 1 is the default VLAN out of the box and is a mandatory VLAN.

Verify

You can verify the default VLAN by typing in the following:

Switch#show vlan

The above command will display the following:

VLAN  Name             Status    Ports
----  ---------------- --------- -------------------
1     default          active    Fa0/1, Fa0/2, Fa0/3

To view the native vlan, you would look at the trunk properties of the interface.

Switch#show interfaces interface-id switchport

This will display the interface switchport information containing VLAN information. This particular line will display the native vlan:

Trunking Native Mode VLAN: 1 (default)

 

Link State Advertisements (LSA) Types

Routers have to agree on certain parameters (such as timers and being on a common subnet) before they can become neighbors. After its neighbor routers are discovered, the router determines whether it should exchange routes with those neighbors. (If they decide to do so, they become adjacent.) If they are adjacent, they begin to exchange information about networks (links) it knows about, using messages called link state advertisements (LSA). After exchanging all routes, the routers send out updates only when there is a change, and they send information only for that affected link, not the entire routing table.

LSA 1 — Router LSA — Generated by all routers in an area to describe their directly attached links (Intra-area routes). These do not leave the area.

LSA 2 — Network LSA — Generated by the designated router (DR) of a broadcast or non-broadcast segment to describe the neighbors connected to the segment. These do not leave the area.

LSA 3 — Summary LSA — Generated by the area border router (ABR) to describe a route to neighbors outside the area. (Intra-area routes)

LSA 4 — Summary LSA — Generated by the area border router (ABR) to describe a route to an autonomous system boundary router (ASBR) to neighbors outside the area.

LSA 5 — External LSA — Generated by autonomous system boundary router (ASBR) to describe routes redistributed into the area. These routes appear as E1 or E2 in the routing table. Listed as E1 or E2 in the route table.

LSA 6 — Multicast LSA — Not supported on Cisco routers

LSA 7 — Not-So-Stubby Area (NSSA) External LSA — Generated by an autonomous system boundary router (ASBR) inside a not-so-stubby area to describe routes redistributed into the not-so-stubby area. LSA 7 is translated into LSA 5 by area border router (ABR). Appear as N1 or N2 in the routing table.

References


  • Cisco CCNA Routing and Switching 200-120 Exam Cram, Fourth Edition by Michael Valentine and Keith Barker
  • OSPF LSA Types document originally located at http://www.ccietalk.com/2008/07/13/ospf-lsa-types and retrieved on December 6, 2017 from https://learningnetwork.cisco.com/docs/DOC-7994