How can I see which switchports are not in use?

  • On a large Cisco Catalyst switch stack, almost all switchports are patched. I need to identify the ports, which are not in use, for connecting further devices.

    Following switchports, cabling, patch fields and sockets to possible end devices is laborious and even then there could be temporarily used sockets. Looking at the activity of port LEDs is not reliable, since a user device can be shut off.

    What's the easiest way to detect all unused switchports via IOS commands?

    Did any answer help you? if so, you should accept the answer so that the question doesn't keep popping up forever, looking for an answer. Alternatively, you could provide and accept your own answer.

    Did any answer help you? If so, you should accept the answer so that the question doesn't keep popping up forever, looking for an answer. Alternatively, you can post and accept your own answer.

  • Stefan

    Stefan Correct answer

    8 years ago

    I frequently use

    sh int | i (FastEthernet|0 packets input)
    

    or the same with GigabitEthernet, whatever kind of interfaces I want to check.

    • sh int (which is show interfaces) gives a huge list of ste status of all interfaces
    • The pipe symbol | can be used for filtering, but also in search expressions
    • | i (for include) filters the output which matches the following search expressions
    • I use (...|...) to match two conditions: the interface name and a status I like to see, we can use regular expressions here, like this "or" expression

    The output can look like:

    ...
    FastEthernet1/0/31 is up, line protocol is up (connected)
         95445640 packets input, 18990165053 bytes, 0 no buffer
    FastEthernet1/0/32 is up, line protocol is up (connected)
    FastEthernet1/0/33 is up, line protocol is up (connected)
    FastEthernet1/0/34 is down, line protocol is down (notconnect)
         0 packets input, 0 bytes, 0 no buffer
    FastEthernet1/0/35 is down, line protocol is down (notconnect)
    FastEthernet1/0/36 is up, line protocol is up (connected)
    FastEthernet1/0/37 is down, line protocol is down (notconnect)
         0 packets input, 0 bytes, 0 no buffer
    ...
    

    Now I can see my candidates, with actually 0 packets input over time, even if my expression matches numbers just ending with 0. I could make it more perfect, but being easy to remember is also a benefit. The interface names right before each 0 packets input lines are my candidates.

    • Check each chosen interface if it's really unused by sh int <name>
    • From time to time, it's good to clear the counters: clear counters [type number]

    It can be good practice, to leave unused switchports shutdown. So it's easy to identify them using sh ip int bri or the like. And you don't run into problems if you use a switchport which was definitly shut off before.

    Device#Show int | i notconnect will show just the interfaces that are down/down.

    This answer is "Network Engineer 1.0" style. Seriously? Pipe to include? :) Instead, pull the data off the device and process it with standard UNIX tools and write your own script/program to produce a report.

    @stefan, parenthesis are not required... this works just fine in ios: `sh int | i FastEthernet|0 packets input`

    Also, if you remove the "Fast" part you'll match Gig, Fast and regular Ethernet interfaces

License under CC-BY-SA with attribution


Content dated before 7/24/2021 11:53 AM