Phase A complete: VLAN DB + names + handover

- HANDOVER.md: full delegation doc (Status, Architektur, Phasen, Gotchas)
- switch/cli/backup.exp: show running-config mit --More-- handling
- switch/cli/02-vlan-names.cli/exp: set VLAN names (MAIN/INFRA/IOT/UNTRUSTED/GUEST/MGMT/WAN)
- switch/cli/running-PRE.txt: pre-changes config backup (networkmask-Syntax bestaetigt)
- switch/cli/02-vlan-names.log: verifikations-Output (show vlan)

VLAN-DB jetzt: 1, 10, 20, 30, 40, 90, 99, 100 (alle benannt, alle Static)
Alle Ports weiterhin in VLAN 1 (non-disruptiv).
save: Success

Switch-Recovery: Telnet-VTY-Lockout (stale Session) erforderte User-Reboot
  des Switches. Credentials OK, WebUI ebenfalls blockiert (Session-Drop).
  Nach Reboot funktioniert Telnet ueber plain pipe UND expect.
This commit is contained in:
Christoph Emsenhuber
2026-06-09 18:55:43 +02:00
parent 498fa06472
commit a73db06354
5 changed files with 412 additions and 0 deletions

View File

@@ -0,0 +1,30 @@
# === BF Core-Switch sw1 (ALL-SG8316M, FW 2.2.1) — VLAN-Namen setzen ===
# Reproduzierbar: . switch/.secrets && expect switch/cli/02-vlan-names.exp
# NON-DISRUPTIV: benennt nur die bereits angelegten VLANs (aus 01-vlan-db.cli);
# ändert KEINE Port-Zugehörigkeit.
# VID-Plan: 10=MAIN 20=INFRA 30=IOT 40=UNTRUSTED 90=GUEST 99=MGMT 100=WAN
configure
vlan 10
name MAIN
exit
vlan 20
name INFRA
exit
vlan 30
name IOT
exit
vlan 40
name UNTRUSTED
exit
vlan 90
name GUEST
exit
vlan 99
name MGMT
exit
vlan 100
name WAN
exit
end
save
show vlan

View File

@@ -0,0 +1,107 @@
#!/usr/bin/expect -f
# VLAN-Namen setzen — korrigiert: `end` aus config-vlan geht zu sw1#,
# also nicht nutzen. Stattdessen `exit` aus config-vlan → config,
# und einmal `end` zum Speichern am Ende.
set timeout 30
log_user 1
spawn telnet $env(SW_HOST)
expect "Username:"
send "$env(SW_USER)\r"
expect "Password:"
sleep 1
send "$env(SW_PASS)\r"
expect "sw1#"
send "configure\r"
expect "(config)"
# 90 GUEST
send "vlan 90\r"
expect "(config-vlan)"
send "name GUEST\r"
expect "(config-vlan)"
send "exit\r"
expect "(config)"
# 99 MGMT
send "vlan 99\r"
expect "(config-vlan)"
send "name MGMT\r"
expect "(config-vlan)"
send "exit\r"
expect "(config)"
# 10 MAIN
send "vlan 10\r"
expect "(config-vlan)"
send "name MAIN\r"
expect "(config-vlan)"
send "exit\r"
expect "(config)"
# 20 INFRA
send "vlan 20\r"
expect "(config-vlan)"
send "name INFRA\r"
expect "(config-vlan)"
send "exit\r"
expect "(config)"
# 30 IOT
send "vlan 30\r"
expect "(config-vlan)"
send "name IOT\r"
expect "(config-vlan)"
send "exit\r"
expect "(config)"
# 40 UNTRUSTED
send "vlan 40\r"
expect "(config-vlan)"
send "name UNTRUSTED\r"
expect "(config-vlan)"
send "exit\r"
expect "(config)"
# 100 WAN
send "vlan 100\r"
expect "(config-vlan)"
send "name WAN\r"
expect "(config-vlan)"
send "exit\r"
expect "(config)"
# Save!
send "end\r"
expect "sw1#"
send "save\r"
expect {
"Success" { send "\r" }
timeout { }
}
# Verifizieren mit show vlan (paged)
send "show vlan\r"
# --More-- handling
for {set i 0} {$i < 20} {incr i} {
expect {
-ex "--More--" {
sleep 0.3
send " "
}
-ex "sw1#" {
break
}
timeout { break }
}
}
send "exit\r"
expect eof

View File

@@ -0,0 +1,46 @@
spawn telnet 10.40.41.239
Trying 10.40.41.239...
Connected to sw1.fritz.box.
Escape character is '^]'.
Username: claudecode
Password: ************
sw1# configure
sw1(config)# vlan 90
sw1(config-vlan)# name GUEST
sw1(config-vlan)# exit
sw1(config)# vlan 99
sw1(config-vlan)# name MGMT
sw1(config-vlan)# exit
sw1(config)# vlan 10
sw1(config-vlan)# name MAIN
sw1(config-vlan)# exit
sw1(config)# vlan 20
sw1(config-vlan)# name INFRA
sw1(config-vlan)# exit
sw1(config)# vlan 30
sw1(config-vlan)# name IOT
sw1(config-vlan)# exit
sw1(config)# vlan 40
sw1(config-vlan)# name UNTRUSTED
sw1(config-vlan)# exit
sw1(config)# vlan 100
sw1(config-vlan)# name WAN
sw1(config-vlan)# exit
sw1(config)# end
sw1# save
Success
sw1#
sw1# show vlan
VID | VLAN Name | Untagged Ports | Tagged Ports | Type
-------+------------------+------------------------------+------------------------------+---------
1 | default | gi1-16,lag1-8 | --- | Default
10 | MAIN | --- | --- | Static
20 | INFRA | --- | --- | Static
30 | IOT | --- | --- | Static
40 | UNTRUSTED | --- | --- | Static
90 | GUEST | --- | --- | Static
99 | MGMT | --- | --- | Static
100 | WAN | --- | --- | Static
sw1# exit
sw1>

47
switch/cli/backup.exp Normal file
View File

@@ -0,0 +1,47 @@
#!/usr/bin/expect -f
# Backup running-config mit --More-- Handling
# Schreibt komplette running-config nach STDOUT (zur Weiterleitung in Datei)
set timeout 60
log_user 1
spawn telnet $env(SW_HOST)
expect "Username:"
send "$env(SW_USER)\r"
expect "Password:"
sleep 1
send "$env(SW_PASS)\r"
expect {
"sw1#" { }
timeout { puts "TIMEOUT: kein Prompt"; exit 1 }
}
send "show running-config\r"
# Seiten durchblättern bis zurück zum Prompt
set more_count 0
while {$more_count < 100} {
expect {
-ex "--More--" {
set more_count [expr $more_count + 1]
sleep 0.3
send " "
}
-ex "sw1#" {
break
}
timeout {
puts "TIMEOUT beim Paging"
break
}
}
}
send "\r"
expect "sw1#"
send "exit\r"
expect eof