Pages

Monday, January 7, 2013

Cisco Catalyst 3750 SVI MAC Addresses


The following has been tested on a Cisco Catalyst 3750. I suspect the behaviour is the same on a 3560 but I would like someone to test that out and confirm. Also, if you find that this is documented better elsewhere please comment and let me know and I'll link to it.

I have a particularly unusual customer setup that I won't go into the details of here, but the long and short of it is that we need to know the MAC address assigned to a particular SVI as the other end can't dynamically learn addresses, but there's a potential gotcha around expecting the MAC to be static.

Let's take a look at the Catalyst 3750 I was testing with. The base MAC (from show version) is as follows:

Base ethernet MAC Address       : 08:17:35:E6:46:80

On the 3750 the first 64 MAC addresses beginning at the base MAC are reserved for layer 2 switchports. The 65th MAC address is assigned to the first layer 3 interface and this is where things get interesting. So, the last part of our base MAC address is 0x80 (hex). Let's convert to decimal to make things a bit easier:

0x80 = 128
128 + 65 = 193
193 = 0xC1

So we would expect our first layer 3 interface to have a MAC address of 08:17:35:E6:46:C1.

If we configure an interface Vlan 40 and do a show interface we get the following output:

Vlan40 is up, line protocol is down
  Hardware is EtherSVI, address is 0817.35e6.46c1 (bia 0817.35e6.46c1)

which is what we expected. And if we configure another SVI, say Vlan 50, we would expect the MAC address to be increased by 1:

Vlan50 is up, line protocol is down
  Hardware is EtherSVI, address is 0817.35e6.46c2 (bia 0817.35e6.46c2)

and it is. So far, so good.

So, we know we can predict the MAC address of an SVI given the base MAC address of the switch, but does it survive a switch reload? Let's save the config and reload to find out. The following is a show interface for vlans 40 and 50 after the reload:

Vlan40 is up, line protocol is down
  Hardware is EtherSVI, address is 0817.35e6.46c1 (bia 0817.35e6.46c1)

Vlan50 is up, line protocol is down
  Hardware is EtherSVI, address is 0817.35e6.46c2 (bia 0817.35e6.46c2)

They're still the same, vlan 40 ending C1 and vlan 50 ending C2. Cool.

What happens if we add vlan 60 now after the reload?

Vlan60 is up, line protocol is down
  Hardware is EtherSVI, address is 0817.35e6.46c3 (bia 0817.35e6.46c3)

As you might have predicted, vlan 60 gets assigned a MAC address ending in C3.

This all makes sense so far, our vlans are contiguous and predictable, but what would happen if we added vlan 30 now? Let's add it and do a show interface:

Vlan30 is up, line protocol is down
  Hardware is EtherSVI, address is 0817.35e6.46c4 (bia 0817.35e6.46c4)

Vlan 30 gets assigned the next available MAC address, ending C4. Okay, so that's fairly predictable; we created a new vlan and it got assigned the next available MAC address. What do you think will happen if the switch is reloaded? Let's save the config and reload to find out:

Vlan30 is up, line protocol is down
  Hardware is EtherSVI, address is 0817.35e6.46c1 (bia 0817.35e6.46c1)

Vlan40 is up, line protocol is down
  Hardware is EtherSVI, address is 0817.35e6.46c2 (bia 0817.35e6.46c2)

Vlan50 is up, line protocol is down
  Hardware is EtherSVI, address is 0817.35e6.46c3 (bia 0817.35e6.46c3)

Vlan60 is up, line protocol is down
  Hardware is EtherSVI, address is 0817.35e6.46c4 (bia 0817.35e6.46c4)

Now we see a change in behaviour. The switch has assigned out the first available layer 3 MAC address to the first assigned vlan, which, when reading the config, is no longer vlan 40, but vlan 30 which appears first in the config.

Normally this isn't going to be a problem, but in my particular scenario where I need to know the MAC addresses for static assignment it's a bit of a big deal.

In summary, MAC addresses are assigned to SVI interfaces in the order the SVI interface comes up, which is numerically in the IOS configuration file.


No comments:

Post a Comment