Code Snippets
Cisco Networking & Security Snippets
Basic Router Config
Set Hostname
Router(config)# hostname MyRouter
Interface Config
Router(config)# interface FastEthernet0/0
Router(config-if)# ip address 192.168.1.1 255.255.255.0
Enable Interface
Router(config-if)# no shutdown
Set Description
Router(config-if)# description LAN Interface
Basic Switch Config
Set VLAN
Switch(config)# vlan 10
Name VLAN
Switch(config-vlan)# name SALES
Set Switch Hostname
Switch(config)# hostname MySwitch
Enable Switchport
Switch(config-if)# no shutdown
Basic Networking Security
Enable Password
Router(config)# enable secret mypassword
Console Password
Router(config)# line console 0
Router(config-line)# password cisco
VTY Password
Router(config)# line vty 0 4
Router(config-line)# password cisco
Login Requirement
Router(config-line)# login
ACLs
Standard ACL
Router(config)# access-list 1 deny 192.168.1.0 0.0.0.255
Extended ACL
Router(config)# access-list 100 permit tcp 192.168.1.0 0.0.0.255 any eq 80
Apply ACL
Router(config)# interface FastEthernet0/0
Router(config-if)# ip access-group 100 in
Named ACL
Router(config)# ip access-list standard BLOCK
Router(config-std-nacl)# deny 10.0.0.0 0.255.255.255
VLANS
Assign Port to VLAN
Switch(config-if)# switchport access vlan 10
Trunk Port
Switch(config-if)# switchport mode trunk
VLAN Name
Switch(config)# vlan 20
Switch(config-vlan)# name ENGINEERING
Show VLANs
Switch# show vlan brief
Access Levels
Privileged Mode
Router# enable
Global Config Mode
Router# configure terminal
Interface Config Mode
Router(config)# interface FastEthernet0/0
Back to categories