Hone

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

enable
The # prompt.
configure terminal
Into configuration mode.
vlan 60
The VLAN it is moving to, which has to exist or the switch will invent it.
name FINANCE
Named.
exit
Out.
interface gi0/7
The port that is moving.
switchport mode access
Access, as it should already be.
switchport access vlan 60
It is in 60 now, and whatever it was in before it no longer is.
end
Out.
show vlan brief
Gi0/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 

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.

Practise moving a port between VLANs on HoneA question on it now, a coding challenge where there is one, and it is remembered for review. Free, no email needed.