VirtuallyUseful – Random Tech Babble

October 2, 2013

Cisco IOS tips and tricks

Filed under: Cisco — Ray Olander @ 11:12 PM

Cisco command line options that I’ve found useful (I will add to this little by little):

  • Reset port gi1/0/1 to default:
    • conf t
    • default interface gi1/0/1
  • Reset ports 1-48 to default:
    • conf t
    • default int range gi1/0/1-48
  • Edit ports 1-48 at the same time
    • conf t
    • int range gi1/0/1-48
    • <enter config change>
  • Apply a config change to a non-contiguous range of ports
    • conf t
    • int range gi1/0/1 – 5 , gi1/0/10 – 15
    • <enter config change>
  • Do multiple steps in a single command when provisioning a port for an end-device
    • conf t
    • int gi1/0/1
    • switchport host
      • sets switch port mode to access + enables spanning tree Port Fast + disables channel grouping.
  • Use macros to run a script by entering a single command AND use variables
    • Create the macro
      • conf t
      • macro name SetToTrunk
      • shut
      • description TRUNK PORT
      • switchport trunk encapsulation dot1q
      • switchport mode trunk
      • switchport trunk native vlan $NATIVE
      • switchport trunk allowed vlan $ALLOWED
      • mls qos trust dscp
      • no shut
      • @
    • Now apply the macro to a port you want to create as a trunk, set the native VLAN to 123 and define all VLANs as being allowed
      • conf t
      • int gi1/0/1
      • macro apply Trunk $NATIVE 123 $ALLOWED all
  • Show all interfaces and the CRC count for each
    • show interface | i protocol|CRC
      • GigabitEthernet1/0/5 is up, line protocol is up (connected)
      • 0 input errors, 0 CRC, 0 frame, 0 overrun, 0 ignored
  • Find what ports are not currently connected
    • sh int status | i notconnect
  • Show what ports are down due to BPDUguard
    • sh int status | i err
    • or
    • show log | I BPDU|bpdu
      • %SPANTREE-2-BLOCK_BPDUGUARD: Received BPDU on port GigabitEthernet1/0/16 with BPDU Guard enabled. Disabling port.
      • %PM-4-ERR_DISABLE: bpduguard error detected on Gi1/0/16, putting Gi1/0/16 in err-disable state
  • Modify an access-list that is referenced with a class-map and policy-map (basically, you need to delete from the top down and rebuild from the bottom up):
    • Steps explained
      • conf t
        • remove the policy within the policy map that references the class-map that references the access-list (access-group)
        • Remove the class-map that references the access-list (access-group)
        • do a no access-list to remove the ACL
        • Enter in the ACL statements
        • Enter in the class-map statements
        • change to policy-map
        • Enter in the policy-map statements
    • Steps performed
      • For this setup we’ll use this configuration
        • policy map MARK-LAN-DSCP
          • class EF-105-CLASS
            • set dscp ef
        • class map match-any EF-105-CLASS
          • match access-group 105
        • Access-list 105 permit ip host 192.168.1. any
        • Access-list 105 permit ip host 192.168.2.1 any
      • GOAL: To edit access-list 105 and change one of the source IP’s without the switch choking on itself
        • conf t
          • policy-map MARK-LAN-DSCP
          • no class EF-105-CLASS
          • exit (this takes you out of the pmap context)
          • no class-map match-any EF-105-CLASS
          • no access-list 105
          • access-list 105 permit ip host 10.0.0.1 any
          • access-list 105 permit ip host 192.168.2.1 any
          • class-map match-any EF-105-CLASS
          • match access-group 105
          • exit (gets you out of the cmap context)
          • policy-map MARK-LAN-DSCP
          • class EF-105-CLASS
          • set dscp ef
          • exit (leaves EF-105-CLASS context)
          • exit (leaves pmap context)
          • exit (leaves edit mode)
          • wr
  • Delete a directory
    • del /force /recursive directory_name
  • For all switches in a stack, define both a primary AND a secondary boot image
    • all flash:c3750-ipbasek9-mz.122-55.SE8.bin;flash:c3750-ipbasek9-mz.122-55.SE7.bin
  • Get extended details about the packets crossing an interface
    • show int gi2/0/39 controller (regular SH INT stats are also displayed, but are omitted here)
    Transmit GigabitEthernet2/0/39           Receive
    542890630 Bytes                        800171957 Bytes
      2196943 Unicast frames                 4155021 Unicast frames
        53197 Multicast frames                 26677 Multicast frames
         4615 Broadcast frames                  5009 Broadcast frames
            0 Too old frames               776174135 Unicast bytes
            0 Deferred frames               23587201 Multicast bytes
            0 MTU exceeded frames             410621 Broadcast bytes
            0 1 collision frames                   0 Alignment errors
            0 2 collision frames                   0 FCS errors
            0 3 collision frames                   0 Oversize frames
            0 4 collision frames                   0 Undersize frames
            0 5 collision frames                   0 Collision fragments
            0 6 collision frames
            0 7 collision frames              124415 Minimum size frames
            0 8 collision frames              161085 65 to 127 byte frames
            0 9 collision frames              104558 128 to 255 byte frames
            0 10 collision frames              67226 256 to 511 byte frames
            0 11 collision frames             170088 512 to 1023 byte frames
            0 12 collision frames            3559335 1024 to 1518 byte frames
            0 13 collision frames                  0 Overrun frames
            0 14 collision frames                  0 Pause frames
            0 15 collision frames
            0 Excessive collisions                 0 Symbol error frames
            0 Late collisions                      0 Invalid frames, too large
            0 VLAN discard frames                  0 Valid frames, too large
            0 Excess defer frames                  0 Invalid frames, too small
      1683840 64 byte frames                       0 Valid frames, too small
       251639 127 byte frames
        15423 255 byte frames                      0 Too old frames
        32565 511 byte frames                      0 Valid oversize frames
         8936 1023 byte frames                     0 System FCS error frames
       262352 1518 byte frames                     0 RxPortFifoFull drop frame
            0 Too large frames
            0 Good (1 coll) frames
            0 Good (>1 coll) frames
  • Show receive and transmit utilization for all ports
    • sh controller utilization
Port       Receive Utilization  Transmit Utilization
Gi1/0/1            0                    0
Gi1/0/2           10                    0
Gi1/0/3            0                    0
Gi1/0/4            0                   37
Gi1/0/5           20                    0
Gi1/0/6            0                    0
Gi1/0/7            0                    0
Gi1/0/8            0                    0
...
Gi2/0/52           0                    0
Total Ports : 104
Switch Receive Bandwidth Percentage Utilization  : 0
Switch Transmit Bandwidth Percentage Utilization : 0
Stack Ring Percentage Utilization : 0

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Blog at WordPress.com.

%d bloggers like this: