Turning on all Cumulus Linux interfaces

Cumulus Linux has a cool ‘feature’ it inherited from Linux.  On most network switches  a port is either Layer2 or Layer3.  When a port is layer2 it has to be part of a VLAN.  Linux does understand and work with VLANs but it can have a port that is running at layer2 but not part of a VLAN.  We can configure a port under /etc/network/interfaces like this:

auto swp1
iface swp1

If we ifup this port its not part of a VLAN, and its not Layer3.  

Why would we want to do this?  Honestly the most common reason is that we can check physical connections by using lldp before this port is part of a broadcast domain (VLAN) that could cause loops or unexpected behavior.

What if I cabled a switch and don’t know what ports are connected?  You could create a stanza for each swp like above, use something like mako or do a simple bash loop on the command line like this:

cumulus@leaf01:~$ for swp in {1..54}; do sudo ip link set swp$swp; done

Now all 54 ports are admin up at layer2 so we can check connections, but its not routing or switching.  Now you can use a “net show int” or use the linux command “ip link show”

cumulus@leaf01:~$ ip link show | grep LOWER_UP
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq master mgmt state UP mode DEFAULT group default qlen 1000
11: swp9: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 9216 qdisc pfifo_fast state UP mode DEFAULT group default qlen 1000
51: swp49: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 9216 qdisc pfifo_fast master peerlink state UP mode DEFAULT group default qlen 1000
52: swp50: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 9216 qdisc pfifo_fast master peerlink state UP mode DEFAULT group default qlen 1000
53: swp51: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 9216 qdisc pfifo_fast state UP mode DEFAULT group default qlen 1000
54: swp52: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 9216 qdisc pfifo_fast state UP mode DEFAULT group default qlen 1000

You can even just use lldp here

cumulus@leaf01:~$ net show lldp

Local Port    Speed    Mode                 Remote Port    Remote  Host     Summary
------------  -------  -------------  ----  -------------  ---------------  --------------------------
eth0          1G       Mgmt           ====  swp23          oob-mgmt-switch  IP: 10.50.100.100/24(DHCP)
swp9          10G      NotConfigured  ====  swp51          leaf07
swp49         40G      NotConfigured  ====  swp49          exit02           
swp50         40G      NotConfigured  ====  swp50          exit02           
swp51         40G      NotConfigured  ====  swp30          spine01
swp52         40G      NotConfigured  ====  swp30          spine02

Yay now we can go configure them now that we know how they are cabled up. Its great to be lazy 🙂

Update 3/30/2017

The famous Daniel Walton (yeah the Daniel that has his name on this, this and my personal favorite this.) let me know that Cumulus Linux’s new NCLU (Network Command Line Utility) also has a method of doing this quickly. You can check out his tweet here. NCLU uses the net command and has the ability to do a range of ports really quickly. One caveat vs using ip link set… this will make persistent config (meaning the ports are actually configured under /etc/network/interfaces). If you don’t want the config to remain you can do a “net del” then a “net commit”

net add int swp1-54

Leave a Reply

Your email address will not be published. Required fields are marked *

*