Friday, 6 July 2018

L2 Layer Troubleshooting for Beginners

MAC ADDRESS, VLAN, ARP:
Important commands for troubleshooting:
  • Show lldp neighbors
  • Show interface status
  • Int et 1/1 →  show active
  • Note:
  • We should never try to ping any host from a switch since it will try to ping via management interface
  • Always check MAC address table on switches
  • Always check ARP table on hosts only (do not check on switches)
  • NOTE: Do the troubleshooting in same order as below:
  1. Check if shutdown
  2. Check vlans
  3. Check IP configurations
  • One method is to start ping from host A to host B. then, go to Host B and tcpdump on the interface. If we get both a request and reply. There is a trouble in the reply path.
  • Note that we cannot see the ping on in-between devices since unicasts do not go to control plane
Case 1: Interface Shut Down:
  • Go to each interface in topology and do
        #int et 1/1
        #show active
And check if it is shutdown
Case 2: Trunk and Access Mismatch:
  • Go to facing interfaces (both sides of a link) in topology and do
        #int et 1/1
        #show active
  • Check if both are trunk and allow the vlan used
  • If one of them is access vlan X and the other is trunk allowed vlan X, then, the untagged packet from access will go to the native vlan and get dropped
Case 3: IP Configuration on hosts:
  • Go to hosts and check the interface IP address
  • One of the hosts will be in different subnet (Then, host A will think that host B is also in same subnet. But, host B will know that it is not in same subnet...so will not reply)
Case 4: MAC Access Lists:
  • Do #show active on each interface
  • Check if there is a mac access-list for another mac-address ‘B’  which blocks packets from mac-address B (using ‘in’)
Case 5: Another host ‘C’ is also receiving the ping requests that was sent for another host ‘D’. Check if true?
  • Start tcpdump on both hosts C and D . (we may see that no ping packets are shown….control plane)
  • But, if we checked on an in-between switch’s interface #show active , we see that mac address learning is set to NO. So, there is always a broadcast due to Unknown Unicast (#no switchport mac address learning)
  • Now that we know that it is supposed to be getting broadcasts, we can confirm it by going to host C and doing
  • #clear counter et 49
  • #watch diff show int et 49 // Other traffic will be there also...so use the other command(OR) #watch diff show int et 49 counter bins
  • Go to host A and start ping for host D using large repeat count and size
Case 6: MAC Flapping:
  • Use command #show logging to see mac flaps
  • #show event-monitor mac can be used to see when a mac-address entry was added and removed

Thursday, 5 July 2018

ICMP Messages and Message Types: What they Mean and how to troubleshoot

ICMP Message Types

The type field identifies the type of the message sent by the host or gateway. Many of the type fields contain more specific information about the error condition. Table 3.2 lists the ICMP message types.

Table 3.2 ICMP Message Types

Type
Description ICMP Message Types
0
Echo Reply (Ping Reply, used with Type 8, Ping Request)
3
Destination Unreachable
4
Source Quench
5
Redirect
8
Echo Request (Ping Request, used with Type 0, Ping Reply)
9
Router Advertisement (Used with Type 9)
10
Router Solicitation (Used with Type 10)
11
Time Exceeded
12
Parameter Problem
13
Timestamp Request (Used with Type 14)
14
Timestamp Reply (Used with Type 13)
15
Information Request (obsolete) (Used with Type 16)
16
Information Reply (obsolete) (Used with Type 15)
17
Address Mask Request (Used with Type 17)
18
Address Mask Reply (Used with Type 18)

Because each of the ICMP message headers vary depending on which one is sent, we will discuss each type separately, identifying the corresponding code fields, if applicable.

Ping: Echo Request and Reply—Types 8 and 0

We discuss the ICMP Echo Request Type 8 and Echo Reply Type 0 because ICMP uses these messages in tandem. Remote hosts use these two message types to test connectivity. As previously mentioned, the user executes the Ping utility, initiating the generation of ICMP echo requests with the expectation that the destination host sends a corresponding echo reply. Upon successful receipt of the replies to the echo requests, the messages do the following:
  • Indicate a successful test.
  • Assume that a valid communication path between the hosts exists.
  • Assume the end host works through the Network layer.

Destination Unreachable—Type 3

ICMP Type 3 message Destination Unreachable alerts a source host of delivery problems encountered while trying to reach the destination. Note that a destination host sends only code types 2 and 3; a router can send all codes. Destination Unreachable uses several code values to further describe the function of the ICMP message being sent. Each code type describes a different delivery problem encountered, as shown here:
0 = Network Unreachable
This message indicates that the router cannot find the destination network (does not exist or has failed) or has no route to this network. In other words, the router cannot deliver or forward an IP datagram to the destination network. This could be the result of a network that is beyond the maximum distance limitation for the routing protocol in use and is therefore considered unreachable (too far). When a client attempts to connect to a host on a network that is unreachable, a gateway generates this message to alert the source host of the problem. You can think of this message as the gateway saying to the sending host, "The street you are trying to locate is not found or is too far to reach."
1 = Host Unreachable
The host unreachable message alerts the sending host that the destination host requested cannot be found. This could happen because this host has been turned off or does not exist. You can think of this message as the gateway saying to the sending host, "I found the street you were looking for, but the house you are trying to find is not there."
2 = Protocol Unreachable
Protocol unreachable indicates that the Transport layer protocol (UDP or TCP) is not available. The destination host or an intervening gateway might send this message. You can think of this message as saying, "The transport layer protocol you are attempting to communicate with is not active on this host."
3 = Port Unreachable
A port unreachable message indicates that the process or application the source host is attempting to establish a connection with is not active on the destination host. Typically this type of message is sent when an application has not been started or has failed on this host. The destination host or an intervening gateway might send this message. You can think of this message as saying, "The process or application you are attempting to communicate with is not active on this host," or, "I found the street, I found the house, the lights were on, but no one was home."
4 = Fragmentation is needed, but don't-fragment bit set
This message occurs when a router receives a datagram that requires fragmentation, but the router has the DF (don't-fragment) flag turned on. (The sending host generally has the responsibility of fragmentation. The receiver has the responsibility of reassembly.)
However, when a router cannot forward a datagram because it is too big, if allowed the router might fragment the datagram further before transmitting it to an attached segment. If the router has the DF bit set, this will not happen and the router will trash the datagram. It then generates a message to alert the sender of this action by sending a Type 3, Code 4 message. The fragmentation bit also can determine the maximum packet size or MTU that hosts can transmit end to end along the communication path.
Hosts can use the ICMP messages sent by routers to resize datagrams, dynamically adjusting to the needs of the network. This allows the host to determine the smallest MTU path to a destination.
5 = Source Route Failed
The message occurs if a router encounters a next hop in the source route that does not reside on a directly connected network.
6 = Destination Network Unknown
This message occurs when a router receives an IP datagram that it cannot deliver or forward to a particular network because it is unknown.
7 = Destination Host Unknown
This message occurs when a router receives an IP datagram that it cannot deliver or forward to a particular host because it is unknown.
8 = Source Host Isolated (obsolete)
9 = Destination Network Administratively Prohibited
This message occurs when a router receives an IP datagram that it cannot deliver or forward to a particular network because it is not allowed. Access to this network has been prohibited.
10 = Destination Host Administratively Prohibited
This message occurs when a router receives an IP datagram that it cannot deliver or forward to a particular host because it is not allowed. Access to this host has been prohibited.
11 = Network Unreachable for ToS
This message occurs when a router receives an IP datagram that it cannot deliver or forward to a particular network because the ToS requested is not available.
12 = Host Unreachable for ToS
This message occurs when a router receives an IP datagram that it cannot deliver or forward to a particular host because the ToS requested is not available.
13 = Communication Administratively Prohibited by Filtering
This message occurs when a router receives an IP datagram that it cannot deliver or forward to a particular host because it is not allowed. An administratively configured filter has prohibited access to this process or application.
14 = Host Precedence Violation
This message occurs when a router receives an IP datagram that it cannot deliver or forward to a particular host because the precedence level requested does not match, and is not accepted or is invalid. This could be a source host attempting to access a high security host without the necessary security clearance values.
15 = Precedence Cutoff in Effect
This message rarely occurs. However, you will receive this message when a packet is dropped by the cutoff function.
Precedence Handling For All Routers
Routers must accept and route incoming traffic of all precedence levels normally, unless you have configured it to do otherwise. If you want to learn more about precedence and Destination Unreachable messages 14 and 15, please refer to RFC 1812, 5.3.3.3, "Precedence Handling for All Routers."

Source Quench—Type 4

A receiving host generates this message when it cannot process datagrams at the speed requested due to a lack of memory or internal resources. This message serves as a simple flow control mechanism that a receiving host can utilize to alert a sender to slow down its transmission of data. When the source host receives this message, it must pass this information on to the upper-layer process, such as TCP, which then must control the flow of the application's datastream. A router generates this message when, in the process of forwarding datagrams, it has run low on buffers and cannot queue the datagram for delivery.

Redirect—Type 5

A router sends a redirect error to the sender of an IP datagram when the sender should have sent the datagram to a different router or directly to an end host (if the end host is local). The message assists the sending host to direct a misdirected datagram to a gateway or host. This alert does not guarantee proper delivery; the sending host has to correct the problem if possible.
Only gateways generate redirect messages to inform source hosts of misguided datagrams. Note that a gateway receiving a misdirected frame does not trash the offending datagram if it can forward it. The gateway forwards the frame, sends an alert message to the source, and hopes the source host will properly direct future frames to the designated host or gateway indicated in the message. ICMP redirect messages alert source hosts when a datagram has been misdirected and should be resent. Four redirect error codes can occur:
  1. 0 = Redirect for Network
  2. 1 = Redirect for Host
  3. 2 = Redirect for Type-of-Service and Network
  4. 3 = Redirect for Type-of-Service and Host

Router Advertisement and Solicitation—Types 9 and 10

Rather than initializing a routing table with static routes specified in configuration files, you can use the router ICMP advertisement and solicitation messages. After bootstrapping, a host can transmit a broadcast or multicast a solicitation message to which a router or routers responds with a router advertisement. This allows communicating hosts to learn of available routes dynamically and update their routing tables. We will discuss routing in more detail in Chapters 5 and 6.

Time Exceeded—Type 11

The time exceeded message occurs when a router receives a datagram with a TTL (Time To Live) of 0 or 1. IP uses the TTL field to prevent infinite routing loops. A router cannot forward a datagram that has a TTL of 0 or 1. Instead, it trashes the datagram and sends a time exceeded message. Two different time exceeded error codes can occur:
  1. 0 = Time-To-Live Equals 0 During Transit
  2. 1 = Time-To-Live Equals 0 During Reassembly
Note that a router cannot forward a datagram with a TTL of 0 or 1 both during transit or reassembly.
As previously mentioned in the IP section of this chapter, the TTL timer is measured in seconds and originally was used before the existence of routers to guarantee that a datagram did not live on the Internet forever. Each gateway processing a datagram reduces this value by at least one if it takes longer to process and forward the datagram. When this value expires, the gateway trashes the datagram and sends a message back to the sender notifying the host of the situation.
The traceroute utility also uses the TTL value to discover the path or route to a destination host or network. Upon execution of the traceroute command, the initial ICMP message is sent out with a TTL value of 1 set in the IP header. You can use the traceroute program to determine, or rather trace, the path to a destination. Traceroute accomplishes this by sending a sequence of datagrams with the TTL set to 1, 2, and so on. It then uses the ICMP Time Exceeded messages like a trail of breadcrumbs to trace the routers along the path. We will provide you with examples later in this section.
As you might recall from earlier in this chapter, when a router receives a datagram with a TTL of zero, it trashes the datagram and returns an ICMP time exceeded message to the source. This message allows the host to learn of the first router in the path to the destination. 
As shown in the figure, ICMP message type 11 alerts a source host of a TTL expiration. Code 0 identifies the reason for the expiration as time to live being exceeded while the datagram was in transit. This message also includes a copy of the original datagram header that caused the error to assist the source host in correcting the problem. Within the offending header contained within the ICMP message, you can see that the "TTL value = 0 seconds/hops," which is why the original datagram was trashed.
Now the source host sends a new ICMP trace with a TTL value of 2, which allows this datagram to be forwarded by the first router (which decrements the value by one) and reaches the next router in the path with a TTL of one. This router must trash the frame and send back an ICMP time exceeded. This process continues until the path to the destination network or host is fully discovered or deemed unreachable. As you can see, traceroute is another useful troubleshooting tool, typically used in conjunction with other utilities such as the Ping utility to test connectivity between two hosts.
TIP
Both the Ping and traceroute utilities can help you when troubleshooting.

Parameter Problem—Type 12

The parameter problem message indicates that a host or gateway received and could not interpret an invalid or misunderstood parameter. A host or gateway also can send this message when no other ICMP message covering the problem can be used to alert the sending host. In this respect, it is a catchall message. In most cases this message indicates some type of implementation error occurred, perhaps because of vendor incompatibility issues. A host or gateway will not send this message unless it trashes the datagram containing the parameter problem.
Two parameter problem error messages can occur:
  1. 0 = IP Header Bad (catchall error0)
  2. A host or gateway sends this error to indicate a general implementation error of an unspecific nature.
  3. 1 = Required Option Missing
  4. The host or gateway expected a specific option, but the sender did not send it.

Timestamp Request and Reply—Types 13 and 14

Timestamp request and reply messages work in tandem. You have the option of using timestamps. When used, a timestamp request permits a system to query another for the current time. It expects a recommended value returned to be the number of milliseconds since midnight, Coordinated Universal Time. This message provides millisecond resolution, considered a beneficial feature when compared to other means of obtaining time from another host who provides resolution in seconds. The two systems compare the three timestamps and use RTT to adjust the sender's or receiver's time if necessary. Note that most systems set the transmit and receive time as the same value.
The process for time resolution goes as follows:
  1. The requestor stamps the originate time and sends the query.
  2. The replying system stamps the receive time when it receives the query.
  3. The replying system stamps the transmit time when it sends the reply to the query.

Information Request and Reply—Types 15 and 16

Although ICMP messages list information request and reply as a potential ICMP message type, they actually do not occur; thus they are obsolete. A host can request information such as to what network it was attached.

Address Mask Request and Reply—Types 17 and 18

Address mask request and reply messages work in tandem. Although we rarely use this message today, its original design supported the function of dynamically obtaining a subnet mask. Hosts can use the ICMP address mask request to acquire subnet masks during bootstrap from a remote host. However, problems can occur when using ICMP to receive a mask if a host gives an incorrect mask from an external source. If the external source does not give a response, the source host must assume a classful mask (that the network is not subnetted).

Summary

IP is the workhorse of the Network layer within the TCP/IP suite. All protocols and applications utilize IP for logical Network layer addressing and transmission of datagrams between internet hosts. IP provides an unreliable, connectionless datagram delivery service and uses ICMP to send messages when it encounters an error.
End host and routers use ICMP as a control, messaging, and diagnostic tool. ICMP utilizes IP to deliver its messages and is considered an integral part of IP. ICMP messages notify a host of problems. Although ICMP does not offer a solution to these problems, it can provide enough information for a source host to solve some of the problems that might occur in the internetwork. The most popular ICMP message is the echo request and reply. Utilizing the Ping utility, these messages allow you to test connectivity between end hosts.

This article is taken from:
Source: http://www.informit.com/articles/article.aspx?p=26557&seqNum=5

Thursday, 28 June 2018

Step-by-Step Note on how to perform Classless Addressing

A Very good document that I obtained from Scribd by a student on Classless networks:

  • Note: This document is for absolute beginners and may be too simple for others

More on IP Routing

Static IP Routing:

    • What will happen two static routes for same IP address?
    • http://www.brocade.com/content/html/en/configuration-guide/FI_08030_L3/GUID-01C97118-4521-4599-8ACD-134E7FD30124.html
    • If administrative distance are not same, it always go through the route with the lower administrative distance.
    • If two routes are there, it uses ECMP (Equal Cost MultiPath Routing)  always. Half of the traffic will go through one route and the other half will go through the other link.
    • Eg) #ip route 6.6.6.0/24 1.1.1.2 20 we give the administrative distance as 20 and #ip route 6.6.6.0/24 3.3.3.2 10 we give administrative distance as 10. In this case, the 20 ad (administrative distance) route will not even be taken into the routing table. But, if the first interface of ad 10 goes down, the route with ad 10 comes up in routing table automatically.
    • Thus, routing table will always have only the best path.

    • STATIC IP ROUTING:
    • See the below example to clear doubts about static IP Routing
    • Look at details like the next hop ip address
    • Format is

    #ip route <ip address> <subnet mask> <next hop ip or exit interface>[d]

    Router0(config)#ip route 20.0.0.0 255.0.0.0 192.168.0.254

    Router1(config)#ip  route 10.0.0.0 255.0.0.0 192.168.0.253
    Router1(config)#ip  route 20.0.0.0 255.0.0.0 192.168.0.250

    Router2(config)#ip  route 10.0.0.0 255.0.0.0 192.168.0.249
    Router2(config)#ip  route 20.0.0.0 255.0.0.0 192.168.0.246

    Router3(config)#ip  route 10.0.0.0 255.0.0.0 192.168.0.245[e]

    • RECURSIVE LOOKUP:
    • A Recursive lookup refers to routes for which the router must look up the connected route to a next-hop gateway in order to route the packet to its ultimate destination.
    • In recursive lookup, in router 1 itself we give the next hop for reaching 20.1.1.0 is 192.168.2.2. But, even 192.168.2.0 is not there, so it checks its entry for route to reach 192.168.2.0. Thus, it uses the 192.168.1.2 as the next hop to reach 192.168.2.0
    • Thus, finally, it uses 192.168.1.2 is chosen as the next hop
    • Advantage is that using this we can not only reach the destination networks but also the intermediate networks since we already know the route to them also.
    • You should avoid recursive routing in static routing,as it increases complexity and decreases the router’s performance.

    • Even if many entries are there in routing table, it takes the closest subnet and that subnet must include the IP address
    • Eg) Among the routes 4.4.4.2/32 , 4.4.4.2/28 and 4.4.4.0/24, it takes the 4.4.4.4/32
    • NOTE:
    • If we use exit interfaces instead of next hop ip address, we need to enable proxy arp on all the exit interfaces.

    --------------------------------------------------------------------------------------------------------------------------------

    • OSPF vs RIP- which is better-????
    • Scalability
    • RIPv1 floods routes frequently (every 30 seconds), which introduces large CPU loads as the size of the routing table increases. This is compounded by the reality that RIP recalculates metrics for every route, every time it floods the route out a new interface. This is prevents RIP from scaling as well as other protocols as the number of routes increases. RIPv1 is classful. RIP is only good for 16 hops and anything after that you get Network is unreachable.
    • OSPF floods routes infrequently, and performs distributed metric calculations at end nodes (instead of at every flooding router, as RIP does). Distributed route calculations, on LSAs which are flooded infrequently, make OSPF scale well. OSPF is a classless protocol, which supports CIDR, which also makes it a more scalable protocol than RIPv1
    • Convergence time
    • RIP is a routing protocol that converges so slowly that even a network of a few routers can take a couple of minutes to converge. In case of a new route being advertised, triggered updates can speed up RIP's convergence but to flush a route that previously existed takes longer due to the holddown timers in use.
    • OSPF is an example of a fast-converging routing protocol. A network of a few routers can converge in a matter of seconds.
    • Trust
    • Control Traffic

    • Control Traffic or Control Packet is more important than data packets since if the control packets are dropped, then, mostly, even the data packets will get dropped because control packets is responsible for proper sending of the data packets.

    --------------------------------------------------------------------------------------------------------------------------------

    Loopbacks:

    • It creates a different broadcast domain.
    • It is a virtual/software interface in a router which can be used to emulate a physical interface. (earlier we use physical loopbacks where we connect one port to another of same switch. Thus, ports are wasted)
    • Loopback interfaces are treated similar to physical interfaces in a router and we can assign IP addresses to them. (so a user cannot know whether it is loopback or actual address)
    • A loopback interface is always up.
    • By default, router doesn’t have any loopback interfaces.
    • A loopback interface has many uses:
    • Loopback interface’s IP Address determines a router’s OSPF Router ID.
    • It is useful in BGP neighborship even if physical interfaces go down

    IP Routing

    IP Routing:

    • Routing is needed to go to a different broadcast domain

    • Factors affecting path taken:
    • Number of hops
    • Congestion
    • Bandwidth- Cost/Metric
    • Link/Node failure
    • Multiple Links
    • For choosing the least cost path:        
    • Administrative Distance
    • Cost/Metric

    • STATIC ROUTING:
    • Manual configuration
    • Routes must be configured both the ways .ie. for both sending data and receiving data
    • Static has a lower administrative distance of 1. Thus, static route will be preferred.
    • If any router fails, then, there will be no path. Thus, static fails
    • Also, congestion will happen on a specific route if lot of traffic is being sent. Still, static route is taken
    • In Production, static routes are used as backup

    • DYNAMIC ROUTING:
    • Automatic selection of routes using algorithms
    • Algorithms may be dynamic, where the routers make decisions based on information they gather, and the routes change over time, adaptively.
    • Default route means we just send all traffic to the default router which becomes the next hop. Using default route is useful since it saves memory (instead of giving a next router for all routes) and also it helps to send packets to unknown router using the default router

    --------------------------------------------------------------------------------------------------------------------------------

    IP Addressing

    • Why we need IP Address?
    • We need it to send information to devices throughout the world
    • Qualities:
    • It is 32-bit binary number (same length)
    • Dotted decimal system
    • Division based on size- Class A, B, C, D, E
    • To find the device: we need identification and location. The identification is the host id. The location is the network id.
    • If we have more users, we need more host bits.
    • Class A- 8 n/w bits and 24 host bits  (0-126) (127 is used for loopback, so can’t be used for hosts)
    • Class B- 16 n/w bits and 16 host bits (128-191)
    • Class C- 24 n/w bits and 8 host bits (192-223)
    • Class D-multicast (224-239)
    • Class E- experimental (240-255)[a]
    • Class:
    • Class A: We have 8 n/w bits. But, the first bit is fixed as 0. Thus, we have only (2^7) networks possible. No of hosts= (224)-2 .
    • Class B: We have 16 n/w bits. But, the first bit is fixed as 10. Thus, we have only (2^14) networks possible. No of hosts= (216)-2
    • Class C: We have 24 n/w bits. But, the first bit is fixed as 110. Thus, we have only (2^21) networks possible. No of hosts= (28)-2[b]

    Note: the (-2) in no. of hosts is because one address is for n/w address and another one is for broadcast address

    • Subnet Mask is used to tell the number of bits for network part.
    • Eg) 10.0.0.0?-  is class A. Therefore, subnet mask is 255.0.0.0. The first host address is 10.0.0.1 and the last host address is 10.255.255.254.
    • Eg) 172.16.0.0 ?- Class B therefore subnet mask is 255.255.0.0 . First host address is 172.16.0.1 and last is 172.16.255.254
    • Eg) 192.168.1.0 ?-is class C. hence, subnet mask is /24. First host ID is 192.168.1.1 and last is 192.168.1.254. The broadcast address is 192.168.1.255
    • Each Class has some range for private IP address:
    • Class A- 10.0.0.0 to 10.255.255.255
    • Class B- 172.16.0.0 - 172.31.255.255
    • Class C- 192.168.0.0 - 192.168.255.255[c]

    • Zero Subnet:It is the first subnet obtained when subnetting the network address. Eg) 192.168.1.0/24 is the zero subnet for class C. Nowadays, we can assign this IP address to hosts also since we use classless IP instead of classful IP addressing.
    • Public IP address must be unique and is assigned by the ISP

    --------------------------------------------------------------------------------------------------------------------------------

    Subnetting:

    • If we use only classes, then, either we have a lot of hosts or a lot of networks. Thus, IP addresses are wasted. Hence, we use variable length subnets.
    • In subnetting, we borrow the bits from the host part.
    • Eg) 10.0.0.0/8.
    • Here, the n/w part is 10.
    • Host part is 0.0.0. We borrow bits from here. Let us take 2 bits. SO, host part starts with (XX000000.)b
    • Thus, we get 4 subnets 10.0.0.0/10, 10.64.0.0/10, 10.128.0.0/10, 10.192.0.0/10

    • Hint: The subnets will be in multiples of the first subnet. Eg) 64*1=61, 64*2=128, 64*3=192
    • If we use /31, then, we will have only one host in the subnet (if we consider broadcast address) or 2 hosts if we don’t consider broadcast.  Since a point to point (between 2 routers on end of the n/w) doesn't really need a  broadcast address, /31 can be used here.
    • CIDR- using only subnets instead of classes