07-01-2021 09:36 AM
Hello,
I'm looking for except script
That will able to run command show run int g0/0.x on 4,094 vlan's
ThanksRouting
07-01-2021 10:08 AM - edited 07-01-2021 10:09 AM
Hello @sas2k3001 ,
no router can support 4,094 VLAN based subinterfaces on the same physical interface ( at least at branch/enterprise level)
However, you can collect the output of
show ip interface brief | inc gi0/0\.
inside the script
in this way you will find a list of all defined subinterfaces the \. tells that you are looking for literal . character and to avoid to consider it a special character in a regular expression.
Once you have the list of defined subinterfaces you can run for each of them
show run int gi0/0.<value>
Hope to help
Giuseppe
07-01-2021 12:49 PM - edited 07-01-2021 12:50 PM
As suggested in your other thread you could use Python and Netmiko.
The following is a very basic script that would do what you want (it has no error checking etc) -
#!/home/netadmin/ntc/bin/python import re from netmiko import ConnectHandler swp = ConnectHandler(device_type='cisco_ios', host='172.30.2.2', username='<your username>', password='<your password>', secret='<enable password>' ) swp.enable() results = swp.send_command('sh run') swp.disconnect() for intf in re.findall(r'(interface Gigabit0/0\.\d+[^!]+)', results, re.DOTALL): print(intf)
You would obviously need to set the IP, the username and the passwords.
Jon
07-02-2021 04:47 AM
Another option is to use the tcl shell to dynamically discover all the interfaces associated with Gig0/0.XXXX and run the show command by pasting this into exec level of the router cli.
term length 0 tclsh set lines [exec "sh ip int brief | inc GigabitEthernet0/0"] foreach line [split $lines "\n"] { if [regexp {(GigabitEthernet0\/0\.[0-9]+)} $line match interface ] { show interface $interface } }
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