SharonTools

Cisco nexus enable all ports script

When configuring Cisco Nexus 7000 with VDC,
Sometimes you need to enable (no shut) all the interfaces in each VDC,
The problem is that in each VDC there are alot of interfaces,
And there is alot of work to enable them,
So, you can use this script to do that:(under ‘conf t’)

Create an alias for the script

N7K-2(config)# cli alias name ifdown show interface status | xml | grep Eth | sed 's/<[^>]*>//g' | sed 's/^/interface /' | sed 's/$/ ; shut/'
N7K-2(config)# cli alias name ifup show interface status | xml | grep Eth | sed 's/<[^>]*>//g' | sed 's/^/interface /' | sed 's/$/ ; no shut/'

 run the alias

N7K-2# ifup
 interface Ethernet1/9 ; no shut
 interface Ethernet1/10 ; no shut
 interface Ethernet1/11 ; no shut
 interface Ethernet1/12 ; no shut
 interface Ethernet1/13 ; no shut
 interface Ethernet1/14 ; no shut
 interface Ethernet1/15 ; no shut
 interface Ethernet1/16 ; no shut
 interface Ethernet2/9 ; no shut
 interface Ethernet2/10 ; no shut
 interface Ethernet2/11 ; no shut
 interface Ethernet2/12 ; no shut
 interface Ethernet2/13 ; no shut
 interface Ethernet2/14 ; no shut
 interface Ethernet2/15 ; no shut
 interface Ethernet2/16 ; no shut
 interface Ethernet3/13 ; no shut
 interface Ethernet3/14 ; no shut
 interface Ethernet3/15 ; no shut
 interface Ethernet3/16 ; no shut
 interface Ethernet3/17 ; no shut
 interface Ethernet3/18 ; no shut
 interface Ethernet3/19 ; no shut
 interface Ethernet3/20 ; no shut
 interface Ethernet3/21 ; no shut
 interface Ethernet3/22 ; no shut
 interface Ethernet3/23 ; no shut
 interface Ethernet3/24 ; no shut
N7K-2#
N7K-2#

now copy all the line above and paste it under ‘conf t’

N7K-2# conf t
Enter configuration commands, one per line. End with CNTL/Z.
N7K-2(config)# interface Ethernet1/9 ; no shut
N7K-2(config-if)# interface Ethernet1/10 ; no shut
N7K-2(config-if)# interface Ethernet1/11 ; no shut
N7K-2(config-if)# interface Ethernet1/12 ; no shut
N7K-2(config-if)# interface Ethernet1/13 ; no shut
N7K-2(config-if)# interface Ethernet1/14 ; no shut
N7K-2(config-if)# interface Ethernet1/15 ; no shut
N7K-2(config-if)# interface Ethernet1/16 ; no shut
N7K-2(config-if)# interface Ethernet2/9 ; no shut
N7K-2(config-if)# interface Ethernet2/10 ; no shut
N7K-2(config-if)# interface Ethernet2/11 ; no shut
N7K-2(config-if)# interface Ethernet2/12 ; no shut
N7K-2(config-if)# interface Ethernet2/13 ; no shut
N7K-2(config-if)# interface Ethernet2/14 ; no shut
N7K-2(config-if)# interface Ethernet2/15 ; no shut
N7K-2(config-if)# interface Ethernet2/16 ; no shut
N7K-2(config-if)# interface Ethernet3/13 ; no shut
N7K-2(config-if)# interface Ethernet3/14 ; no shut
N7K-2(config-if)# interface Ethernet3/15 ; no shut
N7K-2(config-if)# interface Ethernet3/16 ; no shut
N7K-2(config-if)# interface Ethernet3/17 ; no shut
N7K-2(config-if)# interface Ethernet3/18 ; no shut
N7K-2(config-if)# interface Ethernet3/19 ; no shut
N7K-2(config-if)# interface Ethernet3/20 ; no shut
N7K-2(config-if)# interface Ethernet3/21 ; no shut
N7K-2(config-if)# interface Ethernet3/22 ; no shut
N7K-2(config-if)# interface Ethernet3/23 ; no shut
N7K-2(config-if)# interface Ethernet3/24 ; no shut

 

By: Sharon Saadon

 

Exit mobile version