交換機基本狀態: switch: ;ROM狀態, 路由器是rommon>hostname> ;用戶模式hostname# ;特權模式hostname(config)# ;全局配置模式hostname(config-if)# ;接口狀態
交換機口令設置: switch>enable ;進入特權模式switch#config terminal ;進入全局配置模式switch(config)#hostname ;設置交換機的主機名switch(config)#enable secret xxx ;設置特權加密口令switch(config)#enable password xxa ;設置特權非密口令switch(config)#line console 0 ;進入控制臺口switch(config-line)#line vty 0 4 ;進入虛擬終端switch(config-line)#login ;允許登錄switch(config-line)#password xx ;設置登錄口令xxswitch#exit ;返回命令
交換機VLAN設置:
switch#vlan database ;進入VLAN設置switch(vlan)#vlan 2 ;建VLAN 2switch(vlan)#no vlan 2 ;刪vlan 2switch(config)#int f0/1 ;進入端口1switch(config-if)#switchport access vlan 2 ;當前端口加入vlan 2switch(config-if)#switchport mode trunk ;設置為幹線switch(config-if)#switchport trunk allowed vlan 1,2 ;設置允許的vlanswitch(config-if)#switchport trunk encap dot1q ;設置vlan 中繼switch(config)#vtp domain ;設置發vtp域名switch(config)#vtp password ;設置發vtp密碼switch(config)#vtp mode server ;設置發vtp模式switch(config)#vtp mode client ;設置發vtp模式
交換機設置IP地址:
switch(config)#interface vlan 1 ;進入vlan 1switch(config-if)#ip address ;設置IP地址switch(config)#ip default-gateway ;設置默認網關switch#dir flash: ;查看閃存
交換機顯示命令:
switch#write ;保存配置信息switch#show vtp ;查看vtp配置信息switch#show run ;查看當前配置信息switch#show vlan ;查看vlan配置信息switch#show interface ;查看端口信息switch#show int f0/0 ;查看指定端口信息
2. 路由器支持的命令:
路由器顯示命令:
router#show run ;顯示配置信息router#show interface ;顯示接口信息router#show ip route ;顯示路由信息router#show cdp nei ;顯示鄰居信息router#reload ;重新起動
路由器口令設置:
router>enable ;進入特權模式router#config terminal ;進入全局配置模式router(config)#hostname ;設置交換機的主機名router(config)#enable secret xxx ;設置特權加密口令router(config)#enable password xxb ;設置特權非密口令router(config)#line console 0 ;進入控制臺口router(config-line)#line vty 0 4 ;進入虛擬終端router(config-line)#login ;要求口令驗證router(config-line)#password xx ;設置登錄口令xxrouter(config)#(Ctrl+z) ; 返回特權模式router#exit ;返回命令
路由器配置:
router(config)#int s0/0 ;進入Serail接口router(config-if)#no shutdown ;激活當前接口router(config-if)#clock rate 64000 ;設置同步時鐘router(config-if)#ip address ;設置IP地址router(config-if)#ip address second ;設置第二個IProuter(config-if)#int f0/0.1 ;進入子接口router(config-subif.1)#ip address ;設置子接口IProuter(config-subif.1)#encapsulation dot1q ;綁定vlan中繼協議router(config)#config-register 0x2142 ;跳過配置文件router(config)#config-register 0x2102 ;正常使用配置文件router#reload ;重新引導
路由器文件操作:
router#copy running-config startup-config ;保存配置router#copy running-config tftp ;保存配置到tftprouter#copy startup-config tftp ;開機配置存到tftprouter#copy tftp flash: ;下傳文件到flashrouter#copy tftp startup-config;下載配置文件ROM狀態:
Ctrl+Break ;進入ROM監控狀態
rommon>confreg 0x2142 ;跳過配置文件
rommon>confreg 0x2102 ;恢復配置文件
rommon>reset ;重新引導
rommon>copy xmodem: flash: ;從console傳輸文件
rommon>IP_ADDRESS=10.65.1.2 ;設置路由器IP
rommon>IP_SUBNET_MASK=255.255.0.0 ;設置路由器掩碼
rommon>TFTP_SERVER=10.65.1.1 ;指定TFTP服務器IP
rommon>TFTP_FILE=c2600.bin ;指定下載的文件
rommon>tftpdnld ;從tftp下載
rommon>dir flash: ;查看閃存內容
rommon>boot ;引導IOS
靜態路由:
ip route ;命令格式router(config)#ip route 2.0.0.0 255.0.0.0 1.1.1.2 ;靜態路由舉例router(config)#ip route 0.0.0.0 0.0.0.0 1.1.1.2 ;默認路由舉例
動態路由:
router(config)#ip routing ;啟動路由轉發router(config)#router rip ;啟動RIP路由協議。router(config-router)#network ;設置發布路由router(config-router)#negihbor ;點對點幀中繼用。