11-02-2015 12:22 AM - edited 03-08-2019 02:31 AM
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
11-02-2015 12:30 AM
#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.
11-02-2015 02:13 AM
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
11-02-2015 06:05 AM
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)
11-02-2015 01:37 AM
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.
10-29-2019 02:22 AM
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
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide