Cisco路由器及交換機口令集合
交換機口令設(shè)置:
switch>enable ;進入特權(quán)模式
switch#config terminal ;進入全局配置模式
switch(config)#hostname ;設(shè)置交換機主機名
switch(config)#enable secret xxx ;設(shè)置特權(quán)加密口令為xxx
switch(config)#enable password xxx ;設(shè)置特權(quán)非密口令為xxx
switch(config)#line console 0 ;進入控制口(Rs232)初始化
switch(config-line)#line vty 0 4 ;進入虛擬終端virtual tty
switch(config-line)#login ;允許登錄
switch(config-line)password xx ;設(shè)置登錄口令xx
switch#exit ;返回命令
交換機VLAN設(shè)置:
switch#vlan database ;進入VLAN設(shè)置
switch(vlan)#vlan 2 ;建VLAN 2
switch(vlan)#no vlan 2 ;刪VLAN 2
switch(config)#int f0/1 ;進入端口1
switch(config-if)#switchport access vlan 2 ;當前端口1加入VLAN 2
switch(config-if)#switchport mode trunk ;設(shè)置為干線
switch(config-if)#switchport trunk allowed vlan 1,2 ;設(shè)置允許的VLAN
switch(config-if)#switchport trunk encap dot1q ;設(shè)置VLAN中繼
switch(config)#vtp domain ;設(shè)置VTP域名
switch(config)#vtp password
switch(config)#vtp mode server
switch(config)#vtp mode client
交換機設(shè)置IP地址:
switch(config)#interface vlan 1 ;進入VLAN 1
switch(config-if)#ip address ;添加遠程登錄IP
switch(config)#ip default-gateway ;添加默認網(wǎng)關(guān)
switch#dir flash ;查看內(nèi)存
交換機顯示命令:
switch#write ;寫入保存
switch#show vtp
switch#show run ;查看當前配置信息
switch#show vlan ;看VLAN
switch#show interface ;查看所有端口信息
switch#show int f0/0 ;顯示端口0的信息
路由器顯示命令:
router#show run ;顯示接口
router#show interface ;顯示接口
router#show ip route ;顯示路由
touter#show cdp nei ;看鄰居
router#reload ;重新啟動
設(shè)置口令:
router>enable ;進入特權(quán)模式
router#config terminal ;進入全局配置模式
router(config)#hostname ;設(shè)置交換機的主機名
router(config)#enable secret xxx ;設(shè)置特權(quán)加密口令為xxx
router(config)#enable password xxx ;設(shè)置特權(quán)非密口令為xxx
router(config)#line console 0 ;進入控制臺(Rs232)初始化
router(config-line)#line vty 0 4 ;進入虛擬終端virtual tty
router(config-line)#login ;允許登錄
router(config-line)password xx ;設(shè)置登錄口令xx
router(config)#(Ctrl+z) ;返回特權(quán)模式
switch#exit ;返回命令
配置IP地址:
router(config)#int s0/0 ;進行串serail接口
router(config-if)#no shutdown ;啟動接口
router(config-if)#clock rate 6400 ;設(shè)置時鐘
router(config-if)#ip address 10.1.1.1 255.255.0.0 ;設(shè)置IP地址和子網(wǎng)掩碼
router(config-if)#ip add 10.1.1.2 255.255.0.0 second
router(config-if)#int f0/0.1 ;進入子接口
router(config-subif.1)#ip address
router(config-subif.1)#encapsulation dot1q
router(config)#config-register 0x2142 ;跳過配置文件
router(config)#config-register 0x2102 ;正常使用配置文件
router#reload ;重新引導
復制操作:
router#copy running-config starup-config ;存配置
router#copy running-config tftp ;上載
router#copy startup-config tftp
router#copy tftp flash: ;特權(quán)模式下升級IOS
router#copy tftp startup-config ;下載配置文件到nvram
ROM狀態(tài):
Ctrl+Break ;進入ROM監(jiān)控狀態(tài)
rommon>confreg 0x2142 ;跳過配置,26 36 45xx
rommon>confreg 0x2102 ;使用配置,恢復工作狀態(tài)
rommon>reset ;重新引導,等效于重新開機
rommon>copy xmodem: flash ;從console升級IOS
IOS:
rommon>IP_ADDRESS=10.65.1.2
rommon>IP_SUNNET_MASK=255.255.0.0
rommon>TFTP_SERVER=10.65.1.1
rommon>TFTP_FILE=c2600.bin
rommon>tftpdnld
rommon>dir flash:
rommon>boot
#p#
靜態(tài)路由:
ip toute
例:
router(config)#ip toute 10.1.0.0 255.255.0.0 10.2.1.1
router(config)#ip route 0.0.0.0 0.0.0.0 1.1.1.2
動態(tài)路由:
router(config)#ip routing ;啟動路由
router(config)#router rip ;啟動RIP路由協(xié)議
router(config-router)#network ;配置范圍,有的支持all
router(config-router)#negihbor ;點對點
幀中繼命令:
router(config)#frame-relay switching ;使能幀中繼交換
router(config-s0)#encapsulation frame-relay ;使能幀中繼
router(config-s0)#frame-relay intf-type DCE ;DCE端(需要配虛電路)
touter(config-s0)#farme-relay local-dlci 20 ;配置虛電路號
基本訪問控制列表:
router(config)#access-list permit|deny
router(config)#interface ;default:deny any
router(config-if)#ip access-group in|out ;default:out
例:
RB(config)#access-list 4 permit 10.8.1.1
RB(config)#access-list 4 deny 10.8.1.0 0.0.0.255
RB(config)#access-list 4 permit 10.8.0.0 0.0.255.255
RB(config)#access-list 4 deny 10.0.0.0 0.255.255.255
RB(config)#access-list 4 permit any
RB(config)#int f0/0
RB(config-if)#ip access-group 4 in
擴展訪問列表:
access-list permit|deny icmp [port]
例1:
router(config)#access-list 101 deny icmp any 10.64.0.2 0.0.0.0 echo
router(config)#access-list 101 permit ip any any
router(config)#int s0/0
router(config-if)#ip access-group 101 in
例2:
router(config)#access-list 102 deny tcp any 10.65.0.2 0.0.0.0 eq 80
router(config)#access-list 102 permit ip any any
router(config)#interface s0/1
router(config-if)#ip access-group 102 out
router(config)#no access-list 102
router(config-if)#no ip access-group 101 in
在路由器上設(shè)置SNMP Community Strings:
router(config)#snmp-server community read-community-string ro
router(config)#snmp-server community write-community-string rw
在交換機上設(shè)置SNMP Community Strings:
switch(config)#snmp-server community read-community-strings ro
switch(config)#snmp-server community write-community-strings rw
在路由器上配置日志信息(Syslog Message logging):
router(config)#logging on
router(config)#logging server-ip-address
router(config)#logging trap serverity-level
路由器恢復出廠設(shè)置
erase start-config
或write erase
或erase NVROM