April 10, 2018

Cisco router/switch commands

❑ Change hostname.
Router(config)#hostname r1
r1(config)#


❑ Set the port password for accessing.
Router(config)#line console 0
* Possible : line vty 0 4
* Impossible : interface serial x/x/x, interface gigabitEthernet x/x
Router(config-line)#password 1q2w3e4r
Router(config-line)#login
* login : Enable using password.


❑ Set the mode password.
* If both "enable password" and "enable secret" are set, the secret configuration is applied.
Router(config)#enable password 1q2w3e4r
Router(config)#enable secret 1q2w3e4r!


❑ Change banner message.
Router#en
Router#conf t
Router(config)#banner motd #
Enter TEXT message.  End with the character '#'.
hello!! this is cisco router!!#


❑ Display configuration and state.
❍ Router(config)#do show running-config : Display current running config.
❍ Router#show running-config : Display current running config.
❍ Router#show ip interface brief : Display interfaces simply.
❍ Router#show interfaces serial 0/2/0 : Display configurations of a specific interface.
❍ R1#show ip ospf neighbor : Display neighboring router information.
❍ R1#show ip protocols : Display the routing protocol information.
❍ Switch#show port-security : Display port-security configuration
❍ Switch#show spanning-tree : Display STP related election results of root bridge and ports.
❍ Switch#show version : Display HW/SW specifications such as MAC address and model.


❑ Apply current configurations also after reboot.
❍ Router#copy running-config startup-config
Building configuration...
[OK]
❍ Router#write memory
Building configuration...
[OK]


❑ Remove startup configuration.
Router#erase startup-config
Erasing the nvram filesystem will remove all configuration files! Continue? [confirm]
[OK]
Erase of nvram: complete


❑ Reboot the router.
Router#reload
Proceed with reload? [confirm]


❑ Abort searching the typo.
Translating "end"...domain server (255.255.255.255)
→ ctrl + shift + 6
% Name lookup aborted


❑ Disable searching the typo.
Router(config)#no ip domain-lookup


❑ On/Off the port.
Router(config)#interface GigabitEthernet0/1
Router(config-if)#no shutdown(or shutdown)


❑ Allocate the IP address.
Router(config)#interface GigabitEthernet0/1
Router(config-if)#ip address 192.168.0.1 255.255.255.0


❑ Set the clock rate.
Router(config)#interface Serial0/2/1
Router(config-if)#clock rate 64000


❑ Check the routing table.
❍ Router#show ip route
❍ Router(config)#do show ip route


❑ Set static routing.
Router(config)#ip route 203.230.9.0 255.255.255.0 203.230.8.2
Router(config)#ip route 203.230.10.0 255.255.255.0 203.230.8.2
Router(config)#ip route 203.230.11.0 255.255.255.0 203.230.8.2


❑ Set dynamic routing RIP2.
Router(config)#router rip
Router(config-router)#network 203.230.9.0
Router(config-router)#version 2
Router(config-router)#no auto-summary


❑ Set dynamic routing EIGRP.
R1(config)#router eigrp 7
* R1(config)#router eigrp [Process ID(AS number)]
R1(config-router)#network 203.230.7.0
R1(config-router)#network 203.230.10.0
R1(config-router)#network 203.230.11.0
R1(config-router)#network 1.0.0.0
* R1(config-router)#network 
[Network address]
R1(config-router)#no auto-summary


❑ Set dynamic routing OSPF.
R1(config)#router ospf 7
* R1(config)#router ospf [Process ID]
R1(config-router)#network 203.230.9.0 0.0.0.0 area 0
R1(config-router)#network 203.230.10.0 0.0.0.0 area 0
R1(config-router)#network 1.1.1.1 0.0.0.0 area 0
* R1(config-router)#network [Network address] [Wild card mask] area [Area ID]


❑ Set dynamic routing RIP2.
Router(config)#router rip
Router(config-router)#network 203.230.9.0
Router(config-router)#version 2


❑ Set VLAN : Divides the area of existing LAN.
e.g. Create VLan 10, VLan 20, and VLan 30 and assigns interfaces to each of them.
Switch(config)#vlan 10
Switch(config-vlan)#name VLAN_10
Switch(config-vlan)#vlan 20
Switch(config-vlan)#name VLAN_20
Switch(config-vlan)#exit
Switch(config)#vlan 30
Switch(config-vlan)#name VLAN_30

Switch(config)#int fastEthernet 0/1
Switch(config-if)#switchport mode access
Switch(config-if)#switchport access vlan 10
Switch(config-if)#exit
Switch(config)#int fastEthernet 0/2
Switch(config-if)#switchport mode access
Switch(config-if)#switchport access vlan 20
Switch(config-if)#exit

Switch(config)#int fastEthernet 0/3
Switch(config-if)#switchport mode trunk
Switch(config-if)#exit
* VLAN Trunk transmits the VLAN frame without distinguishing the VLAN ID.


❑ Set Inter VLAN : Communication between VLANs. It is supported by the router's virtual interface.
e.g. Set Inter VLAN configuration so that VLAN 10 and VLAN 20 can communicate with each other.
Router(config)#int gi0/0
Router(config-if)#no shu
Router(config-if)#no shutdown

Router(config)#int gi0/0.10
* Router(config)#int gi0/0.[Generally VLan ID]
Router(config-subif)#encapsulation dot1Q 10
* Router(config-subif)#encapsulation dot1Q [VLan ID]
Router(config-subif)#ip address 203.230.7.1 255.255.255.0

Router(config-subif)#int gi0/0.20
Router(config-subif)#encapsulation dot1Q 20
Router(config-subif)#ip address 203.230.8.1 255.255.255.0
※ Also refer this Inter VLAN example.


❑ Set an IP address for telnet connection to the switch
Switch(config)#enable password enpass
Switch(config)#int vlan 1
Switch(config-if)#ip addr 192.168.1.5 255.255.255.0
Switch(config-if)#no shutdown
Switch(config-if)#exit
Switch(config)#line vty 0 15
Switch(config-line)#password 1234
Switch(config-line)#login


❑ Set switch port security.
e.g. Communication is restricted except the terminal of specified MAC address.
* restrict : protect(Blocking communication) + log
* shutdown : shutdown the interface.
Switch(config)#interface fa 0/1
Switch(config-if)#switchport mode access
Switch(config-if)#switchport port-security
Switch(config-if)#switchport port-security maximum 1
Switch(config-if)#switchport port-security mac-address 000D.xxxx.E478
Switch(config-if)#switchport port-security violation restrict
* Switch(config-if)#switchport port-security violation [protect | restrict | shutdown]