Lessons · Network switches · moving a port between VLANs
Moving a port from one VLAN to another
Setting the access VLAN again replaces the old one; there is nothing to remove first.
Hone is a place to practise programming. This is one of its lessons, written out in full and free to read without an account.
What it is for
Somebody changes desk, a department moves floor, a printer is reassigned. It is the most routine change there is, and doing it in two steps is how people put a port briefly in VLAN 1.
How to think about it
One line. Do not shut the port, do not clear the old VLAN, do not remove and re-add. Then read show vlan brief to see it has moved rather than been copied.
Worked example
enableThe # prompt.
configure terminalInto configuration mode.
vlan 60The VLAN it is moving to, which has to exist or the switch will invent it.
name FINANCENamed.
exitOut.
interface gi0/7The port that is moving.
switchport mode accessAccess, as it should already be.
switchport access vlan 60It is in 60 now, and whatever it was in before it no longer is.
endOut.
show vlan briefGi0/7 appears against FINANCE and against nothing else. A port is in exactly one access VLAN.
Your turn
Move this port into VLAN 60.
switchport access vlan
Console into a switch
The trap
Typing `no switchport access vlan 20` first. That does not clear the way for the new VLAN, it puts the port back in VLAN 1, and if you are interrupted between the two commands that is where it stays.