Hitlessly change a Cisco switchport from an Access to a Trunk Port in Production

Monday, 27 Apr 2020

So you've got an Access Port on a Cisco Switch going down to a Host/Server of some sort, and for whatever reason you then swap out that Server for maybe a Virtualisation Host (ESXi, oVirt, Docker, k3s....), or in my case a Cisco WAVE594 with a built-in Tyan AST2050 BMC (where the iLO shares the same physical NIC as the Server, no seperate Mgmt Port) - and you want to do it hitlessly. Hmm, sounds like a good challenge to me!

Draw it up then!

What we have is:

  • Left-hand side (before)
    • Baremetal Server SERVER Eth0 connected to Cisco Switch SWITCH Gig 1/0/9
    • Eth0 set as without VLAN tagging/membership
    • Cisco Switch SWITCH Gig 1/0/9 set as Member (Access) of VLAN 99
    • VLAN 99 associated with SVI99 for inter-VLAN Routing
  • Right-hand side (after)
    • Baremetal Server SERVER Eth0 connected to Cisco Switch SWITCH Gig 1/0/9
    • Eth0 associated with Software vSwitch (or similar)
    • Internal Mgmt Loopback/Interface associated with Physical NIC Eth0, set as without VLAN tagging/membership
    • Virtual Machine VIRTUALMACHINE vNIC0 associated ultimately with SERVER Eth0 pNIC, but set as and to tag VLAN 86
    • Cisco Switch SWITCH Gig 1/0/9 set as Trunk and Native (Access) for VLAN 99
    • VLAN 99 associated with SVI99 for inter-VLAN Routing
    • VLAN 86 associated with SVI86 for inter-VLAN Routing

Topology showing Cisco Switches and Access-connected Hosts

Tag vs Untag / Cisco vs Others

First, some terminology that always caught me out as a Cisco Guy - the difference between Tag and Untag, and Access and Trunk. In my simple Cisco Head, the world is just two things:

  • Access Ports
    • Member of one VLAN
    • 1:1 Port to VLAN mapping
  • Trunk Ports
    • Member of as many VLANs as you like
    • 1:many Port to VLAN mapping

I'd then learnt about a "Native" VLAN, but it was mostly a superficial reference to something that didn't make sense, so I moved on with my life. Then I encountered the following that change my views, and made it all "click" for me:

  • Tag Ports
  • Untag Ports
  • Voice VLANs

Voice VLANs never sat right with me, as they break the Simple Cisco Paradigm of "A (Access) or B (Trunk); there is no C (Other)" - as Cisco sell a Voice VLAN as if it's an Access Port:

interface Gig1/0/2
 description "Connection to an Overpriced Cisco Phone"
 switchport mode access
 switchport access vlan 100
 switchport voice vlan 101

Yet I know that's two VLANs down one port, so it's a friggin' 802.1q Trunk dammit - nothing access'y about that at all, but don't let that stop you using the "access" keyword! My mental model, you done broke my mental model argh!

Access is Trunk, Trunk is Voice, Voice is Access?

After a few coffees whiskeys though, it clicks - Cisco are once again, lying; the true answer is there are three states a port can be in:

  • Untagged for one VLAN (or "Access" as Cisco call it)

Except when it's voice, because who loves consistency? Not Cisco BU's clearly - "Oh hi, welcome to Model1! Yes, it's 'show mac-address-table' here... Oh hi, welcome to Model2! Yes, it 'show mac address-table' here. Mess up your scripting did that? LOLZ, sucks to be you, fool!"

  • Tagged for many VLANs (or "Trunk" as Cisco call it)
  • Tagged for many VLANs and Untagged for one special-little-snowflake VLAN (or "Trunk" with a "Native VLAN")

The third is what we're going to use, where one VLAN (of your choosing) doesn't get a VLAN tag appended to it when thrown onto the wire; meaning the reverse is true. What the above hints at is a Switch-centric view of the world, but if we take that from a Server-centric view of the world:

Port Type Switch-centric View
(Port Egress)
Server-centric View
(Port Ingress)
Access No VLAN tag present No VLAN tag present Switch appends VLAN on ingress/Server no clue it's in a VLAN
Trunk VLAN tag present VLAN tag present Switch sees VLAN on ingress/Server knows it's in a VLAN

...which is why the "Tagged" and "Untagged" definitions make infinitely more sense than normal Cisco nomenclature "Access" versus "Trunk", as the Cisco speak hides the fact that a port can have three states (Access; Trunk with no Native & Trunk with Native), whereas a given logical Server port's membership is one of two states (Explicit Member - Tagged, Server knows the VLAN exists or Silent Member - Untagged, Server has no clue it is within a VLAN [Native]).

What's a BU? A Business Unit, obviously dummy - everyone in Cisco knows that, so we don't bother explaining that acronym, duh. What, you mean you didn't know that? Best hand that CCNP back, boyzone...

The solution

So back to the problem at hand; I want the Server's Mgmt IP to remain at, but not be Tagged (not know it's within a VLAN), and I want to hitlessly (or as near as possible) change the configuration on the fly from Access to Trunk. Here's my way forward:

  • Current configuration
    • interface GigabitEthernet1/0/9
      description "To SERVER Eth0"
      switchport mode access
      switchport access vlan 99
      no shutdown
  • Future configuration
    • interface GigabitEthernet1/0/9
      description "To SERVER Eth0"
      switchport mode trunk
      switchport trunk encapsulation dot1q
      switchport trunk native vlan 99
      no shutdown

Which effectively tells the ingress-behaviour (Server-to-Switch) of the Trunk to bang all untagged Server traffic (in our case, that's to or from Mgmt virtual/logical Interface, into VLAN99 - without the Server ever knowing it is a member of VLAN99, but while allowing the Trunk to pass explicitly-tagged Virtual Machine, or other, traffic (such as VLAN86).

This is incredibly useful when working with inline iDRAC/BMC configurations, as you can do this without burning another cabling run/Server port (or in my case with the Cisco WAVE594, because it doesn't have any other option/no in-built Dedicated iDRAC Mgmt port):

  • Operating System/ISO Eth0 Port
    • Untag (hits the "Native" VLAN)
  • iDRAC/BMC Eth0 Port
    • Tag (hits the explicit VLAN)

Or the other way around - whatever works for you. Which is exactly the same that Cisco ended up bodging their "Voice VLAN" configuration to do, only it's a Trunk not an Access... let's not go there again.

Get bodging!