路由器命令基礎使用


Router> //用戶模式,只能簡單的show及ping/tracer
Router>enable //從用戶模式進入特權模式
Router# //特權模式,能夠進行所有的show及ping/tracer
Router#configure terminal //從特權模式進入全局配置模式
Router(config)# //全局配置模式,可以進行相關配置
Router(config)#hostname R1 //給設備命名
R1#show version //查看設備軟硬件版本信息,開機時間,內存和Flash大小,模塊等
R1#show ip interface brief //查看接口信息
R1#show running-config //查看運行在內存中的當前配置
R1#show startup-config //查看開機配置,保存在NVRAM
R1#copy running-config startup-config //將當前運行配置保存到開機配置中
R1#show tech-support //查看設備所有軟硬件的詳細信息
R1(config)#enable password xxx //配置enable密碼,該密碼show run可見,注意空格也是一位密碼
R1(config)#enable secret xxx //配置enable密碼,該密碼show run不可見,兩個同時配置時,secret密碼生效
R1(config)#line vty 0 4 //進入telnet配置模式
R1(config-line)#login //telnet登陸需要密碼驗證
R1(config-line)#password xxx //配置telnet密碼,注意空格也是一位密碼
R1(config-line)#exit
R1(config)#line vty 0 4
R1(config-line)#no login //telnet登陸不需要驗證
R1(config-line)#exit
R1(config)#line vty 0 4
R1(config-line)#login local //telnet登陸需要在本地數據庫查找用戶名密碼進行驗證
R1(config-line)#exit
R1(config)#username spoto password xxx //創建本地用戶名密碼,注意空格也是一位密碼
R1(config)#banner ^!!!!R1!!!!!^ //配置設備登陸提示符,頭尾符號需要一致,中間為提示符內容
R1(config)#line vty 0 4
R1(config-line)#privilege level 15 //配置telnet用戶特權等級為15,即登陸后直接進入enable模式
R1(config-line)#exit
R1(config)#interface fastEthernet x/x //進入接口配置模式
R1(config-if)#ip address x.x.x.x x.x.x.x //配置IP及掩碼
R1(config-if)#no shutdown //打開接口,路由器接口默認處於管理性關閉狀態
R1(config-if)#exit //退出接口配置模式,返回全局配置模式
R1(config)#no ip routing //關閉路由功能,將路由器模擬成PC
R1(config)#ip default-gateway x.x.x.x //配置網關地址
R1#show ip route //查看關閉路由功能后的網關配置
R1#show cdp neighbors //查看思科互連設備信息,包括設備類型/名稱/接口/IP等
R1(config)#interface loopback 0 //創建環回接口0,用於模擬網段和測試
R1(config-if)#ip address x.x.x.x x.x.x.x //配置環回接口IP及掩碼,環回接口不需要no shutdown
R1(config-if)#exit

R1(config)#ip route x.x.x.x x.x.x.x x.x.x.x //配置使用下一跳地址的靜態路由
R1(config)#ip route x.x.x.x x.x.x.x fastEthernet x/x //配置使用本地出接口的靜態路由
R1(config)#ip route 0.0.0.0 0.0.0.0 x.x.x.x //配置使用下一跳地址的默認路由
R1(config)#ip route 0.0.0.0 0.0.0.0 fastEthernet x/x //配置使用本地出接口的默認路由
R1#show ip route //查看路由表
R1#ping x.x.x.x //使用出接口作為源IP的普通ping
R1#ping x.x.x.x source x.x.x.x //使用指定源地址的擴展ping
R1#debug ip icmp //打開ping的調試過程顯示
R1#undebug ip icmp //關閉ping的調試過程顯示
R1#traceroute x.x.x.x //路徑跟蹤,查看到達目的地所經過的IP
R1(config)#router rip //運行RIP協議,進入RIP協議配置模式
R1(config-router)#version 2 //配置RIP為版本2
R1(config-router)#no auto-summary //關閉自動匯總功能
R1(config-router)#network x.x.x.x //將相關網段發布到RIP進程中,所有相關子網都會被發布,命令配置不支持帶掩碼
R1(config-router)#exit //退出RIP協議配置模式
R1(config)#router eigrp x //運行EIGRP,配置EIGRP AS號碼,相鄰設備的AS號碼要求一致
R1(config-router)#no auto-summary //關閉自動匯總功能
R1(config-router)#network x.x.x.x //將相關網段發布到EIGRP進程中,所有相關子網都會被發布
R1(config-router)#network x.x.x.x x.x.x.x //將相關網段精確發布到EIGRP進程中,命令配置支持帶反掩碼
R1(config-router)#exit //退出EIGRP協議配置模式
R1#show ip eigrp neighbors //查看EIGRP鄰居表
R1#show ip eigrp topology //查看EIGRP拓撲表
R1(config)#router ospf x //運行OSPF,配置OSPF本地進程號,該號碼僅有本地意義
R1(config-router)#network x.x.x.x x.x.x.x area x //相關網段精確發布到OSPF區域中,命令配置要求帶反掩碼,相鄰設備區域號要相同
R1(config-router)#auto-cost reference-bandwidth x //修改參考帶寬,單位是兆
R1(config-router)#exit //退出OSPF協議配置模式
R1#show ip ospf neighbor //查看OSPF鄰居表
R1#show ip ospf database //查看OSPF拓撲表
R1#show ip ospf interface //查看OSPF接口狀態信息,包括RID、網絡類型、hello時間等

在C3640上加載NM-16ESW模塊來模擬交換機。如果是模擬2層交換機,需要關閉路由功能。
Switch#vlan database //進入VLAN數據庫模式
Switch(vlan)#vlan x //創建VLAN,刪除時前面加no
Switch(vlan)#exit
Switch#show vlan-switch //查看VLAN表及所屬端口,真實設備或IOU模擬器上的命令為show vlan
Switch#show vtp status //查看VTP信息,包括域名、版本、模式等
Switch(config)#int fastEthernet x/x
Switch(config-if)#switchport mode access //配置端口模式為access
Switch(config-if)#switchport access vlan 10 //將該端口划入VLAN10,默認所有端口屬於VLAN1
Switch(config-if)#exit
Switch(config)#int fastEthernet x/x //進入單臂路由主接口
Switch(config-if)#switchport trunk encapsulation dot1q //指定trunk封裝使用802.1Q,當交換機支持802.1Q和ISL時使用
Switch(config-if)#switchport mode trunk //配置端口模式為trunk
Switch(config-if)#exit
Switch#show interfaces trunk //查看交換機trunk接口信息及狀態
Switch(config)#interface vlan x //進入管理IP所在的接口
Switch(config-if)#ip address x.x.x.x x.x.x.x //配置交換機的管理IP
Switch(config-if)#exit
Switch(config)#ip default-gateway x.x.x.x //配置交換機的網關地址,實現跨網段遠程管理
R1(config)#interface fastEthernet x/x
R1(config-if)#no shutdown //單臂路由配置,只需要主接口開啟,子接口會自動繼承開啟
R1(config-if)#exit
R1(config)#interface fastEthernet x/x.x //進入子接口配置模式
R1(config-subif)#encapsulation dot1Q x //配置封裝為802.1Q,並指定該子接口所對應的VLAN
R1(config-subif)#ip address x.x.x.x x.x.x.x //配置該VLAN的網關地址
R1(config-subif)#exit
R1(config)#access-list x permit x.x.x.x //允許來自某台主機的流量
R1(config)#access-list x permit x.x.x.x x.x.x.x //允許來自某個網段的流量
R1(config)#access-list x deny any //標准ACL的默認操作是拒絕所有流量
R1(config)#interface fastEthernet x/x
R1(config-if)#ip access-group x in //將CAL應用在接口的入方向
R1(config-if)#ip access-group x out //將ACL應用在接口的出方向
R1(config-if)#exit
R1(config)#line vty 0 4
R1(config-line)#access-class 1 in //telnet遠程控制,有在ACL中被允許的主機能遠程telnet到本機。
R1(config-line)#exit
R1(config)#access-list 100 permit ip x.x.x.x x.x.x.x x.x.x.x x.x.x.x //允許某個網段到某個網段的流量通過
R1(config)#access-list 100 permit ip host x.x.x.x host x.x.x.x //允許某台主機到某台主機的流量通過
R1(config)#access-list 100 permit ip any any //允許任何IP流量通過
R1(config)#access-list 100 permit tcp any any eq x //允許某種TCP流量通過
R1(config)#access-list 100 permit udp any any eq x //允許某種UDP流量通過
R1(config)#access-list 100 permit icmp any any //允許ping包通過
R1(config)#access-list 100 deny ip any any //擴展ACL的默認操作是拒絕所有流量
R1#show access-lists //查看ACL內容及匹配情況
R1(config)#interface fastEthernet x/x
R1(config-if)#ip nat inside //指定接口為NAT的inside端
R1(config)#interface fastEthernet x/x
R1(config-if)#ip nat outside //指定接口為NAT的outside端
R1(config)#ip nat inside source list 1 interface fastEthernet x/x overload //配置基於出接口的PAT
R1(config)#access-list 1 permit any //允許任何IP作為NAT的源地址
R1(config)#ip nat inside source static x.x.x.x x.x.x.x //配置靜態NAT
R1(config)#ip nat pool spoto x.x.x.x x.x.x.x netmask 255.255.255.0 //配置NAT的地址池
R1(config)#ip nat inside source list 1 pool spoto overload //配置基於地址池的PAT
R1(config)#ip nat inside source static tcp x.x.x.x x interface FastEthernetx/x x //配置靜態端口映射
R1#show ip nat translations //查看NAT轉換表
R1#clear ip nat translation * //清楚NAT轉換表,靜態條目不會被刪除
R1-S/C(config)#int serial x/x
R1-S/C(config-if)#clock rate 64000
R1-S/C(config-if)#encapsulation ppp //將接口封裝從默認的HDLC改為PPP封裝
PAP認證配置,認證服務器端:
R1-S(config)#username xxx password xxx //在認證服務器端配置本地用戶名密碼
R1-S(config-if)#ppp authentication pap //在認證服務器端開啟pap認證要求

PAP認證配置,認證客戶端:
R1-C(config-if)#ppp pap sent-username xxx password xxx //在認證客戶端配置pap發送的用戶名和密碼
CHAP認證配置,認證服務器端:
R1-S(config)#username xxx password xxx //在認證服務器端配置本地用戶名密碼
R1-S(config-if)#ppp authentication chap //在認證服務器端開啟chap認證要求
CHAP認證配置,認證客戶端:
R1-C(config-if)#ppp chap hostname xxx //在認證客戶端配置chap發送的用戶名
R1-C(config-if)#ppp chap password xxx //在認證客戶端配置chap發送的密碼
FRSW(config)#frame-relay switching //將路由器模擬成幀中繼交換機
FRSW(config)#int serial x/x
FRSW(config-if)#clock rate 64000
FRSW(config-if)#encapsulation frame-relay //將接口封裝從默認的HDLC改為幀中繼封裝
FRSW(config-if)#frame-relay intf-type dce //指定幀中繼交換機接口類型為DCE
FRSW(config-if)#frame-relay route xxx interface serial x/x xxx //配置幀中繼交換路徑
FRSW(config-if)#exit
FRR(config)#int serial x/x
FRR(config-if)#encapsulation frame-relay //配置幀中繼路由器接口封裝從默認的HDLC改為FR
FRR(config-if)#ip address x.x.x.x x.x.x.x
FRR(config-if)#frame-relay map ip x.x.x.x x broadcast //靜態配置IP到DLCI的映射關系,指定對端IP及本端使用的DLCI值
FRR(config-if)#exit
FRR#show frame-relay map //查看幀中繼映射表
FRR(config)#int serial x/x
FRR(config-if)#ip ospf network point-to-multipoint //幀中繼下OSPF默認模式是NBMA,無法自動建立鄰居。手動修改網絡類型為PTMP或PTP
FRR(config-if)#exit


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM