Showing posts with label ICND2. Show all posts
Showing posts with label ICND2. Show all posts

Monday, April 18, 2016

Majorbacon's Breakdown on Spanning Tree Protocol and Variants Part 1: The Problem

First, the Problem

Spanning Tree Protocol is one answer to a specific problem that occurs at a layer 1 & 2 levels - redundant connections between switches cause problems!

No Redundancy, No Problems


Now we've added a redundant connection enabling multiple paths for switch to switch communication

If a broadcast is sent out it will flood normally, but it will eventually also enter through the "back door" of the original switch that forwarded the broadcast, acting like a "new" message that needs further flooding, causing infinite flooding (remember this is layer 2, there is no time to live on a frame)

Worse yet, the broadcast actually went out both directions at the beginning of the flood, which means we actually have two broadcasts circulating the network infinitely!
The results of the unmanaged switching loop includes:
  • Broadcast storms - no room for valid traffic - packets will keep getting forwarded until the switches run out of memory and start dropping frames.
  • MAC Table Instability - remember that the source MAC address of a packet is used to update the switch's MAC address table - this means that eventually the first switch, the one connected to the broadcasting Server, will eventually believe that the server is attached to one of the other switches, since it will receive a broadcast from them with the Server's MAC address listed at the source. The switch will lose track of its own devices!
  • Redundant Frames - both broadcasts and unicasts may be received multiple times by destination endpoints, bogging down intermediate services like TCP and higher level application services

So now we know the problem... see the Spanning Tree Protocol and Variants Part 2 to start seeing the solution!


Thursday, December 17, 2015

An easy to understand description of VLANs for Cisco, HP, VMWare, or Microsoft

VLANs can be confusing for virtualization administrators, because it takes a really solid understanding of networking to then be abstracted into a virtual environment, which can then be configured multiple ways.
Let's make sure we're on the same page with VLANs first

Let's think about a physical environment that is segmented without any VLANS
 
If we think about networks from a chronological perspective, we start with just the green local area network at the top. All your local clients were in a local broadcast domain with a single network ID. And the living was easy.
Then LANs continued to grow and grow, which caused too many broadcasts, traffic congestion, and security vulnerabilities... all because all the devices were playing in the same "sandbox."
 
So to divide the LAN we ran a dedicated cable from a newly dedicated interface on the router, installed a separate switch, and routed between the LANs, as seen in the diagram above.
 
Question: Why would anyone ever want anything better than that solution?
#1 - Money: High speed Ethernet interfaces on routers are a costly proposition, only superseded by purchasing entirely new routers to handle the traffic from each network. Additionally, every subnet needs a dedicated switch. What if a 48 port switch is serving a network of only 10 hosts? 37 wasted ports.
#2 - Management: To reassign a host to a different subnet means moving their patch cable to a physically different switch. This is a manual, physical process that requires going into the racks and mucking about - always an additional risk, easy to make mistakes

The good news is that soon one of the first network virtualization technologies came into being. Instead of having to buy additional switches and router interfaces, we can use virtual LANs (VLANs)

- VLANs allow us to virtualize networks using two key components:
1) Switch ports are virtualized so that instead of one switch you can have the effect of having two or three or more switches from a single physical switch, and then you can spread these multiple virtual switches across multiple physical switches!
2) Router interfaces are also virtualized, using sub-interfaces on physical routers or virtual VLAN interfaces on multilayer switches. Each virtualized router interface will be configured to "plug in" to the virtual switch. This means that one uplink could support a connection to 20 different subnets!

So how do you go about virtualization? It's all about playing a game of tag. Each switch's access port (a port going to an end station such as a server, desktop, phone, or router) will be tagged with a particular VLAN number, determined arbitrarily by the administrator.  (Side note, many administrators make their lives easier by creating a loose association between VLANs and subnet IDs. For example, the 192.168.5.0 subnet could be assigned VLAN 5 for simplicity.)

So each VLAN is identified by a number and the default VLAN is VLAN 1. All ports are assigned to VLAN 1 by default, meaning that the switch functions like an unmanaged switch, all ports will forward, filter, and flood with all other ports. Since this is the case, by default, VLAN tagging (inserting the tag ID into the frame) is skipped by default for VLAN 1. This skipping can only be done for one VLAN ID number, and is known as the "native VLAN". 

But now we choose to subdivide the switch by adding VLAN 2.  Generally on a switch you will have the opportunity to provide a VLAN name, which makes it a more sensical device (ie: HR_192.168.5.0 for the Human Resources subnet using 192.168.5.0)

Now that we two different VLANs an administrator needs to assign access ports to that VLAN.

This effectively turns a switch from this:
(Switch with all ports still on VLAN 1)


into this:




Remember, the devices connected to the switch know nothing about VLANs. But now the switch has virtualized two networks instead of one, which means that traffic must be ROUTED from one VLAN into the other, not just switch. 

In order to allow multiple switches and routers to participate in these VLANs we must modify the standard Ethernet frame and insert a VLAN tag number so that all devices can respect the defined VLAN boundaries. Tagging is done between devices over what are known as trunk ports. Trunk ports are used when connecting switches to each other or when connecting switches with multiple vlans to a router. Trunk ports are not assigned a VLAN number because their job is to carry ALL VLAN traffic upstream to a router and to take the returning packets and forward them to the correct access ports. VLAN ID numbers are stripped from the frames before they enter an access port.

That allows for this:



With this configuration you can see that we have the equivalent of 4 switches instead of two, with two switches in each broadcast domain. The great thing about the configuration above is that a device in VLAN 1 can switch to another device in VLAN 1 (or a VLAN 2 device to another VLAN 2 device) at high speeds. However, if a device wants to connect to another device across VLANs (VLAN 1 PC to a VLAN 2 Server, for example) then they had better know the know the IP address of the sub-interface (virtual interface) of their L3 routing service! In other words, they must route as if they were physically connected to different physical interfaces of the router.




But the real beauty of all this is that any device could be moved to a different subnet by reconfiguring the VLAN ID of an access port to a different number. As long as all the switches have the same VLAN ID numbers (and the router has VLAN associated sub-interfaces.

A little more about the native VLAN. The default VLAN is VLAN 1 (what all ports start off as). The default VLAN is also the native VLAN (untagged "assumed" VLAN number) by default. This was useful when connecting unmanaged and managed switches and in carrying management traffic back in the day. However, for security reasons, it is usually a best practice to change the native vlan to a different, unused VLAN ID number (such as 999). This ensures that are no assumptions, and therefore no annoying security holes. Now VLAN1 frames will be tagged as VLAN 1 just like all the other VLANs

When VLAN 2 is added, the VLAN tag is added to frames that are a part of VLAN 2. We now have two VLANs, and at least one of them must be tagged to be identified. 

Now, let’s add VLAN 3.  In this setup, two VLANs would need to be tagged, one would not because it was the original lan (VLAN)  The VLAN that is not tagged is known as the native VLAN.


There are a lot of questions of when and why to use the native VLAN or if you should use the native VLAN at all.  As always in IT, the answer is, it depends on what you are doing. VLAN 1 does not have to be your management VLAN.  It does not have to be the native or untagged VLAN. You can do whatever you need for your environment.  Typically, I do not use the native VLAN for security reasons, and I choose to tag everything. 

Remember that all of this is true whether you are dealing with a physical switch or a hypervisor driven virtual switch on Microsoft Hyper-V or VMWare ESXi. Trunk ports between switches, defined VLANs omnipresent, Access ports with VLAN ID numbers on individual access ports.

Keep it clean, keep it safe.

Monday, December 14, 2015

Get Trunk!!!

Remember - you can't carry traffic for multiple VLANs unless you...



Smiles,


Thursday, October 22, 2015

Resetting your Cisco Router Password via ROMMON

How to perform password recovery on your Cisco IOS router

Here's the tools you will need
1) Router/Switch
2) Rollover cable
3) Terminal Emulator Program such as Tera Term or Putty
4) Knowledge of Register values


  1. Connect the rollover cable's RJ-45 interface to your device and the serial or USB interface into to your computer
  2. Picture thanks to: https://es.wikibooks.org/wiki/Planificaci%C3%B3n_y_Administraci%C3%B3n_de_Redes/Tema_6/Texto_complete
  3. Fire up your terminal emulator
  4. Connect to the appropriate COM port (remember the appropriate serial settings)
    • 9600 baud rate
    • No parity
    • 8 data bits
    • 1 stop bit
    • No flow control
  5. Reboot the Router
  6. Send the break signal to the Router - the keystroke to signal break varies by terminal emulator
  7. The break signal drops you into ROMMON mode instead of booting the IOS in this low level mode (kind of like booting to BIOS/CMOS on a desktop) you get different options such as configuring the boot register (like changing the boot order or hardware in BIOS)
  8. To tell the system to boot normally, except without loading the startup configuration type:
    • ROMMON>confreg 0x2142
  9. To reboot type:
    • ROMMON>reset
  10. When the system boots you may be prompted to configure setup using the prompts - if so type:
    • no
  11. You have an un-configured system - log on by typing:
    • Router#enable
  12. Now load your startup configuration by typing:
    • Router#copy start run
    • (DO NOT DO THE OPPOSITE (copy run start) OR YOU WILL LOSE THE STARTUP CONFIG!!!)
    • Yes, I did that once. Thank God for TFTP backups.
  13. Now your configuration has loaded but you're already in, without having to have typed the official password! Sneaky! Now you can set the password to access privileged mode by typing:
    • Router#conf t
    • Router(config)#enable secret <enter your secret here>
  14. Reset the device to boot normally instead of skipping the startup config by typing:
    • Router(config)#config-register 0x2102 
    • Router(config)#end
  15. Backup your current configuration to survive rebooting by typing:
    • Router#copy run start
    • (if you type the opposite you will lose all your hard work and it will revert to the unknown secret)
  16. Reboot the device to prove correct configuration and trigger all interfaces to return to an up / up status by typing
    • Router#Reload
And that's how I get into all those systems where no one knows the password because it was set by a contractor who emailed the password to the guy who quit six months ago!

Hope it helps!

Cisco Spanning Tree Portfast and BPDUGuard

There are two powerful tools available for those of us (the majority I believe) that are still relying on Spanning Tree Protocol (STP) for our switch loop protection. They are Portfast! and BPDUGuard! (Don't the sound impressive with those exclamation points?)

Portfast!

Enabling PortFast on a switchport skips the listening and learning states when a device is plugged in (you know, that annoying wait time with the amber light?). From an STP perspective the port is set to a forwarding state immediately, This works out great for most accessthat are trustworthy to be connected only to a single device such as a server or workstation

Here are a couple of key commands related to basic portfast:

To globally set PortFast on all NON-Trunking ports:
Switch (config)#spanning-tree portfast default

To locally set PortFast on a particular interface:
Switch (config-if)#spanning-tree portfast

BPDUGuard!

PortFast is designed for access ports that do not receive Switch to Switch BPDU packets from STP. It is possible to have non-trunking ports that connect two switches, however, which can then cause spanning tree loops. With BPDUGuard enabled on top of PortFast the receipt of a BPDU packet over a PortFast interface triggers the port to move into an err-disabled state instead of configuring the port in an STP blocking port configuration which would look like this:
Switch#show interfaces gigabitethernet 1/1 status
Port    Name               Status       Vlan       Duplex  Speed Type
Gi1/1                      err-disabled 100          full   1000 1000BaseSX

This security measure then leads a network administrator to either:
a) unplug the switch from this port and move it to a correct port
b) change the port to a trunking port rather than an access port so that STP can function normally

 Here are a couple of key commands related to basic BPDUGuard:

To globally set BPDUGuard on all NON-Trunking ports:
Switch (config)#spanning-tree portfast bpduguard default

To locally set BPDUGuard on a particular interface:
Switch (config-if)#spanning-tree bpduguard enable

To recover from the err-disabled state:
Switch(config-if)#spanning-tree portfast disable

TestTakers!

  1. Note the similarities and differences between the PortFast and BPDUGuard commands
  2. Consider the order in which you would set them (Portfast first!)
  3. Recognize Err-Disabled as a possibly a BPDUGuard issue
Err-Disabled triggers include:
  • BPDU guard violation
  • Duplex mismatch
  • Port channel misconfiguration
  • UniDirectional Link Detection (UDLD) condition
  • Late-collision detection
  • Link-flap detection
  • Security violation
  • Port Aggregation Protocol (PAgP) flap
  • Layer 2 Tunneling Protocol (L2TP) guard
  • DHCP snooping rate-limit
  • Incorrect GBIC / Small Form-Factor Pluggable (SFP) module or cable
  • Address Resolution Protocol (ARP) inspection
  • Inline power
 Hope that keeps it all straight in your head!

Wednesday, October 21, 2015

Understanding Recursive Lookups in Cisco routing tables


First, the term "Recursive"

While recursion can just refer generically to repetition, the term in Information Systems and Technology contexts almost always refers to using a tool to enable the use of the same tool. Think of using a mirror to reflect a mirror (an example of infinite recursion).
Examples: 

1) A DNS server receives a DNS query for which it doesn't know the answer. It performs recursion by sending it's own DNS query to root DNS server to discover the answer for the client.

  • DNS uses DNS to answer DNS.


2) In a Microsoft SQL database server there is a database called Master that is recursively used by SQL to find and reference the high level properties of all the other attached databases that are used by end-users.

  • SQL uses SQL to manage SQL.


Now for understanding Cisco routing recursion:

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.

  • The Router uses Routes to 
    • a) find the next router in the route path and 
    • b) to Route to the next Router

This is because in a routing table the gateway for a routed network can be defined as an interface or as an IP address.

Using an interface works great when the router is referring to directly connected routes like this:
Router4#show ip route
Gateway of last resort is not set

     172.16.0.0/30 is subnetted, 1 subnets
C       172.16.100.0 is directly connected, Serial0/0
C    192.168.1.0/24 is directly connected, FastEthernet0/0 

or to point-to-point links in which there is only one possible intended destination:

Router5(config)#ip route 192.168.0.0 255.255.0.0 se 0/0
Router5(config)#end
%SYS-5-CONFIG_I: Configured from console by console
Router5#show ip route

Gateway of last resort is not set

     172.16.0.0/16 is variably subnetted, 2 subnets, 2 masks
C       172.16.1.0/24 is directly connected, FastEthernet0/0
C       172.16.100.0/30 is directly connected, Serial0/0
S    192.168.0.0/16 is directly connected, Serial0/0

However, routes that reference an endpoint on multi-access networks like Ethernet or Frame Relay need a logical destination, since the physical interface could connect to many devices. This is where we see our standard routing entries that indicate an IP address as the gateway value:

Router4(config)#ip route 172.16.1.0 255.255.255.0 172.16.100.1
Router4(config)#end
%SYS-5-CONFIG_I: Configured from console by console
Router4#show ip route

Gateway of last resort is not set

     172.16.0.0/16 is variably subnetted, 2 subnets, 2 masks
S       172.16.1.0/24 [1/0] via 172.16.100.1
C       172.16.100.0/30 is directly connected, Serial0/0
C    192.168.1.0/24 is directly connected, FastEthernet0/0

So now you need to think like a router
1) You receive an incoming packet destined for 172.16.1.5
2) You find that the best route is the static route 172.16.1.0/24 (remember to always choose the longest subnet mask / slash notation that is a match)
3) You discover the gateway for that route is 172.16.100.1
4) As a router, you have multiple interfaces. Which one should you use to contact 172.16.100.1?
5) You look up 172.16.100.1 in the routing table
6) You find that the best route is the connected route 172.16.100.0/30
7) You forward the packet over the Serial 0/0 interface

You just used your routing table to figure out how to route the packet to the gateway you found in your routing table - Recursion!!!

Test Tip: Watch out for how this could apply to a gateway of last resort - your 0.0.0.0/0 route!

Hope this helps clear things up for everyone!