02 / CONFIGURATION AND TOPOLOGY · LESSON 05

Review access VLAN assignments

Compare desired and observed access VLANs using device-and-port identity.

18 min · learn at your pace

A port name is not a global identifier

Many switches have a port called Ethernet1. Join on both the device ID and the port name so observations from one device cannot overwrite another. A composite key keeps that identity boundary visible even when the human-readable names look familiar.

The desired export says what should be configured. The observed export says what one collector recorded. This is a left join from desired state: every required port remains in the report, while unrelated observed ports do not create extra requirements. Both input tables have unique composite keys in this exercise.

Difference and absence are different findings

A different observed VLAN is a mismatch. No matching observation is missing. Neither result alone proves that a user has lost connectivity; the report establishes a configuration comparison, not a live end-to-end diagnosis.

Read VLANs as canonical integers from validated exports, but retain the complete port name as a field. Sort the report by device and port under LC_ALL=C for a stable review. This exercise does not write switch commands or apply a configuration. A later lesson turns reviewed differences into a local candidate file with a separate apply step.

Try an example.sh
awk -F '\t' 'NR>1 {printf "%s / %s expects VLAN %s\n",$1,$2,$3}' desired.tsv
YOUR TURN

Put it into practice.

desired.tsv and observed.tsv use device_id<TAB>port<TAB>vlan, with validated unique device/port pairs and VLANs 1–4094. Print device_id<TAB>port<TAB>expected<TAB>observed<TAB>state for each desired row, sorted by device then port under LC_ALL=C. State is match, mismatch or missing. For missing observations print - in observed. Ignore observed ports not listed in desired. A port name on another device is not a match.

See an explained solution
One way to solve it.sh
export LC_ALL=C
printf 'device_id\tport\texpected\tobserved\tstate\n'
awk -F '\t' 'FILENAME==ARGV[1] {if(FNR>1)seen[$1 SUBSEP $2]=$3;next}
FNR>1 {key=$1 SUBSEP $2;value="-";state="missing";if(key in seen){value=seen[key];state=(value==$3)?"match":"mismatch"}printf "%s\t%s\t%s\t%s\t%s\n",$1,$2,$3,value,state}
' observed.tsv desired.tsv | sort

The composite join prevents identically named ports from different switches being combined. Its desired-state direction retains missing coverage and excludes unrelated observations without claiming a connectivity diagnosis.