Touch with us for Information Technology Solutions. Email us for your Query on Technical.gaurav@gmail.com.
Propellerads
Showing posts with label cisco. Show all posts
Showing posts with label cisco. Show all posts

08/09/2013

EIGRP Tutorials

EIGRP Tutorials


In this article we will mention about the EIGRP protocol.
Enhanced Interior Gateway Routing Protocol (EIGRP) is a Cisco-proprietary routing protocol. EIGRP is a classless routing protocol, meaning that it sends the subnet mask of its interfaces in routing updates, which use a complex metric based on bandwidth and delay.
EIGRP is referred to as a hybrid routing protocol because it has the characteristics of both distance-vector and link-state protocols but now Cisco refers it as an advanced distance vector protocol.
Notice: the term “hybrid” is misleading because EIGRP is not a hybrid between distance vector and link-state routing protocols. It is a distance vector routing protocol with enhanced features.
EIGRP is a powerful routing protocol and it is really standout from its ancestor IGRP. The main features are listed below:
+ Support VLSM and discontiguous networks
Use Reliable Transport Protocol (RTP) to delivery and reception of EIGRP packets
+ Use the best path selection Diffusing Update Algorithm (DUAL), guaranteeing loop-free paths and backup paths throughout the routing domain
Discover neighboring devices using periodic Hello messages to discover and monitor connection status with its neighbors
+ Exchange the full routing table at startup and send partial* triggered updates thereafter (not full updates like distance-vector protocols) and the triggered updates are only sent to routers that need the information. This behavior is different from the link-state protocol in which an update will be sent to all the link-state routers within that area. For example, EIGRP will send updates when a new link comes up or a link becoming unavailable
Supports multiple protocols: EIGRP can exchange routes for IPv4, IPv6, AppleTalk and IPX/SPX networks
Load balancing: EIGRP supports unequal metric load balancing, which allows administrators to better distribute traffic flow in their networks.
* Notice: The term “partial” means that the update only includes information about the route changes.
EIGRP use metrics composed of bandwidth, delay, reliability, and load. By default, EIGRP uses only bandwidth and delay.
EIGRP use five types of packets to communicate:
Hello: used to identify neighbors. They are sent as periodic multicasts
Update: used to advertise routes, only sent as multicasts when something is changed
Ack: acknowledges receipt of an update. In fact, Ack is Hello packet without data. It is always unicast and uses UDP.
Query: used to find alternate paths when all paths to a destination have failed
Reply: is sent in response to query packets to instruct the originator not to recompute the route because feasible successors exist. Reply packets are always unicast to the originator of the query
EIGRP sends every Query and Reply message using RTP, so every message is acknowledged using an EIGRP ACK message.
EIGRP Route Discovery
Suppose that our network has 2 routers and they are configured to use EIGRP. Let’s see what will happen when they are turned on.
Firstly, the router will try to establish a neighboring relationships by sending “Hello” packets to others running EIGRP. The destination IP address is 224.0.0.10 which is the multicast address of EIGRP. By this way, other routers running EIGRP will receive and proceed these multicast packets. These packets are sent over TCP.
EIGRP_initial_route_discovery.jpg
After hearing “Hello” from R1, R2 will respond with another “Hello” packet.
EIGRP_initial_route_discovery_2.jpg
R2 will also send its routing table to R1 by “Update” packets. Remember that R2 will send its complete routing table for the first time.
EIGRP_initial_route_discovery_3.jpg
R1 confirms it has received the Update packet by an “ACK” message.
EIGRP_initial_route_discovery_4.jpg
R1 will also send to R2 all of its routing table for the first time
EIGRP_initial_route_discovery_5.jpg
R2 sends a message saying it has received R1′s routing table.
EIGRP_initial_route_discovery_6.jpg
Now both R1 & R2 learn all the paths of the neighbor and the network is converged. But there are some notices you should know:
+ After the network converged, “Hello” messages will still be sent to indicate that the it is still alive.
+ When something in the network changes, routers will only send partial updates to routers which need that information.
+ Hellos are sent as periodic multicasts and are not acknowledged directly.
+ The first hellos are used to build a list of neighbors; thereafter, hellos indicate that the neighbor is still alive
To become a neighbor, the following conditions must be met:
+ The router must hear a Hello packet from a neighbor.
+ The EIGRP autonomous system must be the same.
+ K-values must be the same.
EIGRP builds and maintains three tables:
+ Neighbor table: lists directly connected routers running EIGRP with which this router has an adjacency
+ Topology table: lists all routes learned from each EIGRP neighbor
+ Routing table: lists all best routes from the EIGRP topology table and other routing processes
Configuring EIGRP
Router(config)#router eigrp 1
Syntax: router eigrp <AS number>
Turn on the EIGRP process
1 is the Autonomous System (AS) number. It can be from 1 to 65535.
All routers in the same network must use the same AS number.
Router(config-router)#network 192.168.1.0
Router will turn on EIGRP 1 process on all the interfaces belonging to 192.168.1.0/24 network.
In the next part we will learn about the Feasible Distance & Administrative Distance of EIGRP

Feasible Distance (FD) and Advertised Distance (AD)
In the next part, we will define these terms and take an example to make them clear.
Advertised distance (AD): the cost from the neighbor to the destination.
Feasible distance (FD): The sum of the AD plus the cost between the local router and the next-hop router
Successor: The primary route used to reach a destination. The successor route is kept in the routing table. Notice that successor is the best route to that destination.
Feasible successor: The backup route. To be a feasible successor, the route must have an AD less than the FD of the current successor route
Maybe it’s a bit confused with these terms so below is an example to make it clear.
EIGRP_metric.jpg
Suppose you are in NEVADA and want to go to IOWA. From NEVADA you need to specify the best path (smallest cost) to IOWA.
In this topology, suppose router A & B are exchanging their routing tables for the first time. Router B says “Hey, the best metric (cost) from me to IOWA is 50 and the metric from you to IOWA is 90″ and advertises it to router A. Router A considers the first metric (50) as the Advertised distance. The second metric (90), which is from NEVADA to IOWA (through IDAHO), is called the Feasible distance.
NEVADA also receives the cost path from NEVADA -> OKLAHOMA -> IOWA advertised by router C with the Advertised distance of 70 and Feasible distance of 130.
All of these routes are placed in the topology table of router A:
RouteAdvertised distanceFeasible distance
NEVADA -> IDAHO -> IOWA5090
NEVADA -> OKLAHOMA -> IOWA70130
Router A will select the route to IOWA via IDAHO as it has the lowest Feasible distance and put it into the routing table.
The last thing we need to consider is if the route NEVADA -> OKLAHOMA -> IOWA will be considered as a feasible successor. To achieve this, it must satisfy the feasibility condition:
To qualify as a feasible successor, a router must have an AD less than the FD of the current successor route
Maybe you will ask “why do we need this feasibility condition?” Well, the answer is because it guarantees a loop-free path to the destination; in other words, it must not loop back to the current successor.
If the route via the successor becomes invalid (because of a topology change) or if a neighbor changes the metric, DUAL checks for feasible successors to the destination route. If one is found, DUAL uses it, avoiding the need to recompute the route as the re-computation can be processor-intensive. If no suitable feasible successor exists, a re-computation must occur to determine the new successor.
EIGRP calls these alternative, immediately usable, loop-free routes feasible successor routes, because they can feasibly be used as a new successor route when the current successor route fails. The next-hop router of such a route is called the feasible successor.
In this case, the route NEVADA -> OKLAHOMA -> IOWA has an AD (70) less than the FD of the successor route (90) so it becomes the feasible successor route.
Of course in some cases the feasibility condition will wrongly drop loop-free paths. For example, if the metric between OKLAHOMA and IOWA is greater than 90 then the route NEVADA -> OKLAHOMA -> IOWA will not be considered as a feasible successor route although it is loop-free. But this condition is necessary because it can guarantee the feasible successor routes are loop-free.
Notice that the feasible successors are placed in the topology table, not in the routing table.
Now router A has 3 complete tables as follows (we only consider route to IOWA network)
EIGRP_neighbor_table.jpg
EIGRP_topology_table.jpg
EIGRP_routing_table.jpg
Now you have a basic concept of EIGRP, in the next part we will dig into the 3 tables of EIGRP – the neighbor, topology & routing tables as understanding them is a requirement for a CCNA-taker and learn how to calculate the metric of EIGRP.

EIGRP_3_tables_topology.jpg
Check the neighbor table of Router0 with the show ip eigrp neighbors command
EIGRP_R0_show_ip_eigrp.jpg
Let’s analyze these columns:
H: lists the neighbors in the order this router was learned
Address: the IP address of the neighbors
+ Interface: the interface of the local router on which this Hello packet was received
Hold (sec): the amount of time left before neighbor is considered in “down” status
Uptime: amount of time since the adjacency was established
SRTT (Smooth Round Trip Timer): the average time in milliseconds between the transmission of a packet to a neighbor and the receipt of an acknowledgement.
RTO (Retransmission Timeout): if a multicast has failed, then a unicast is sent to that particular router, the RTO is the time in milliseconds that the router waits for an acknowledgement of that unicast.
Queue count (Q Cnt): shows the number of queued EIGRP packets. It is usually 0.
Sequence Number (Seq Num): the sequence number of the last update EIGRP packet received. Each update message is given a sequence number, and the received ACK should have the same sequence number. The next update message to that neighbor will use Seq Num + 1.
As CCNA level, we only care about 4 columns: Address, Interface, Hold & Uptime. Other columns will be discussed in CCNP so you don’t need to remember them now!
EIGRP_R0_show_ip_eigrp_analysis.jpg
Notice that you can see a line “IP-EIGRP neighbors for process 100″. “Process 100″ here means “AS 100″.
Next we will analyze the EIGRP topology with the show ip eigrp topology command. The output of Router0 is shown below
EIGRP_R0_show_ip_eigrp_topology.jpg
The letter “P” as the left margin of each route entry stands for “Passive”. Passive state indicates that the route is in quiescent mode, implying that the route is known to be good and that no activities are taking place with respect to the route.
Each route shows the number of the successor it has. For example, the network 192.168.2.0, 192.168.1.0,192.168.3.0 & 192.168.4.0 have only 1 successor (and no feasible successor). Only network 192.168.5.0 has 2 successors.
We notice that there are 2 numbers inside the brackets (30720/28160). The first one is the metric from Router0 to the destination, the second is the AD of this route, advertised by the neighbor. For example, the third route entry has:
EIGRP_R0_show_ip_eigrp_topology_third_entry.jpg
Let’s see how to calculate them!
First you should learn the formula to calculate the metric. It’s a bit complex, I think :)
metric = [K1 * bandwidth + (K2 * bandwidth)/(256 - load) + K3 * delay] * [K5/(reliability + K4)]
Note: you can check these K values with the “show ip protocols” command. Below is an example of this command on Router0.
EIGRP_R0_show_ip_protocols.jpg
To change these values, use the “metric weights tos k1 k2 k3 k4 k5″ in the EIGRP router mode.
By default, K1 = 1, K2 = 0, K3 = 1, K4 = 0, K5 = 0 which means that the default values use only bandwidth & delay parameters while others are ignored. The metric formula is now reduced:
metric = bandwidth + delay
But the bandwidth here is defined as the slowest bandwidth in the route to the destination & delay is the sum of the delays of each link. Here is how to calculate the EIGRP metric in detail:
EIGRP_fomula.jpg
EIGRP uses the slowest bandwidth of the outgoing interfaces of the route to calculate the metric. In this case we need to find out the bandwidth of Fa0/0 of Router0 & Fa0/1 of Router1 as the destination network is 192.168.3.0/24.
EIGRP_3_tables_topology_outgoing_interfaces.jpg
Find the bandwidth
We can find the bandwidth of each interface by the “show interfaces “. Below is an output of the “show interfaces fa0/0″ on Router0.
EIGRP_R0_show_interfaces_fa0_0.jpg
All the interfaces in this topology have the bandwidth of 100,000 Kbps so we will get the same result on interface Fa0/1 of Router1 -> The slowest bandwidth here is 100,000 Kbps. Now we can calculate the first portion of the formula:
EIGRP_fomula_first_portion.jpg
Notice that if the result is not an integer then the result will be rounded down. For example, 10,000,000 divided by 1024 (the speed of T1) equals 9765.625. The result will be rounded down to 9765.
Find the delay
EIGRP also used the delay of the outgoing interfaces and it can also be found with the “show interfaces “, the delay lies next to the bandwidth value (for example, DLY 100usec). In this case, the delay value of both Fa0/0 of Router0 & Fa0/1 of Router1 is 100 usec (microsecond) so the sum of delay is 100 + 100 = 200 usec. The second portion of the formula is:
EIGRP_fomula_second_portion.jpg
Get the metric
Now just sum up two portions of the formula and multiplied by 256 to get the result:
EIGRP_fomula_result.jpg
The result is 30720 and it matches the value shown in the topology table of the route to 192.168.3.0/24
EIGRP_R0_show_ip_eigrp_topology_match.jpg
Using the formula above, we can easily calculate the AD of that route (with slowest bandwidth = 100,000Kpbs; sum of delay = 10)
metric = (100 + 10) * 256 = 28160
This metric matches with the second parameter of the above route.
Note: The output of “show ip eigrp topology” command shows only feasible successors while the output of “show ip eigrp topology all-links” shows all neighbors, whether feasible successors or not. To learn more about the “show ip eigrp topology all-links” please read http://www.digitaltut.com/route-eigrp-simlet. Although it belongs to CCNP exam but CCNA level can read it too.
EIGRP Routing table
The last table we will discuss is the routing table. This is the most used table to check the operation of EIGRP. Here is the output of the show ip routecommand on Router0:
EIGRP_R0_show_ip_route.jpg
The routing table has two parameters [90/30720] but the first one is the administrative distance of EIGRP. EIGRP has a default administrative distance of 90 for internal routes and it is often the most preferred routing protocol because it has the lowest administrative distance.
Administrative distance is the measure used by Cisco routers to select the best path when there are two or more different routes to the same destination from two different routing protocols.
Below is the administrative distances of the most popular routing protocols used nowadays. Notice that the smaller is the better.
EIGRP_Administrative Distances_popular_routing_protocols.jpg
So, if a network running two routing protocols at the same time, for example EIGRP and OSPF, which routing protocol will the router choose? Well, the answer is EIGRP as it has lower Administrative Distance than OSPF ( 90 < 110).
The second parameter, as you can guess, is the metric of that route as we discussed above.
“no auto-summary” with EIGRP
One of the features of EIGRP is “support VLSM and discontiguous networks”. Discontiguous networks are networks that have subnets of a major network separated by a different major network. Below is an example of discontiguous networks where subnets 10.10.1.0/24 and 10.10.2.0/24 are separated by a 2.0.0.0/8 network.
EIGRP_discontiguous_network_1.jpg
Now let’s see what will happen when we turn on EIGRP on both of the routers. To turn on EIGRP you will use these commands:
R1(config)#router eigrp 1
R1(config-router)#network 2.0.0.0
R1(config-router)#network 10.10.1.0 (or network 10.0.0.0)
R2(config)#router eigrp 1
R2(config-router)#network 2.0.0.0
R2(config-router)#network 10.10.2.0 (or network 10.0.0.0)
You can try to use the more specific “network 10.10.1.0″ instead of “network 10.0.0.0″, hoping that EIGRP will understand it is a sub-network. But if we check the configuration with the “show running-config” command we will notice that EIGRP has auto-summarized our network.
R1#show running-config
EIGRP_discontiguous_network_show_run_R1.jpg
-> Network 10.10.1.0 has been summarized to network 10.0.0.0 because it knows 10.x.x.x network belongs to class A.
The same thing happens for R2. Now we should check the routing table of R1 with the “show ip route” command
R1#show ip route
EIGRP_discontiguous_network_show_ip_route_R1.jpg
From the output above we learn that R1 only knows about the directly connected 10.10.1.0/24 network but it doesn’t have any information about the far-away 10.10.2.0/24 network and a ping to 10.10.2.1 cannot be successful (but notice that we can ping to that directly connected network, 10.10.1.2, for example).
So we can conclude that if a router receives the same route with what it is advertising then it will not learn that route. In the above example, the “collision” occurs because both of the routers summarize into network 10.0.0.0/8 and advertise it to other router. The neighboring router realizes that it is also advertising this network so it drops this network information.
Now if we use the “no auto-summary” command on both routers then the problem will surely be solved but first let’s try to use that command only on R1 router.
R1(config)#router eigrp 1
R1(config-router)#no auto-summary
R1#show ip route
EIGRP_discontiguous_network_show_ip_route_R1_no_auto_summary.jpg
-> Nothing changes!
R2#show ip route
EIGRP_discontiguous_network_show_ip_route_R2_no_auto_summary.jpg
-> R2 has just learned about the new “10.10.1.0/24″ network which is advertised from R1 so R2 can ping this network
EIGRP_discontiguous_network_ping_R1.jpg
In conclusion when we enable “no auto-summary” on R1 then R1 will advertise its network with their subnet mask so R2 can learn them correctly.

06/09/2013

Enhanced Interior Gateway Routing Protocol (EIGRP)

Overview of EIGRP

Enhanced Interior Gateway Routing Protocol (EIGRP) or Enhanced IGRP is a Cisco proprietary routing protocol utilizing the Diffusing Update Algorithm (DUAL). The DUAL algorithim was invented by Dr. J.J. Garcia-Luna Aceves of SRI International as an improvement to the IGRP routing protocol. EIGRP was designed to be interoperable with standard IGRP. EIGRP is a hybrid protocol as it incorporates features of a Distance Vector routing protocol and features of a Link State routing protocol. EIGRP is often used in Cisco-based networks running multiple network-layer protocols.
EIGRP can redistribute its routes (and metrics) intoother routing protocols and accepts redistribution from other routing protocols as well.

EIGRP Features

  • Hybrid Distance Vector/Link State algorithm
  • Supports VLSM (subnets/supernets)
  • Integrates seamlessly with IGRP
    • Automatic Redistribution of Routes (IGRP <-> EIGRP)
    • EIGRP metrics are 256 times the IGRP metric and therefore 'directly translatable'
  • Fast convergence
  • Performs Partial Updates as needed
  • Consumes less bandwidth (no broadcasts, no periodic updates, updates contain only changes)
  • Supports multiple network layer protocols
    • Appletalk
    • Internet Protocol (IP)
    • Novell Netware (IPX/SPX)

    EIGRP Operation

    • Four EIGRP Components
      • Neighbor Discovery/Recovery
        • Dynamically find other routers running IGRP/EIGRP
        • Dynamically forms neighbor relationships
        • Discover neighbor state (unreachable or inoperative) - Uses HELLO packets
      • Reliable Transport Protocol - Utilizes Reliable Transport Protocol (RTP) for delivery of EIGRP packets.
      • DUAL Finite State Machine
      • Protocol Dependant Modules
    • EIGRP tracks all routes advertised by all neighbors (feasible successor routes)
      • Selects best path
      • Selects a feasible successor route
        • CISCO.COM: A feasible successor is a neighboring router used for packet forwarding that is a least-cost path to a destination that is guaranteed not to be part of a routing loop
      • If no feasible successor exists,
        • queries are sent out to the network
        • Diffusing computation is performed to select another feasible route
        • Diffusing computation is not processor intensive (but affects convergence time
    • Maintains a copy of each neighbor's route table.
    • Sends updates only when changes in the metrics occur
    • Sends only the changes
    • Sends changes only to neighbors that need the information (no broadcasts)
    • Can redistribute routes from RTMP, OSPF, RIP, IPX RIP/SAP, IS-IS, EGP and BGP
    • Routing
      • Administrative Distance for EIGRP
        • Summary Routes [5]
        • Internal Routes [90]
        • External Routes [170]
      • Neighbor Tables
        • Neighbors recorded (IP and interface of neighbor)
        • One neighbor table for each network protocol
        • Neighbors send hold time in HELLO packet
        • Hello packet contains hold down time
        • If neighbor is not heard from within the hold down time, topology table is changed via DUAL
        • Contains RTP information (Sequence Number, transmission list of packets, round trip timers optimize retransmission interval).
      • Topology Tables
        • Contains all destinations advertised by all neighboring routers
        • Each topology table entry contains:
          • destination address
          • list of neighbors used to reach the destination
          • for each neighbor store the advertised metric for each destination
          • Best Path = sum of best advertised metric from all neighbors and the link cost to the best neighbo
      • Feasible Successors
        • Route(s) inserted by EIGRP into the routing table will have the best metric of all the routes in the table.
        • Any route to a destination whose metric is less than the current entry or entries in the routing table is a feasible successor.
        • When the current route enters the 'active' state, the feasible successor is inserted in the routing table.
        • The list of feasible successors may have to be re-evaluated if a neighbor sends a topology change or updates the metric to a destination.
        • If a neighbor who is the only feasible successor to a destination goes down, all of the neighbor's routes enter the active state and trigger route recomputation.
      • Route States (two states)
        • Active - recomputation is being performed
        • Passive - no recomputation going on
        • If feasible successors are always available, a destination never goes into the active state.
        • Recomputation occurs when no feasible successor route exists
        • If a neighbor who is the only feasible successor to a destination goes down, all of the neighbor's routes enter the active state and trigger route recomputation.
        • Recomputation Process
          • Send a query packet to all neighboring routers
          • Neighbor sends
            • a reply that it has a feasible successor, or
            • a query packet to indicate it is partcipating in the recomputation
          • Routes in the active state cannot have their routing table information changed
          • Once all neighbors have replied the topology table entry for the destination returns to the pasive state and the router may then select a feasible successor.
      • Route Tagging
        • Internal routes come from neighbors with the same (E)IGRP AS number or from directly attached interfaces over which IGRP or EIGRP runs.
        • External routes come from other routing protocols or from static routes and are tagged with the following information:
          • Router ID of the router that distributed the route
          • AS number of the destination
          • Configurable administrator tag
          • ID of the external protocol
          • Metric from the external protocol
          • Bit flags for default routing

    EIGRP Message Types

    TypeTransmitSentFunction
    Hello
    MulticastHello messages are used for neighbor discovery and neighbor recovery. If a hello message is not received within the configured interval, all neighbor entries are removed from the routing table and feasible successor routes re utilized.
    UnicastReliablyHello messages are also used to acknowledge receipt of information. Zero byte acknowledgement (with ACK number)
    Updates
    UnicastReliablyNeighbor discovery
    MulticastReliablyLink cost or metric change updates
    QueriesMulticastReliablySent when one or more destinations enter the active state.
    RepliesUnicastReliablySent to originator of a query.
    RequestsMulticast or UnicastUnreliablyRequest specific information from neighbors

    EIGRP Configuration

    Basic EIGRP router configuration (Cisco)
    router(config)# router eigrp <AS number>
    Enable EIGRP routing and set the Autonomous System number.
    router(config-router)# network 192.168.0.0 0.0.255.255
    Configure the directly connected networks that will be advertised.

    EIGRP Troubleshooting

    show ip eigrp topology
    Shows only feasible successor routes
    show ip eigrp topology <network> 
    Shows all entries in the topology table for the given destination network.
    show ip eigrp topology all-links 
    Shows all entries in the topology table
    show ip eigrp topology [active | pending | zero successors ]
                 
    Show destinations that are in the active or pending states or have zero successors.
     



    01/09/2013

    Subnetting Tutorial ! I make it so Easy !!!!!

    <<<<<< Subnetting Tutorial >>>>>>>>

    The table below summarizes the possible network numbers, the total number of each type, and the number of hosts in each Class A, B, and C network.
     Default subnet maskRange
    Class A255.0.0.0 (/8)1.0.0.0 – 126.255.255.255
    Class B255.255.0.0 (/16)128.0.0.0 – 191.255.255.255
    Class C255.255.255.0 (/24)192.0.0.0 – 223.255.255.255
    Table 1 – Default subnet mask & range of each class
    Class A addresses begin with a 0 bit. Therefore, all addresses from 1.0.0.0 to 126.255.255.255 belong to class A (1=0000 0001; 126 = 0111 1110).
    The 0.0.0.0 address is reserved for default routing and the 127.0.0.0 address is reserved for loopback testing so they don’t belong to any class.
    Class B addresses begin with a 1 bit and a 0 bit. Therefore, all addresses from 128.0.0.0 to 191.255.255.255 belong to class B (128=1000 0000; 191 =1011 1111).
    Class C addresses begin with two 1 bits and a 0 bit. Class C addresses range from 192.0.0.0 to 223.255.255.255 (192 = 1100 0000; 223 = 1101 1111).
    Class D & E are used for Multicast and Research purposes and we are not allowed to subnet them so they are not mentioned here.
    Note: The number behind the slash notation (/) specifies how many bits are turned on (bit 1). For example:
    + “/8″ equals “1111 1111.0000 0000.0000 0000.0000 0000″ -> 8 bits are turned on (bit 1)
    + “/12″ equals “1111 1111.1111 0000.0000 0000.0000 0000″ -> 12 bits are turned on (bit 1)
    + “/28″ equals “1111 1111.1111 1111.1111 1111.1111 0000″ -> 28 bits are turned on (bit 1)
    + “/32″ equals “1111 1111.1111 1111.1111 1111.1111 1111″ -> 32 bits are turned on (bit 1) and this is also the maximum value because all bits are turned on.
    The slash notation (following with a number) is equivalent to a subnet mask. If you know the slash notation you can figure out the subnet mask and vice versa. For example, “/8″ is equivalent to “255.0.0.0″; “/12″ is equivalent to “255.240.0.0″; “/28″ is equivalent to “255.255.255.240″; “/32″ is equivalent to “255.255.255.255″.
    Class_A_B_C_network_host_portions.jpg
    The Network & Host parts of each class by default
    From the “default subnet mask” shown above, we can identify the network and host part of each class. Notice that in the subnet mask, bit 1 represents for Network part while bit 0 presents for Host part (255 equals to 1111 1111 and 0 equals to 0000 0000 in binary form).
    What is “subnetting”?
    When changing a number in the Network part of an IP address we will be in a different network from the previous address. For example, the IP address 11.0.0.1 belongs to class A and has a default subnet mask of 255.0.0.0; if we change the number in the first octet (a block of 8 bits, the first octet is the leftmost 8 bits) we will create a different network. For example, 12.0.0.1 is in a different network from 11.0.0.1. But if we change a number in the Host part, we are still in the same Network. For example, 11.1.0.1 is in the same network of 11.0.0.1.
    The problem here is if we want to create 300 networks how can we do that? In the above example, we can only create different networks when changing the first octet so we can create a maximum of 255 networks because the first octet can only range from 1 to 255 (in fact it is much smaller because class A only range from 1 to 126). Now we have to use a technique called “subnetting” to achieve our purpose.
    “Subnetting” means we borrow some bits from the Host part to add to the Network part. This allows us to have more networks than using the default subnet mask. For example, we can borrow some bits in the next octet to make the address 11.1.0.1 belong to a different network from 11.0.0.1.
    How to subnet?
    Do you remember that I said “in the subnet mask, bit 1 represents for Network part while bit 0 presents for Host part”? Well, this also means that we can specify how many bits we want to borrow by changing how many bit 0 to bit 1 in the subnet mask.
    Let’s come back to our example with the IP 11.0.0.1, we will write all numbers in binary form to reveal what a computer really sees in an IP address.
    Class_A_binary_form.jpg
    Now you can clearly see that the subnet mask will decide which is the Network part, which is the Host part. By borrowing 8 bits, our subnet mask will be like this:
    Class_A_subnet_binary_form.jpg
    After changing the second octet of the subnet mask from all “0″ to all “1″, the Network part is now extended. Now we can create new networks by changing number in the first or second octet. This greatly increases the number of networks we can create. With this new subnet mask, IP 11.1.0.1 is in different network from IP 11.0.0.1 because “1″ in the second octet now belongs to the Network part.
    So, in conclusion we “subnet” by borrowing bit “0″ in the Host portion and converting them to bit “1″. The number of borrowed bits is depended on how many networks we need.
    Note: A rule of borrowing bits is we can only borrow bit 0 from the left to the right without skipping any bit 0. For example, you can borrow like this: “1111 1111. 1100 0000.0000 0000.0000 0000″ but not this: “1111 1111. 1010 0000.0000 0000.0000 0000″. In general, just make sure all your bit “1″s are successive on the left and all your bit “0″s are successive on the right.

    Calculate how many networks and hosts-per-subnet
    In our example, you may raise a question: “when we borrow 8 bits, how many sub-networks and how many hosts per sub-network do it create?”
    Note: From now, we will call sub-networks “subnets”. This term is very popular so you should be familiar with it.
    How many new subnets?
    Because we can change any bit in the second octet to create a new subnet, each bit can be “0″ or “1″ so with this subnet mask (255.255.0.0) we can create 28 more subnets. From here we can deduce the formula to calculate the newly created subnets. Suppose n is the number of bits we borrow:
    The number of newly created subnets = 2n
    In our example, we borrow 8 bits so we will have 2n = 28 = 256 subnets!
    How many hosts per subnet?
    The number of hosts per subnet is depended on the Host part, which is indicated by the “0″ part of the subnet mask. So suppose k is the number of bits “0″ in the subnet mask. The formula to calculate the number of hosts is 2k. But notice that with each subnet, there are two addresses we can’t assign for hosts because they are used for network address & broadcast address. Thus we must subtract the result to 2. Therefore the formula should be:
    The number of hosts per subnet = 2k – 2
    In our example, the number of bit “0″ in the subnet mask 255.255.0.0 (in binary form) is 16 so we will have 2k – 2 = 216 – 2 = 65534 hosts-per-subnet!
    Some other examples
    Well, practice makes perfect so we should have some more exercises to be familiar with them. But remember that this is only the beginning in your journey to become a subnetting guru :)
    Exercise 1
    Your company has just been assigned the network 4.0.0.0. How many subnets and hosts-per-subnet you can create with a subnet mask of 255.255.255.0?
    (Please try to solve by yourself before reading the solution ^^)
    Solution
    First of all you have to specify which class this network belongs to. According to Table 1, it belongs to class A (simply, class A ranges from 1 to 126) and its default subnet mask is 255.0.0.0. Therefore if we use a subnet mask of 255.255.255.0, it means we borrowed 16 bits (to convert from 0 to 1).
    255.0.0.0 = 1111 1111.0000 0000.0000 0000.0000 0000
    255.255.255.0 = 1111 1111.1111 1111.1111 1111.0000 0000
    Now use our above formulas to find the answers:
    The number of newly created subnets = 216 = 65536 (with 16 is the borrowed bits)
    The number of hosts per subnet = 28 – 2 = 254 (with 8 is the bit “0″s left in the 255.255.255.0 subnet mask)
    Exercise 2
    Your company has just been assigned the network 130.0.0.0. How many subnets and hosts-per-subnet you can create with a subnet mask of 255.255.128.0?
    (Please try to solve by yourself before reading the solution ^^)
    Solution
    130.0.0.0 belongs to class B with the default subnet mask of 255.255.0.0. But is the subnet mask of 255.255.128.0 strange? Ok, let’s write all subnet masks in binary:
    255.255.128.0 = 1111 1111.1111 1111.1000 0000.0000 0000
    This is a valid subnet because all bit “1″s and “0″s are successive. Comparing to the default subnet mask, we borrowed only 1 bit:
    255.255.0.0 = 1111 1111.1111 1111.0000 0000.0000 0000
    Therefore:
    The number of newly created subnets = 21 = 2 (with 1 is the borrowed bits)
    The number of hosts per subnet = 215 – 2 = 32766 (with 15 is the bit “0″s left in the 255.255.128.0 subnet mask)
    Exercise 3
    Your company has just been assigned the network 198.23.16.0/28. How many subnets and hosts-per-subnet you can create with a subnet mask of 255.255.255.252?
    (Please try to solve by yourself before reading the solution ^^)
    Solution
    In this exercise, your company was given a “subnetted” network from the beginning and it is not using the default subnet mask. So we will compare two subnet masks above:
    /28 = 1111 1111.1111 1111.1111 1111.1111 0000 (=255.255.255.240)
    255.255.255.252 = 1111 1111.1111 1111.1111 1111.1111 1100 (= /30)
    In this case we borrowed 2 bits. Therefore:
    The number of newly created subnets = 22 = 4 (with 2 is the borrowed bits)
    The number of hosts per subnet = 22 – 2 = 2 (with 2 is the bit “0″s left in the 255.255.255.252 subnet mask)
    In this exercise I want to go a bit deeper into the subnets created. We learned there are 4 created subnets but what are they? To find out, we should write all things in binary:
    Class_C_binary_form.jpg
    Because two subnet masks (/28 & /30) only affect the 4th octet so we don’t care about the first three octets. In the 4th octet we are allowed to change 2 bits (in the green box) of the IP address to create a new subnet. So there are 4 values we can use: 00, 01, 10 & 11. After changing, we convert them back to decimal numbers. We get 4 subnets:
    + First subnet: 198.23.16.0/30 (the 4th octet is 00000000)
    + Second subnet: 198.23.16.4/30 (the 4th octet is 00000100)
    + Third subnet: 198.23.16.8/30 (the 4th octet is 00001000)
    + Fourth subnet: 198.23.16.12/30 (the 4th octet is 00001100)
    So how about hosts per subnet? Please notice that all these 4 subnets are successive. So we can deduce the range of these subnets:
    + First subnet: ranges from 198.23.16.0 to 198.23.16.3
    + Second subnet: ranges from 198.23.16.4 to 198.23.16.7
    + Third subnet: ranges from 198.23.16.8 to 198.23.16.11
    + Fourth subnet: ranges from 198.23.16.12 to 198.23.16.15
    Let’s analyze the first subnet which ranges from 198.23.16.0 to 198.23.16.3. Notice that all networks (and subnets) have a network address and a broadcast address. In this case, the network address is 198.23.16.0 and the broadcast address is 198.23.16.3 and they are not assignable or usable for hosts. This is the reason why we have to subtract 2 in the formula “The number of hosts per subnet = 2k – 2″. After eliminating these 2 addresses we have 2 addresses left (which are 198.23.16.1 & 198.23.16.2) as calculated above.

    In the previous examples, we have to write all subnet masks and IP addresses in binary numbers to find out the results. It is a boring and time-consuming task. In this part I will show you a shortcut to subnet without using a calculator or rough paper!
    Subnetting – The quick & easy way
    One important thing we should notice is that a valid subnet mask must have all bit “1″s and “0″s successive, in which bit “1″s must be on the left; bit “0″s must be on the right. Therefore we only have 8 situations:
    Subnet_Decimal_Binary.jpg
    Table 2 – lists all valid subnet masks
    This is a very important table to do subnet quickly! Please take some time to learn it by heart. Make sure you remember the right-most bit “1″ position (the least significant bit 1, which are in red in the above table) and their equivalent decimal values.
    In most cases, this table is used to quickly convert a number from decimal to binary value without any calculation. For example, you can quickly convert the 4th octet of the subnet mask 255.255.255.248 to 11111000. Or if you are given a subnet of /29 you will know it equals to 255.255.255.248 (by thinking “/24 is the default subnet mask of class C so /29 will have the right-most bit “1″ at 5th position).
    Try to practice with these questions:
    + “/28″ in binary form?
    + “255.255.224.0″ in binary form?
    + “255.192.0.0″ in slash notation form?
    + “/26″ in binary form?
    + “255.128.0.0″ in binary form?
    + “248.0.0.0″ in slash notation form?
    (Please try to solve by yourself before reading the solution)
    Answers:
    + /28 -> 1111 1111.1111 1111.1111 1111.1111 0000
    + 255.255.224.0 -> 1111 1111.1111 1111.1110 0000.0000 0000
    + 255.192.0.0 -> /10
    + /26 -> 1111 1111.1111 1111.1111 1111.1100 0000
    + 255.128.0.0 -> 1111 1111.1000 0000.0000 0000.0000 0000
    + 248.0.0.0 -> /5
    How to find out the increment number?
    The increment is the heart of subnetting; if you can find out the increment, you can find all the information to solve a subnetting question. So it is usually the first thing you must find out in a subnetting question.
    The increment number is the number specifying how “big” your subnets are. Let’s take an example of the increment number! Did you remember the subnets in “Exercise 3″ in the previous part? By changing bits in the Network part, we found out 4 subnets:
    + First subnet: 198.23.16.0/30 (the 4th octet is 00000000)
    + Second subnet: 198.23.16.4/30 (the 4th octet is 00000100)
    + Third subnet: 198.23.16.8/30 (the 4th octet is 00001000)
    + Fourth subnet: 198.23.16.12/30 (the 4th octet is 00001100)
    In this case the increment is 4 (in the 4th octet) because the “difference” between two successive subnets is 4 (from 0 -> 4; from 4 -> 8; from 8 -> 12)
    There are 2 popular ways to find out the increment number:
    1) Use the formula:
    Increment = 256 – x
    In which “x” is the first octet (counting from the left) which is smaller than 255 in a subnet mask. For example:
    + In a subnet mask of 255.224.0.0 -> x = 224
    + In a subnet mask of /29 -> x = 248 (because /29 = 255.255.255.248)
    + In a subnet mask of 1111 1111.1111 1100.0000 0000.0000 0000 -> x = 252
    In the case you see a subnet mask of 255.255.255.255 (which is very rare in CCNA), x = 255
    Note: Also remember which octet “x” belongs to because we have to plus the increment to that octet.
    Now let’s solve Exercise 3 again by using this formula:
    Exercise 3 one again (with the formula 256 – x):
    Your company has just been assigned the network 198.23.16.0/28. How many subnets and hosts-per-subnet you can create with a subnet mask of 255.255.255.252?
    The subnet mask is 255.255.255.252 -> x = 252 (x belongs to 4th octet)
    Therefore the Increment = 256 – 252 = 4
    The initial network 198.23.16.0/28 is also the first subnet, so:
    + The first subnet: 198.23.16.0/30
    + The second subnet: 198.23.16.4/30 because the increment is 4 so we plus the network address with it to get the next network address (0 + 4 = 4)
    + The third subnet: 198.23.16.8/30 (4 + 4 = 8)
    + The fourth subnet: 198.23.16.12/30 (8 + 4 = 12)
    Note: We know there are only 4 subnets because we borrow 2 bits.
    2) Learn by heart the decimal value of the rightmost bit “1″ in the subnet mask:
    Another way to find the increment value is to write “x” in binary: 11110000. Consider the rightmost bit “1″, the decimal value of this bit is the increment value. In this case it equals to 16.
    The table below summarizes the decimal values of bit “1″ depending on its position. To use this method, you should learn by heart this table:
    Subnet_bit_1_significance.jpg
    Table 3 – How to find out increment based on the “least-significant” (rightmost) bit 1
    Now let’s solve Exercise 3 again by using this method:
    Exercise 3 one again (with the “decimal value of the rightmost bit 1″ method):
    Your company has just been assigned the network 198.23.16.0/28. How many subnets and hosts-per-subnet you can create with a subnet mask of 255.255.255.252?
    First use Table 2 to convert 252 to 1111 1100. The decimal value of the rightmost bit “1″ is 4 (according to Table 3) -> The Increment is 4.
    After finding out the increment we can deduce 4 subnets it creates.
    The initial network 198.23.16.0/28 is also the first subnet, so:
    + The first subnet: 198.23.16.0/30
    + The second subnet: 198.23.16.4/30 because the increment is 4 so we plus the network address with it to get the next network address (0 + 4 = 4)
    + The third subnet: 198.23.16.8/30 (4 + 4 = 8)
    + The fourth subnet: 198.23.16.12/30 (8 + 4 = 12)
    Note: We should only choose one method to use and try to practice, practice & practice more with it. Practice until you can solve any subnetting questions within 20 seconds!
    Maybe you will ask why 256 can help you find the increment. In fact, by using the formula Increment = 256 – x you are trying to separate the rightmost bit “1″ from other bits:
    256 – x = 255 – x + 1
    In which “255 – x” will convert all bit “0″s to bit “1″s and all bit “1″s to “0″s while “+1″ part will make our result have only one bit “1″ left. For example, if x = 240 then:
    Why_256_magic.jpg
    So in fact we can say two above methods are the same!