HON’s Wiki # Cisco Catalyst Switches (IOS/IOS XE)
Home / Networking
Contents
I keep most of my Cisco notes elsewhere, sorry.
Related Pages
Initial Configuration
An example of a full configuration for Catalyst 3750G.
- Connect using serial.
- Don’t enter initial configuration (it’s useless).
- Enter privileged exec mode:
enable
- Enter configuration mode:
conf t
- Set the hostname and domain name:
hostname <hostname>
ip domain-name <domain>
(the part after the hostname)
- Set the time zone (for Norway) and time:
- Time zone:
clock timezone UTC 1 0
(Norway)
- Automatic summer time:
clock summer-time CEST recurring last Sun Mar 2:00 last Sun Oct 3:00
(Norway)
- Set the time (exec mode):
clock set 10:50:00 Oct 26 2006
(example)
- Show the current time (exec mode):
show clock
- Disable unused features/services:
no service config
no service pad
no service password-encryption
vtp mode off
no cdp run
no ip source-route
no ip domain-lookup
no ip http server
no ip http secure-server
- Setup console:
- Enter console config:
line con 0
- Enable synchronous logging:
logging synchronous
- Setup logging:
- Change buffer size and max level:
logging buffered 16384 warnings
- Log important messages to console:
logging console critical
- Setup user login:
- Enable new model AAA:
aaa new-model
- Set the enable secret (e.g. to “secret”):
enable algorithm-type scrypt secret <secret>
- Add a user:
username <username> privilege 15 algorithm-type scrypt secret <password>
- Set local login as default:
aaa authentication login default local
- Enable console local login:
line con 0
login authentication default
- Configure SSH:
- Generate SSH server cert:
crypto key generate rsa modulus 2048
- Set version:
ip ssh version 2
- Set VTY lines to use SSH:
- Enter line config:
line vty 0 15
- Set to use SSH:
transport input ssh
- Set the timeout:
exec-timeout <minutes> <seconds>
(e.g. 15 minutes)
- (Optional) Add default native vlan and black hole VLAN:
- Never use the default native VLAN.
- Use the black hole VLAN as the native VLAN for trunks without an untagged VLAN, as it can’t be simply disabled on some switches.
- Setup default native VLAN:
int vlan 1
, desc default-native, shut
- Setup black-hole native VLAN:
vlan 2
, name black-hole
, shut
, int vlan 2
, desc black-hole
, shut
- Configure VLANs and VLAN interfaces:
- Enter VLAN config:
vlan <VID>
- Set name:
name <name>
- (Optional) Shut down:
shutdown
- Enter VLAN interface config:
interface vlan<vid>
- Set description:
description <description>
- (Optional) Shut down:
shutdown
- Configure LAGs (LACP):
- Set load balancing method (globally):
port-channel load-balance src-dst-ip
- Enter LAG config:
interface port-channel <id>
- Set description:
description <description>
- Add interfaces (int config):
channel-group <id> mode active
- Configure ports:
- If using LAG:
- Connect it:
channel-group <id> mode active
- Configure the LAG, not the interface range.
- Add access port:
switchport access vlan <VID>
switchport mode access
- Disable DTP:
switchport nonegotiate
spanning-tree portfast
spanning-tree bpduguard enable
(if not enabled globally)
- Setup other security features (see section below.)
- Add trunk port:
switchport trunk encapsulation dot1q
(the default on 2960G and cannot be set manually)
switchport trunk native vlan <vid>
switchport trunk allowed vlan <vid>[,<vid>]*
switchport mode trunk
- Disable DTP:
switchport nonegotiate
- Enable root guard if facing a lower-tier switch:
spanning-tree guard root
- Disable unused ports:
shutdown
- Configure spanning tree (rapid-pvst):
- Mode:
spanning-tree mode rapid-pvst
spanning-tree extend system-id
- Configure VLANs:
spanning-tree vlan <vid-list>
spanning-tree vlan <vid-list> priority <priority>
- Set management IP address and default gateway:
- Enter the chosen management VLAN.
- Set a management IP address:
ip address <address> <subnet-mask>
- Set the default gateway (global config):
ip default-gateway <address>
- (Optional) Configure NTP client:
ntp server <address>
- Show status:
sh ntp assoc
sh ntp status
- Configure access port security features:
- Storm control:
- Enter the interface config.
storm-control broadcast level bps 3m
(3Mbps broadcast)
storm-control multicast level bps 3m
(3Mbps multicast)
- By default it will only filter excess packets.
- DHCP snooping:
- DHCP snooping keeps a database DHCP leases. It can provide certain DHCP protection features, like rate limiting. It is used by some other security features.
ip dhcp snooping
ip dhcp snooping vlan <vid-list>
(for user VLANs)
ip dhcp snooping verify mac-address
(applies to DHCP packets)
- Set trusted interfaces (if config):
ip dhcp snooping trust
- Limit DHCP packets (if config):
ip dhcp snooping limit rate 25
(25/s)
- Verify that it’s enabled:
sh ip dhcp snooping
- Port security:
- Port security limites the amount of MAC addresses that may be used by a single port.
- TL;DR, it validates MAC-to-port bindings.
- Enter the interface config.
switch port-sec
switch port-sec max 1
(1 MAC address)
switch port-sec violation restrict
(don’t shut down port)
switch port-sec aging type inactivity
switch port-sec aging time 1
(1 minute)
- IP source guard (IPSG) (IPv4):
- IPSG verifies that packets from a port match the IP addresses and optionally MAC adresses in the DHCP snooping DB.
- TL;DR, it validates IP-to-port bindings.
- Enter interface config.
ip verify source
- An extra argument
port-security
can be specified which specified that MAC addresses should also be checked. If not specified, it only checks IP addresses. It requires that the server supports option 82.
- Dynamic ARP inspection (DAI) (IPv4):
- DAI uses the DHCP snooping DB and is similar to IPSG, but only applies to ARP packets.
- TL;DR, it validates IP-to-MAC bindings.
ip arp inspection vlan <vid-list>
- Enter the interface config.
- On trusted interfaces:
ip arp inspection trust
- Verify configuration:
sh ip arp inspection
- TODO: DHCPv6 snooping and other IPv6 security mechanisms.
- Configure remote syslog delivery:
logging host <address>
logging facility syslog
- Configure SNMP daemon:
snmp-server community public RO
- TODO
- Configure SNMP traps:
- TODO
- Save the config:
copy run start
- (Optional) Copy the config to a TFTP server:
copy start tftp://<host>/<path>
General Configuration
Basics
- Show statuses:
- L3 port overview:
sh ip int br
- L2 port overview:
sh int status
- Port statistics:
sh int <if>
- Err-disable:
sh int status err-disabled
- STP blocked ports:
sh span blockedports
- STP blocked VLANS:
sh span summary
- Show/search log:
sh log | i <search-text>
Spanning Tree
- Enable BPDU guard globally to automatically enable it om ports with portfast. Or don’t.
- Only enable loop guard for links which may become uni-directional and which have UDLD enabled.
- Show err-disabled ports:
sh int status err-disabled
- Show blocked ports:
sh span blockedports
- Show blocked VLANS:
sh span summary
- Show STP neighbors: `` TODO
IPv4 First-Hop Security
TODO: DHCP snooping, MAC checking etc.
IPv6 First-Hop Security
- Binding table:
- Built by ND and DHCP snooping/gleaning and used by guard features.
- Destination guard: TODO
Features
VLAN Trunking Protocol (VTP)
- Cisco-proprietary.
- It may fuck up the trunks when an out-of-sync VTP switch joins.
- Disable globally:
vtp mode (off | transparent)
Dynamic Trunking Protocol (DTP)
- Cisco-proprietary.
- It may facilitate switch spoofing and VLAN hopping.
- Disable it for each switch port:
switchport nonegotiate
StackWise
- For switch stacking, creating a single, logical switch.
- Supported by certain Catalyst switches.
- Uses special ports and proprietary cables.
Virtual Switching System (VSS) (aka StackWise Virtual)
- Also called Stackwise Virtual as it is an evolution of StackWise.
- Supported by certain Catalyst switches.
- Uses conventional network ports.
Tasks
Reset the Configuration
- Show files:
sh flash:
- Delete the config files:
delete flash:config.text
delete flash:private-config.text
delete flash:vlan.dat
- Delete any
.backup
and .renamed
files too.
- Reload:
reload
- Not required if the “mode” button was used to reset the device.
Without CLI Access
Hold the “mode” button for 30 seconds or until it says in the console that it’s restarting and clearing the configuration.
Miscellanea
Ports and VLANs
- Use trunks between switches. Avoid using native VLANs with trunks if possible.
- User ports:
- Untrusted.
- Generally, configure it as an access port.
- Disable services/protocols like CDP, VTP, DTP, etc.
- Disable automatic PaGP/LACP.
- Enable portfast.
- Enable BPDU guard, unless configured globally.
- Enable port security to limit the amount of MAC addresses using that port. MAC flooding can result in full MAC tables, which causes all frames to be flooded.
- Enable ARP inspection to prevent ARP spoofing.
- Ports to switches:
- Generally, configure it as a trunk port without a native VLAN.
- Enable root guard if facing switches on lower topological tiers.
- Unused ports:
- Native VLAN:
- Be careful not to have a native VLAN spanning the entire area.
- Avoid using VLAN 1 (the default VLAN).
- Consider adding a new VLAN (e.g. VLAN 2) and shutting it down, then using it as the native VLAN of trunks. This effectively disables the native VLAN for those trunks.
- User VLANs should never be a native VLAN on any trunk. It can enable VLAN hopping through double tagging.
Port Lights
- Status mode:
- Off: No link or administratively down.
- Green: Link present.
- Blinking green: Activity.
- Alternating green-amber: Link fault. Could be caused by hardware errors or mismatched speed or duplex.
- Amber and blinking amber: Blocked by STP.
hon.one
| HON95/wiki
| Edit page