cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
23254
Views
0
Helpful
5
Replies

show access ports in a specific VLAN

Traian Bratescu
Level 1
Level 1

Hi,

Is there any command that will show all access ports that belong to a specific VLAN?

I need to know if I can delete a VLAN and I need to know if it has any ports belonging to it.

Thank you,

Traian

5 Replies 5

devils_advocate
Level 7
Level 7

#show vlan

This will show all Vlans and their associated ports

#show vlan id 10

This will just show Vlan 10 and its associated ports.

I just need to know the access ports, not the trunking ones; I have aproximately 400 interfaces and I need just the access ports so that I can find out whether that VLAN is still in use. - I know I could use VTP prunning, but it's not an option for the moment.

Traian

Perhaps it can be usefull - I did not find any usefull command so far; I am quite sure it can be done much more elegantly :) - this takes a while to finish

Python script to find access ports in a particular VLAN - tried it on n5k...

import re;    # search strings
vlan_id=13  # vlan to search

init = cli("show interface brief");
words="";
interfaces = []

#first value is a return value - not interesting
for output in init:
  if type(output) == int:
    continue;
  else:
    words = output.split();

# get usefull interfaces - only extenders
for word in words:
  if re.search ('Eth[0-9]+\/[0-9]+\/[0-9]+', word):
    interfaces.append(word);

for i in interfaces:
  init = cli ("show interface " + str(i) + " switchport")
  if re.search('Operational Mode: access',init[1]): # is the port access?
    if re.search('Access Mode VLAN: ' + str(vlan_id) + ' .*' , init[1]): # is the port in the specified VLAN?
      print ("Interface " + i + " sbelongs to VLAN " + str(vlan_id))
      for k in init:
       print(k)

In addition to the advice already given, keep in mind that it's not only an access-port that needs the vlan. Also if this vlan is used by a trunk-port, the vlan is still needed on the switch.

marian.neagu
Level 1
Level 1

Hi,

sh interface switchport | incl Name|access|<Vlan ID>

Just replace the <Vlan ID> with the one you are looking for if there's a specific vlan you want. All interfaces with 2 indented fields underneath are the ones you want.

sh interface switchport | incl Name|access|Access

All interfaces with 2 indented fields underneath are access, and you also get the specific Vlan they are in..

Best regards,

Marian Neagu

Review Cisco Networking for a $25 gift card