title: Cisco IOS Switches
breadcrumbs:
- title: Configuration
- title: Network
---
{% include header.md %}
Related Pages
{:.no_toc}
Using
{:.no_toc}
- Catalyst 2950
- Catalyst 2960G
- Catalyst 3750G
Initial Configuration
- 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 (Norway):
- Time zone:
clock timezone UTC 1 0
- Automatic summer time:
clock summer-time CEST recurring last Sun Mar 2:00 last Sun Oct 3:00
- 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 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. 10 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
General Configuration
Simple Actions
- 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
Reset the Configuration
- Delete the config:
erase startup-config
- Delete the VLAN DB:
delete flash:vlan.dat
- Show files:
sh flash:
- Delete
.renamed
files too.
- Reload:
reload
Services and Features
- CDP:
- It may leak information.
- Disable globally:
no cdp run
- VTP:
- It may fuck up the trunks when an out-of-sync VTP switch joins.
- Disable globally:
vtp mode (off | transparent)
- DTP:
- It may facilitate switch spoofing and VLAN hopping.
- Disable it for each switch port:
switchport nonegotiate
- UDLD:
- Generally only useful for fiber.
- Disable globally: TODO
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.
Theory
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.
Resources
{% include footer.md %}