1. 程式人生 > >《思科路由器常用配置命令》學習筆記(更新中)

《思科路由器常用配置命令》學習筆記(更新中)

1、檢視模式介紹

router> //使用者模式
router#  //特權模式,在普通模式下輸入enable
router(config)#  //全域性模式,在特權模式下輸入configure terminal
router(config-if)# //介面檢視,在全域性模式下輸入int 介面名稱 例如 int s0 或 int e0
router(config-route)# //路由協議檢視,在全域性模式下輸入router 動態路由協議名稱

2、基本配置

router>enable //進入特權模式
router#configure terminal //進入全域性配置模式
router(config)#hostname xxx //設定裝置名稱
router(config)#no ip domain-lookup //不允許路由器預設使用DNS解析命令

router(config)#enable password  //設定特權口令
router(config)# Service password-encrypt //對所有在路由器上輸入的口令進行暗文加密
router(config)#line vty 0 4 //進入設定telnet服務模式
router(config-line)#password xxx //設定telnet的密碼
router(config-line)#login //使能可以登陸
router(config)#line con 0 //進入控制口的服務模式
router(config-line)#password xxx //要設定console的密碼
router(config-line)#login //使能可以登陸

3、介面配置

router(config)#int s0 //進入介面配置模式 serial 0 埠配置(如果是模組化的路由器前面加上槽位編號,例如serial0/0 代表這個路由器的0槽位上的第一個介面)
router(config-if)#ip address xxx.xxx.xxx.xxx xxx.xxx.xxx.xxx  //新增ip 地址和掩碼
router(config-if)#no shutdown //開啟埠

router(config-if)#enca hdlc/ppp 捆綁鏈路協議 hdlc 或者 ppp 思科預設串列埠封裝的鏈路層協議是HDLC所以在show run配置的時候介面上的配置沒有,如果要封裝為別的鏈路層協議例如PPP/FR/X25就是看到介面下的enca ppp或者enca fr
router(config)#int loopback //建立環回口(邏輯介面)模擬不同的本機網段
router(config-if)#ip add xxx.xxx.xxx.xxx xxx.xxx.xxx.xxx  //新增ip 地址和掩碼給環回口
router(config-if)#no shutdown //在物理介面上配置了ip地址後用no shutdown啟用這個物理介面反之可以用shutdown管理性的關閉介面

4、靜態路由配置

router(config)#ip route xxx.xxx.xxx.xxx xxx.xxx.xxx.xxx //下一條或自己的介面
router(config)#ip route 0.0.0.0 0.0.0.0 s 0 //新增預設路由

5、RIP動態路由協議

router(config)#router rip //啟動rip協議
router(config-router)#network xxx.xxx.xxx.xxx //宣告自己的網段
router(config-router)#version 2 // 轉換為rip 2版本
router(config-router)#no auto-summary //關閉自動彙總功能,rip V2才有作用
router(config-router)# passive-int 介面名 //啟動本路由器的那個介面為被動介面
router(config-router)# nei xxx.xxx.xxx.xxx //廣播轉單播報文,指定鄰居的接ip

6、IGRP動態路由協議

igrp協議-----內部閘道器路由協議(IGRP:Interior Gateway Routing Protocol)
router(config)#router igrp xxx //啟動igrp協議
router(config-router)#network xxx.xxx.xxx.xxx //宣告自己的網段
router(config-router)#variance xxx //調整倍數因子,使用不等價的負載均衡

7、EIGRP動態路由協議

//eigrp---Enhanced Interior Gateway Routing Protocol(增強閘道器內部路由線路協議)
router(config)#router eigrp xxx //啟動協議
router(config-router)#network xxx.xxx.xxx.xxx //宣告自己的網段
router(config-router)#variance xxx //調整倍數因子,使用不等價的負載均衡
router(config-router)#no auto-summary //關閉自動彙總功能
router#show ip eigrp neighbors //檢視eigrp協議的鄰居表
router#show ip eigrp top  //檢視eigrp協議的拓樸表
router#show ip eigrp interface //檢視當前路由器執行eigrp協議的介面情況

8、OSPF動態路由協議

router(config)#router ospf xxx //啟動協議啟動一個OSPF協議程序
router(config-router)#network xxx.xxx.xxx.xxx area xxx //宣告自己的介面或網段在ospf的區域中,可以把不同介面
宣告在不同區域中
router(config-router)#router-id xxx.xxx.xxx.xxx //配置路由的id
router(config-router)#area xxx stub //配置xxx區域為末梢區域,加入這個區域的路由器全部要配置這個條命令
router(config-router)#area xxx stub no-summary //配置xxx區域為完全末梢區域,只在ABR上配置
router(config-router)#area xxx nssa //配置xxx區域為非純末梢區域,加入這個區域的路由器全部要配置這個條命令
router(config-router)#area xxx nssa no-summary  //配置xxx區域為完全非純末梢區域,只在ABR上配置,併發布預設路由資訊進入這個區域內的路由器
router#show ip ospf neighbor //檢視當前路由器的ospf協議的鄰居表
router#show ip ospf interface //檢視當前路由器執行ospf協議的介面情況
router#clear ip ospf process //清楚當前路由器ospf協議的程序

9、儲存當前修改//執行的配置

router#write //將RAM中的當前配置儲存到NVRAM中,下次路由器啟動就是執行儲存的配置
router#Copy running-config startup-config //命令與write效果一樣

10、exit命令:從介面、協議、line等檢視模式下退回到全域性配置模式,或從全域性配置模式退回到特權模式

router(config-if)#exit
router(config)#
router(config-router)#exit
router(config)#
router(config-line)#exit
router(config)#
router(config)#exit
router#

11、end命令:從任何檢視直接回到特權模式

router(config-if)#end
router(config-router)#end
router(config-line)#end
router#

12、登出和熱啟動命令

router#Logout //退出當前路由器登陸模式相對與windows的登出
router#reload //重新啟動路由器(熱啟動)冷啟動就是關閉路由器再開啟電源開關

13、檢視當前路由表

router#show ip route //檢視當前的路由表
router#clear ip route * //清除當前的路由表
router#show ip protocol //檢視當前路由器執行的動態路由協議情況
router#show ip int brief //檢視當前的路由器的介面ip地址啟用情況
router#show running-config //檢視當前執行配置
router#show startup-config //檢視啟動配置
router#debug ip pack //開啟ip報文的除錯
router#terminal monitor //輸出到終端上顯示除錯資訊
router#Show interfaces //顯示設定在路由器和訪問伺服器上所有介面的統計資訊. 顯示路由器上配置的所有介面的狀態
router#Show interfaces serial //顯示關於一個串列埠的資訊
router#Show ip interface //列出一個介面的IP資訊和狀態的小結, 列出介面的狀態和全域性引數

14、show命令

router#show running config //顯示所有的配置
router#show versin //顯示版本號和暫存器值
router#show interface+介面型別+介面號 //檢視介面管理性
router#show controllers interface //檢視介面是否有 DCE 電纜
router#show history //檢視歷史記錄
router#show terminal //檢視終端記錄大小
router#show ip interface brief //檢視介面的謫要資訊
router#show spamming-tree vlan +vlan號 //檢視 VLAN生成樹議

15、介面配置

shutdown //關閉介面
no shutdown //開啟介面
ip add +ip地址 //配置 IP 地址
secondary+IP地址 //為介面配置第二個 IP 地址
hostname+主機名 //配置路由器或交換機的標識
config memory //修改儲存在 NVRAM 中的啟動配置
exec timeout 0 0 //設定控制檯會話超時為 0
no ip address //刪除已配置的 IP 地址

16、密碼設定

service password-encryptin //手工加密所有密碼
enable password +密碼 //配置明文密碼
ena sec +密碼 //配置密文密碼
line vty 0 4/15 //進入 telnet 介面
password +密碼 //配置 telnet 密碼
line aux 0 //進入 AUX 介面
password +密碼 //配置密碼
line con 0 //進入 CON 介面
password +密碼 //配置密碼
bandwidth+數字 //配置頻寬

17、在Cisco裝置上修改控制埠密碼

R1(config)# line console 0
R1(config-line)# login
R1(config-line)# password Lisbon
R1(config)# enable password Lilbao
R1(config)# login local
R1(config)# username student password cisco

18、在Cisco裝置上設定控制檯及vty埠的會話超時

R1(config)# line console 0
R1(config-line)# exec-timeout 5 10
R1(config)# line vty 0 4
R1(config-line)# exec-timeout 5 2

19、NVRAM

show startup config 檢視 NVRAM 中的配置資訊
copy run-config atartup config 儲存資訊到 NVRAM
write 儲存資訊到 NVRAM
erase startup-config 清除 NVRAM 中的配置資訊
description+資訊 配置介面聽描素資訊

19、三層交換機配置命令

Switch# configure terminal
Switch(config)# vlan 20
Switch(config-vlan)# name test20
Switch(config-vlan)# end

Switch# vlan database
Switch(vlan)# vlan 20 name test20
Switch(vlan)# exit

Switch# configure terminal
Switch(config)# interface fastethernet0/1
Switch(config-if)# switchport mode access
Switch(config-if)# switchport access vlan 2
Switch(config-if)# end
Switch#

Switch# configure terminal
Switch(config)# interface fastethernet0/4
Switch(config-if)# switchport mode trunk
Switch(config-if)# switchport trunk encapsulation dot1q
Switch(config-if)# end

Switch(config)# interface fastethernet0/1
Switch(config-if)# switchport trunk allowed vlan remove 2
Switch(config-if)# end