Routering & Switching S2 — Cheatsheet
Cisco IOS, switching, VLANs en routing — 2024–2025
Inhoudstafel
- Cisco IOS-basis
- Switching en MAC-tabellen
- VLANs en trunks
- Inter-VLAN routing
- Spanning Tree en EtherChannel
- IPv4- en IPv6-routing
- Statische routing
- Dynamische routing
- ACL, NAT en DHCP
- Troubleshooting
Cisco IOS-basis
User EXEC Router>
Privileged EXEC Router#
Global config Router(config)#
Interface config Router(config-if)#
Line config Router(config-line)#
enable
configure terminal
hostname R1
no ip domain-lookup
enable secret SterkWachtwoord
service password-encryption
banner motd #Authorized access only#
line console 0
password consolepw
login
logging synchronous
line vty 0 4
login local
transport input ssh
username admin secret SterkWachtwoord
ip domain-name lab.local
crypto key generate rsa modulus 2048
ip ssh version 2
copy running-config startup-config
show running-config
show startup-config
show ip interface brief
show interfaces
show version
show cdp neighbors detail
Afkortingen
IOS accepteert unieke afkortingen en ? voor contexthelp. Gebruik in documentatie bij voorkeur herkenbare volledige commando's.
Switching en MAC-tabellen
Een switch leert source MAC-adressen en stuurt bekende unicast doelgericht door. Unknown unicast en broadcast worden binnen het VLAN geflood.
show mac address-table
clear mac address-table dynamic
show interfaces status
show interfaces counters errors
Collisiondomein: per switchpoort. Broadcastdomein: per VLAN. Full-duplex elimineert klassieke collisions; duplex/snelheidsmismatch veroorzaakt wel slechte prestaties en fouten.
Poortbeveiliging
interface g0/1
switchport mode access
switchport port-security
switchport port-security maximum 2
switchport port-security mac-address sticky
switchport port-security violation restrict
Modes: protect dropt stil, restrict dropt en telt/logt, shutdown zet poort err-disabled.
VLANs en trunks
vlan 10
name USERS
vlan 20
name SERVERS
interface range f0/1-12
switchport mode access
switchport access vlan 10
interface g0/1
switchport mode trunk
switchport trunk native vlan 999
switchport trunk allowed vlan 10,20,999
Een accesspoort draagt verkeer van één VLAN ongetagd. Een 802.1Q-trunk draagt meerdere VLANs; native-VLAN-verkeer is standaard ongetagd. Native VLAN en allowed VLAN-lijst moeten aan beide kanten overeenkomen.
VLAN bestaat niet automatisch overal
De trunk kan VLAN 20 toelaten, maar het VLAN moet ook in de lokale VLAN-database bestaan.
Inter-VLAN routing
Router-on-a-stick
interface g0/0
no shutdown
interface g0/0.10
encapsulation dot1Q 10
ip address 192.168.10.1 255.255.255.0
interface g0/0.20
encapsulation dot1Q 20
ip address 192.168.20.1 255.255.255.0
Layer-3-switch met SVI's
ip routing
interface vlan 10
ip address 192.168.10.1 255.255.255.0
no shutdown
interface vlan 20
ip address 192.168.20.1 255.255.255.0
no shutdown
Een SVI komt pas line protocol up als het VLAN bestaat en minstens één bijbehorende actieve L2-poort/trunk aanwezig is.
Spanning Tree en EtherChannel
Redundante L2-links kunnen broadcast storms, duplicate frames en instabiele MAC-tabellen veroorzaken. STP kiest een loopvrije boom:
- Laagste bridge ID wordt root bridge.
- Elke non-root switch kiest een root port.
- Per segment komt één designated port.
- Overtollige paden blokkeren logisch.
show spanning-tree
spanning-tree vlan 10 root primary
interface range f0/1-10
spanning-tree portfast
spanning-tree bpduguard enable
Gebruik PortFast alleen op edgepoorten. BPDU Guard schakelt een edgepoort uit als er toch BPDU's aankomen.
EtherChannel
| Protocol | Modes |
|---|---|
| LACP | active/passive |
| PAgP | desirable/auto |
| statisch | on/on |
interface range g0/1-2
channel-group 1 mode active
interface port-channel 1
switchport mode trunk
show etherchannel summary
Alle memberpoorten moeten dezelfde speed, duplex, access/trunkmodus, native VLAN en allowed VLANs hebben.
IPv4- en IPv6-routing
Een router kiest de route via:
- langste prefix match;
- laagste administrative distance bij gelijk prefix;
- laagste metric binnen hetzelfde protocol.
Routecodes: C connected, L local, S static, O OSPF, R RIP.
interface g0/0
ip address 10.0.0.1 255.255.255.252
ipv6 address 2001:db8:1::1/64
no shutdown
ipv6 unicast-routing
Statische routing
ip route 192.168.20.0 255.255.255.0 10.0.0.2
ip route 0.0.0.0 0.0.0.0 10.0.0.2
ipv6 route 2001:db8:20::/64 2001:db8:1::2
ipv6 route ::/0 2001:db8:1::2
Een floating static route krijgt een hogere administrative distance en wordt pas actief als de voorkeursroute verdwijnt.
Heen- én terugweg
Een ping faalt ook wanneer alleen de return route ontbreekt. Controleer routingtabellen aan beide kanten.
Dynamische routing
RIP/RIPng — concept
RIP gebruikt hop count als metric; maximum 15 hops. Het is eenvoudig maar convergeert traag en schaalt beperkt.
OSPF — kern
OSPF is een link-state IGP. Routers bouwen een link-state database en berekenen kortste paden. Alle interfaces binnen area 0 vormen de backbone.
router ospf 1
router-id 1.1.1.1
network 10.0.0.0 0.0.0.3 area 0
network 192.168.10.0 0.0.0.255 area 0
passive-interface g0/1
show ip ospf neighbor
show ip ospf interface brief
show ip route ospf
Wildcard mask = omgekeerde subnetmaskerbits; voor /24 is dit 0.0.0.255, voor /30 0.0.0.3.
Adjacencyproblemen: area mismatch, subnet mismatch, hello/dead timers, authenticatie, MTU of duplicate router ID.
ACL, NAT en DHCP
ACL
- Standard ACL matcht source IPv4; plaats dicht bij destination.
- Extended ACL matcht protocol, source, destination en poorten; plaats dicht bij source.
- Eerste match wint; onderaan staat impliciet
deny any.
ip access-list extended WEB_ONLY
permit tcp 192.168.10.0 0.0.0.255 host 192.168.20.10 eq 443
deny ip any any log
interface g0/1
ip access-group WEB_ONLY in
NAT/PAT
access-list 1 permit 192.168.10.0 0.0.0.255
interface g0/0
ip nat inside
interface g0/1
ip nat outside
ip nat inside source list 1 interface g0/1 overload
show ip nat translations
show ip nat statistics
DHCP-server op IOS
ip dhcp excluded-address 192.168.10.1 192.168.10.20
ip dhcp pool USERS
network 192.168.10.0 255.255.255.0
default-router 192.168.10.1
dns-server 192.168.20.10
domain-name lab.local
Voor een externe DHCP-server op een ander subnet:
Troubleshooting
show ip interface brief
show interfaces status
show vlan brief
show interfaces trunk
show spanning-tree
show etherchannel summary
show mac address-table
show arp
show ip route
show access-lists
ping <ip>
traceroute <ip>
Volgorde: fysieke link → interface/config → VLAN/accesspoort → trunk → STP/EtherChannel → IP/prefix → gateway/routing → ACL/NAT → applicatie.
Vergelijk beide uiteinden
De meeste labfouten zijn asymmetrisch: trunk aan één zijde, verkeerd subnetmasker, shutdown interface of ontbrekende return route.