Basic Switch/Router Configuration & Security (Ref Chapter 9 - ICND1)
Basic Switch/Router Configuration & Security (Ref Chapter 9 - ICND1)
Cisco2610-1(config)#line con 0
Cisco2610-1(config-line)#login
Cisco2610-1(config-line)#password cisco
Cisco2610-1(config-line)#logging synchronous
Cisco2610-1(config-line)#exec-timeout 30 0
Cisco2610-1(config)#line aux 0
Cisco2610-1(config-line)#login
Cisco2610-1(config-line)#password cisco
Cisco2610-1(config-line)#logging synchronous
Cisco2610-1(config-line)#exec-timeout 30 0
Enable password
Encrypting Passwords
R1(config)#service password-encryption
Cisco2610-1(config-line)#line vty 0 4
Cisco2610-1(config-line)#history size 20
R1#show history
Local User Database
Adding a user to the local database for Telnet that goes straight into privilege exec mode
Cisco2610-1(config)#line vty 0 4
Cisco2610-1(config-line)#login local
Cisco2610-1(config-line)#username test privilege 15 password test
OR
R1(config)#line vty 0 4
R1(config-line)#login local
R1(config-line)#transport input telnet ssh
R1(config-line)#exit
R1(config)#username cisco password cisco
Then
Check Connections
R1#show ssh
R1(config)#line vty 0 4
R1(config-line)#transport input ssh
Disable SSH
R1(config)#crypto key zeroize rsa
% All RSA keys will be removed.
% All router certs issued using these keys will
will also be removed.
Do you really want to remove these keys? [yes/no]: yes
Connecting to a Router using SSH
Using Putty
1. Open Putty
2. Enter the IP address of the router
3. Select SSH
4. Enter a name for the connection
5. Click on the Save button
6. Click on SSH
7. If your using an older router select Preferred SSH protocol version 1 for newer devices select 2
8. Click on Session and Click on the save button again
9. Click on the Open button
10. Click on Yes to accept the public key from the router
11. Enter the username and password you configured earlier
Cisco2610-1>enable
Password:
Cisco2610-1#config t
Enter configuration commands, one per line. End with CNTL/Z.
Cisco2610-1(config)#banner motd #
Enter TEXT message. End with the character '#'.
*************************************************************
This is Cisco test router 1 for my CCNA Lab
This router has security enabled
*************************************************************
#
Cisco2610-1(config)#banner login #
Enter TEXT message. End with the character '#'.
Test Login Banner
#
Cisco2610-1(config)#banner exec #
Enter TEXT message. End with the character '#'.
Test exec Banner
#
Assigning an IP address and default Gateway to a Switch/Router
Configure IP address
Cisco2610-1>enable
Password:
Cisco2610-1#configure t
Enter configuration commands, one per line. End with CNTL/Z.
Cisco2610-1(config)#interface s0/1
Cisco2610-1(config-if)#ip address 172.10.0.100 255.255.0.0
Cisco2610-1(config-if)#no shutdown
switch#
switch#config t
Enter configuration commands, one per line. End with CNTL/Z
switch(config)#ip default-gateway 172.16.0.200
switch(config)#
Cisco2610-1(config)#interface vlan1
Cisco2610-1(config-if)#ip address dhcp
Cisco2610-1(config-if)#no shutdown
Note: Some older switches/routers do not support being configured as a DHCP client
Configuring Switch Interfaces/Ports
Setting the Speed, Duplex and adding a description
switch(config)#interface fa0/1
switch(config-if)#speed 100
switch(config-if)#duplex full
switch(config-if)#description Connection to voice router
switch(config-if)#exit
Checking the status for all ports (not available on older switches/firmware)
switch#show interfaces status
Switch(config)#interface fa0/1
Switch(config-if)#switchport mode access
Switch(config-if)#switchport port-security mac-address 0000.0C06.705D
Switch(config-if)#switchport port-security
Switch(config-if)#switchport port-security maximum 1
Switch(config-if)#switchport port-security violation shutdown
Switch(config-if)#exit
Checking port-security
switch#show port-security
Disabling a Port
switch(config)#interface fa0/5
switch(config-if)#shutdown
Enabling a Port that has been shutdown by port security
switch(config)#interface fa0/5
switch(config-if)#shutdown
switch(config-if)#no shutdown
S2950-1#vlan database
S2950-1(vlan)#vlan 10 name VOICE
VLAN 10 modified:
Name: VOICE
S2950-1(vlan)#vlan 50 name DATA
VLAN 20 added:
Name: DATA
switch#config t
Enter configuration commands, one per line. End with CNTL/Z
switch(config)#vlan 2
switch(config-vlan)#name sales
switch(config-vlan)#
switch#
switch#
switch#config t
Enter configuration commands, one per line. End with CNTL/Z
switch(config)#vlan 3
switch(config-vlan)#name marketing
switch(config-vlan)#
switch#show vlan
switch#
switch#config t
Enter configuration commands, one per line. End with CNTL/Z
switch(config)#interface fastethernet0/1
switch(config-if)#switchport access vlan 2
switch(config-if)#
switch#config t
Enter configuration commands, one per line. End with CNTL/Z
switch(config)#interface fastethernet0/4
switch(config-if)#switchport access vlan 3
Router(config)#interface fa0/0
Router(config-if)#no shutdown
Router(config)#interface fa0/0.1
Router(config-subif)#ip address 10.1.1.1 255.255.255.0
Router(config-subif)#encapsulation dot1q 1
Router(config)#interface fa0/0.2
Router(config-subif)#ip address 10.1.2.1 255.255.255.0
Router(config-subif)#encapsulation dot1q 2
Router(config)#interface fa0/0.3
Router(config-subif)#ip address 10.1.3.1 255.255.255.0
Router(config-subif)#encapsulation dot1q 3
Set a VLAN to use trunking but not to encapsulate the VLAN ID in a trunking header
Router(config)#interface fa0/0.1
Router(config-subif)#encapsulation dot1q 1 native
Configuring Trunking between Switches
Changing an Interface to become a Trunk (set this on only one interface between two switches)
Switch(config)#interface fa0/3
Switch(config-if)#switchport mode trunk
or
Switch(config-if)#switchport mode dynamic desirable
Removing a VLAN from a trunk (this will need doing on each switch)
AccessLayerSwitch2(config)#interface range g1/1-2
AccessLayerSwitch2(config-if-range)#switchport trunk allowed vlan remove 4
Changing the encapsulation a trunk uses(most switches only support 802.1q so dont support these commands)
Switch(config-if)#switchport trunk encapsulation isl
or
Switch(config-if)#switchport trunk encapsulation negotiate
Configuring VTP between two Switches
Configuring a VLAN to become a secondary root switch for that VLAN only
SW1(config)#spanning-tree vlan 3 root secondary
Configuring the priority of a switch to make it the root switch for a VLAN only
SW1(config)#spanning-tree vlan 3 priority 1000
Enabling PVST
SW1(config)#spanning-tree mode pvst
Enabling MIST
SW1(config)#spanning-tree mode mst
Enable CDP
switch(config)#cdp run
Switch(config)#cdp timer 90
Switch(config)#cdp holdtime 240
Displays info on the VLAN’s and which interfaces have been assigned to them
Switch#show Vlan
MAC Address Table Commands
switch#show mac-address-table
S3500XL-1#show mac-address-table
Dynamic Address Count: 2
Secure Address Count: 0
Static Address (User-defined) Count: 0
System Self Address Count: 51
Total MAC addresses: 53
Maximum MAC addresses: 8192
Non-static Address Table:
Destination Address Address Type VLAN Destination Port
------------------- ------------ ---- --------------------
0004.277f.0000 Dynamic 1 FastEthernet0/6
0007.e918.d07b Dynamic 1 FastEthernet0/12
router#show ip route
Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, * - candidate default
U - per-user static route, o - ODR, P - periodic downloaded static route
T - traffic engineered route
router#show protocols
Global values:
Internet protocol routing is enabled
Serial0/0/0 is administratively down, line protocol is down
Serial0/0/1 is up, line protocol is up
Internet address is 10.1.128.251/24
Serial0/1/0 is up, line protocol is up
Internet address is 10.1.130.251/24
Serial0/1/1 is administratively down, line protocol is down
FastEthernet0/0 is up, line protocol is up
Internet address is 10.1.1.251/24
FastEthernet0/1 is up, line protocol is up
Internet address is 10.1.100.251/24
Albuquerque#show protocols fa0/0
% Incomplete command.
router>enable
router#config t
Enter configuration commands, one per line. End with CNTL/Z
router(config)#interface serial0/0/1
router(config-if)#clock rate 128000
router(config-if)#bandwidth 64
Interface Serial0/0/1
Hardware is GT96K
DCE V.35 clock rate 128000
idb at 0x454E69C8, driver data structure at 0x454EE0EC
router#show running-config
interface Serial0/0/1
bandwidth 64
ip address 10.1.128.251 255.255.255.0
no ip directed-broadcast
Backing up and Restoring IOS and configuration files Image
Setting the Configuration Register to load using image specified in boot system command
router(config)#config-register 0x2102 (Default Setting)
or
router(config)#config-register 0x210F
Boot System Commands - IOS with the name filename is loaded from flash memory
router(config)#boot system flash filename
Boot System Commands - IOS with the name filename is loaded from tftp server
router(config)#boot system flash filename 10.0.0.1
Routing Protocols (Chapter 14)
Enabling rip v2
router(config)#router rip
router(config-router)#version 2
router(config-router)#network 10.0.0.0
router(config-router)#network 172.1.0.0
Display the mask in decimal rather than prefix when using show ip route command
router#terminal ip netmask-format decimal
Disable Autosummarisation (can only do on classless routing protocols and can't do it on OSPF)
router(config)#router rip
router(config-router)#no auto-summary
Troubleshooting IP Routing (Chapter 15)
Display a routers ARP cache
router#show ip arp
Additional Commands
Configuring DCHP Pool
BGRouter(config)#interface fa0/0
BGRouter(config-if)#ip nat inside
BGRouter(config-if)#exit
BGRouter(config)#interface s0/0
BGRouter(config-if)#ip nat outside
BGRouter(config-if)#exit
BGRouter(config)#access-list 1 permit 10.0.0.11
BGRouter(config)#access-list 1 permit 10.0.0.12
BGRouter(config)#ip nat pool SalesPool 198.18.194.73 198.18.194.78 netmask 255.255.255.248
BGRouter(config)#ip nat inside source list 1 pool SalesPool overload
BGRouter(config)#exit
You’ll need to add a route back to the 198.18.194.0 address range from the ISP router
Configuring NAT to Allow Any Address in the 192 Range to use NAT
router(config)#access-list 1 permit 192.0.1.0 0.255.255.255
Extended ACLs
Block any IP packet from any source address to destination IP address 10.1.4.4
R3(config-if)#ip access-group 100 out
R3(config-if)#exit
R3(config)#access-list 100 deny ip any host 10.1.4.4
R3(config)#access-list 100 permit ip any 0.0.0.0 255.255.255.255
Block tcp packets with a source greater than 1023 and a source IP 10.1.4.1 and port of 21
R3(config)#access-list 100 deny tcp any gt 1023 host 10.1.4.3 eq 21
R3(config)#access-list 100 permit ip any 0.0.0.0 255.255.255.255
Allow tcp packets from 10.1.1.0 network to connect to destination 10.1.4.3 on port 21
R3(config)# access-list 100 permit tcp 10.1.1.0 0.0.0.255 host 10.1.4.3 eq 21
Multiple ACL entries (Routers read ACLs in order entered if the last one was entered first the others would not be
applied as this one allows all traffic. same goes for the first one if that was applied after the third one it would not
work)
R3(config)# access-list 100 permit tcp 10.1.1.0 0.0.0.255 host 10.1.4.3 eq 21
R3(config)#access-list 100 deny ip any host 10.1.4.4
R3(config)#access-list 100 deny tcp any host 10.1.4.3 eq ftp
R3(config)#access-list 100 permit ip any any
Named ACLs (these can be used for standard and extended ACLs)
Block all outbound traffic from 10.1.1.3 out one interface on a router
R1(config)#ip access-list extended BlockOutbound1
R1(config-ext-nacl)#deny ip host 10.1.1.3 any
R1(config-ext-nacl)#permit ip any any
R1(config-ext-nacl)#exit
R1(config)#interface s0/1
R1(config-if)#ip access-group BlockOutbound1 out
Block all inbound traffic to 10.1.4.4 & block all ftp traffic to 10.1.4.3 apart from devices on the 10.1.1.0 network
R3(config)#ip access-list extended BlockInbound1
R3(config-ext-nacl)#deny ip any host 10.1.4.4
R3(config-ext-nacl)#permit tcp 10.1.1.0 0.0.0.255 host 10.1.4.3 eq ftp
R3(config-ext-nacl)#deny tcp any host 10.1.4.3 eq ftp
R3(config-ext-nacl)#permit ip any any
R3(config-ext-nacl)#exit
R3(config)#interface fa1/0
R3(config-if)#ip access-group BlockInbound1 out
Manipulating ACLs Using Sequence Numbers
(works on IOS 12.3 or later and doesn't work in Packet Tracer)
Create Access List (notice sequence numbers using the show command)
R1(config)#ip access-list standard 1
R1(config-std-nacl)#deny 10.1.2.0 0.0.255.255
R1(config-std-nacl)#deny 10.2.3.0 0.0.255.255
R1(config-std-nacl)#permit any
R1(config-std-nacl)#exit
R1(config)#do show access-list 1
Standard IP access list 1
10 deny 10.1.0.0, wildcard bits 0.0.255.255
20 deny 10.2.0.0, wildcard bits 0.0.255.255
30 permit any
Removing an entry
R1(config-std-nacl)#no 20
R1(config-std-nacl)#do show access-list
Standard IP access list 1
10 deny 10.1.0.0, wildcard bits 0.0.255.255
25 deny 10.3.0.0, wildcard bits 0.0.255.255
30 permit any
R2(config)#line vty 0 15
R2(config-line)#access-class in
R2(config)#exit
R2(config)#access-list 3 deny any