- 路由器和交換機的基本命令 推薦度:
- 相關(guān)推薦
路由交換命令大全
路由器相信大家都很熟悉,我們?nèi)粘T诩疑暇W(wǎng)就需要用到它,下面是小編給大家整理的關(guān)于路由交換命令,歡迎閱讀!
路由交換命令 1
「基礎(chǔ)配置」
進入console口進行本地配置用戶模式 xx>enable n特權(quán)模式 xx#configure terminal全局配置模式 xx(config)#interface [f|s] n/m進入接口配置模式xx(config-if)#
進入(子)接口模式后配置IP(config-if)#ip addr A.B.C.D 子網(wǎng)掩碼激活接口(config-if)#no shutdown配置速度(config-if)#speed {auto|10|100}配置接口工作模式(config-if)#duplex {auto|half|full}配置時鐘(串行口DCE端)
。╟onfig-if)#clock rate n反向操作(刪除配置)
no + 命令在換回接口上配多個ip(config-if)#ip addr A.B.C.D 子網(wǎng)掩碼(config-if)#ip addr A.B.C.D 子網(wǎng)掩碼 secondary查看所有配置#show running-config
路由器關(guān)閉路由功能充當主機(config)#no ip routing為路由器設置網(wǎng)關(guān)(config)#ip default-gateway ip地址
改機器名字(config)#hostname yy控制線路超時(config)#line n(config-line)#exec-timeout 0 0關(guān)閉域名解析功能(config)#no ip domain-lookup開啟路由器http功能(config)#ip http server(config)#username xxx password yyy(config)#username xxx secret yyy(config)#enable secret yyy啟用密碼加密服務(config)#service password-encryption yyy開啟路由器https功能(config)#ip http secure-server開啟路由器遠程登錄功能(config)#line vty 0 4(config)#login local或者(config)#no login(config)#enable n登錄時使用命令 telnet A.B.C.D
「交換機」
查看mac地址表#show mac-address-table綁定靜態(tài)mac地址(config)#mac-address-table static H.H.H vlan n interface fx/x #show arp在主機上使用arp -a查看arp信息開啟交換機端口安全(防止連接主機惡意發(fā)送隨機mac填滿mac地址表)
(conifg)#switchport port-security(conifg)#switchport ?
#show port-security int fx/x恢復(config)#errdisable recovery
為交換機vlan1配置管理ip(conifg)#int vlan 1(config-if)#ip addr A.B.C.D 子網(wǎng)掩碼(config-if)#no shut
「交換機vlan」
查看vlan #show vlan-switch或是#show vlan創(chuàng)建vlan #vlan database(vlan)#vlan n將端口加入到vlan中(config-if)#switchport access vlan n給允許多個vlan的接口打trunk(config-if)#switchport mode trunk
「單臂路由vlan」
路由器上配置子接口實現(xiàn)不同vlan之間通信,先必須激活其父接口,另外IP不允許重復(config)#interface fx/x.x(config-subif)#encapsulation dot1q vlan-id(config-subif)#ip addr A.C.D.E 子網(wǎng)掩碼(config-subif)#no shut
「使用三層交換機交換虛擬接口」
交換機上配置虛擬交換接口實現(xiàn)不同vlan之間通信,先必須在交換機上添加對應vlan(config)#int vlan n(config-if)#ip addr A.B.C.D 子網(wǎng)掩碼(config-if)#no shut在刪除時,務必先刪除交換虛擬接口,再刪對應vlan
「VTP」
配置VTP模式#vlan database(vlan)#vtp {server|client|transparent}只有域名和密碼完全一樣的路由器之間才能同步vlan信息(vlan)#vtp domain <域名>(vlan)#vtp password <密碼>打開VTP裁剪(vlan)#vtp pruning退出激活(vlan)#exit
「端口聚合」
創(chuàng)建R1(config)#interface port-channel 1(config-if)#switchport trunk encapsulation dot1q(config-if)#switchport mode trunk將指定接口加入聚合組內(nèi)#int range f x/x-x #channel-group 1 mode on查看聚合接口#show etherchannel summary
「生成樹協(xié)議」
基于vlan的生成樹可防止環(huán)路開啟生成樹協(xié)議(STP默認是開啟的,可省略)
。╟onfig)#spanning-tree vlan n修改生成樹協(xié)議優(yōu)先級(根網(wǎng)橋:mac最小、優(yōu)先級最。
。╟onfig)#spanning-tree vlan n priority m交換機和主機之間連接的.端口開啟portfast,可防止主機發(fā)送BPDU偽造數(shù)據(jù)(config-if)#spanning-tree portfast查看生成樹#show spanning-tree [vlan n]
「靜態(tài)路由」
查看協(xié)議#show ip protocols查看路由表#show ip route添加靜態(tài)路由(以默認路由舉例)
(config)#ip route 0.0.0.0 0.0.0.0 {出接口|下一跳ip}浮動靜態(tài)路由(備份鏈路,在原鏈路失效后起作用)
。╟onfig)#ip route 0.0.0.0 0.0.0.0 出接口 AD管理距離靜態(tài)黑洞路由(config)#ip route 192.168.0.0 255.255.0.0 null 0
「RIP距離矢量路由,動態(tài)路由」
配置RIP宣告直連網(wǎng)段(config)#router rip(config-router)#network 網(wǎng)段更改為版本2(config-router)#version {2|1}關(guān)閉自動匯總(如果被其他網(wǎng)路隔開時,最好關(guān)閉自動匯總)
。╟onfig-router)#no auto-summary設置被動接口(只接受更新,不宣告自己)
(config-router)#passive-interface 接口單播更新(只和指定的ip交換路由信息)
。╟onfig-router)#neighbor ip地址清除路由表內(nèi)容#clear ip route *
「OSPF鏈路狀態(tài)路由,動態(tài)路由」
配置OSPF宣告直連網(wǎng)路(config)#router ospf <進程號>(config-router)#router-id <任意ip地址>(config-router)#network<反掩碼> area n重啟OSPF進程#clear ip ospf process查看接口的OSPF信息#show ip ospf interface查看鄰居表#show ip ospf neighbor查看鏈路數(shù)據(jù)表#show ip ospf database <?>
「EIGRP鏈路狀態(tài)路由,動態(tài)路由」
配置EIGRP宣告直連網(wǎng)路(config)#router eigrp <系統(tǒng)編號>(config-router)#network查看鄰居表#show ip eigrp neighbors查看拓撲表#show ip eigrp topology
「VRRP虛擬路由器路由協(xié)議」
提供網(wǎng)關(guān)冗余查看VRRP信息#show vrrp <?> VRRP配置(在提供備份的兩臺路由器上做以下配置)
端口跟蹤(監(jiān)視某個接口的狀態(tài))
。╟onfig)#track 1 interface 接口 line-protocol(config-if)#vrrp<1~254>ip額外配置優(yōu)先級(IP和優(yōu)先級越大Master)和搶占(config-if)#vrrp<1~254>priority<1~254>(config-if)#vrrp<1~254>preempt(config-if)#vrrp 1 track 1 decrement<1~255>
「訪問控制列表ACL」
ACL無法控制自身發(fā)起的流量,對于已經(jīng)建立的流量不起作用標準ACL(不能單獨刪除、添加一條訪問列表)
。╟onfig)#access-list<1~99|1300~1999>{permit|deny} ip地址 反掩碼擴展ACL(config)#access-list<100-199>{permit|deny} <協(xié)議> <源ip> <反掩碼> <源端口> <目標ip> <反掩碼> <目標端口>應用到指定ACL到某個接口(config)#int 接口(config-if)#ip access-group<1~99|100-199|1300~1999>{in|out}
命名ACL(config)#ip access-list standard <標準acl名字>(config-std-nacl)#{permit|deny} ip地址 反掩碼(config)#ip access-list extended <擴展acl名字>(config-ext-nacl)#{permit|deny} <協(xié)議> <源ip> <反掩碼> <源端口> <目標ip> <反掩碼> <目標端口>應用到指定ACL到某個接口(config)#int 接口(config-if)#ip access-group <標準acl名字|擴展acl名字> {in|out}
自反ACL(RACL,可以只允許內(nèi)網(wǎng)主動發(fā)起的流量通過)
(config)#ip access-list extended OUTB(config-ext-nacl)#permit tcp any any reflect RACL(config)#ip access-list extended INB(config-ext-nacl)#evaluate RACL(config-ext-nacl)#deny ip any any應用到指定ACL到某個接口(config-if)#ip access-group OUTB out(config-if)#ip access-group INB in
基于時間的ACL設置時區(qū)時間(config)#clock timezone GMT +8 #clock set hh:mm:ss <日> <月> <年>定義時間(config)#time-range <時間名>(config-time-range)#periodic <?> hh:mm to hh:mm(config-time-range)#absolute start hh:mm:ss <日> <月> <年> end hh:mm:ss <日> <月> <年>結(jié)合ACL(config)#ip access-list extended <擴展acl名字>(config-ext-nacl)#deny tcp any any time-range <時間名>
「NAT和PAT」
定義內(nèi)外網(wǎng)接口(config)#int 接口(config-if)#ip nat {inside|outside}靜態(tài)NAT(config)#ip nat inside source static ip地址 <?>靜態(tài)PAT(config)#ip nat inside source static <協(xié)議> ip地址 <端口號> <?>
使用ACL捕獲流量(config)#access-list n permit ip地址 反掩碼(config)#ip nat pool <地址池名> <起始ip地址> <終止ip地址> netmask 掩碼TCP負載均衡(輪詢轉(zhuǎn)換)
(config)#ip nat pool <地址池名> <起始ip地址> <終止ip地址> netmask 掩碼 type rotary動態(tài)NAT(config)#ip nat inside source list n pool <地址池名>動態(tài)PAT(config)#ip nat inside source list n pool <地址池名> overload
查看轉(zhuǎn)換項#show ip nat translations
「廣域網(wǎng)PPP協(xié)議」
在串行口上的兩臺路由器都封裝ppp協(xié)議(config)#int sx/x(config-if)#encapsulation ppp(config-if)#no shut
啟用PAP認證,未加密認證方(config)#username <用戶名> password <密碼>(config-if)#ppp authentication pap請求認證方(config-if)#ppp pap sent-username <用戶名> password <密碼>
啟用CHAP認證,安全加密認證方(config)#username <請求認證方名> password <請求認證方密碼>(config-if)#ppp authentication chap請求認證方(config)#username <認證方名> password <認證方密碼>(config-if)#ppp authentication chap
「幀中繼」
無廣播的多路訪問網(wǎng)絡(NBMA)
配置幀中繼交換機關(guān)閉路由器路由功能(config)#no ip routing啟用幀中繼(config)#frame-relay switching進入串行接口R8(config)#int sx/x封裝frame-relay協(xié)議R8(config-if)#encapsulation frame-relay指定lmi-type類型(config-if)#frame-relay lmi-type cisco指定intf-type接口類型為DCE(config-if)#frame-relay intf-type dce配置時鐘頻率(config-if)#clock rate n配置DLCI(config-if)#frame-relay route <進dlci號> int <出接口> <出dlci號>
配置路由器,封裝frame-relay協(xié)議(config-if)#encapsulation frame-relay靜態(tài)指定映射(config-if)#frame-relay map ip
清除動態(tài)學到的Frame Relay #clear frame-relay-inarp查看映射#show frame-relay map調(diào)試#debug frame-relay lmi
點到多點(解決水平分割問題,劃分子接口)
適用于全互聯(lián)和部分互聯(lián)(config)#int sx/x(config-if)#encapsulation frame-relay(config)#int sx/x.x multipoint關(guān)閉反向arp,禁止自學習DLCI號和IP對應,而采取靜態(tài)Map(config-subif)#no frame-relay inverse-arp靜態(tài)映射DLCI號和IP(config-subif)#frame-relay map ip
broadcast如在R1上對R3 DLCI號103 IP地址192.168.1.3
點到點子接口(不存在水平分割問題)
子接口可以看作是專線,適用于星型(config)#int sx/x(config-if)#encapsulation frame-relay(config)#int sx/x.x point-to-point(config-subif)#frame-relay interface-dlci
路由交換命令 2
《1》配置設備
交換機、路由器、防火墻、服務器
1、協(xié)議功能
2、協(xié)議原理(工作過程)
3、協(xié)議配置
4、協(xié)議報文分析
《2》ensp安裝
尋找數(shù)通學習文檔:support.huawei.com
交流群:華為企業(yè)互動社區(qū)。
軟件安裝視頻:
https://www.bilibili.com/video/BV1gV411Z7ke
安裝之前需要把防火墻以及殺毒軟件關(guān)掉。
安裝ensp:第60分鐘左右,安裝管理員運行,
Virtualbox安裝:45分鐘開始。
注意:需要在vbox把全局工具網(wǎng)卡更改以及dhcp關(guān)掉。安裝完成ensp后進入vbox當中選擇AR-box-》設置-》系統(tǒng)
如果是灰色進入bios開啟虛擬功能
《3》ensp常見cLl配置
進入命令行接口 CLI (Command LineInterface) 。
1、幫助命令
任意命令視圖下,輸入"? "獲取該命令視圖下所有的命令及其簡單描述。
快捷鍵:當用戶輸入不完整的關(guān)鍵字后按下鍵,系統(tǒng)自動執(zhí)行部分幫助,將命令補全,按兩下tab可顯示下個命令。
下光標鍵<↑>、<↓>表示顯示歷史命令;
2、使用用戶視圖檢查基本參數(shù)
用戶視圖下只能使用參觀和監(jiān)控級命令,如使用 display version 命令顯示系統(tǒng)軟件版
本及硬件等信息
display version
3、視圖間的切換(兩種模式:用戶模式,系統(tǒng)模式(進行配置相關(guān)協(xié)議))
<Huawei>system-view
進入系統(tǒng)模式
[Huawei]quit
退出系統(tǒng)模式:quit、Ctrl+z
4、接口配置
使用 display 查看路由器基本信息
[Huawei]display interface GigabitEthernet 0/0/0 顯示接口信息
[Huawei]interface GigabitEthernet 0/0/0 interfaceGigabitEthernet 進入千兆以太網(wǎng)接口
[Huawei]shutdown 關(guān)閉接口
[Huawei]undo shutdown 激活接口
[Huawei-g0/0/0] ip add 192.168.1.1 24 配置ip地址192.168.1.1 子網(wǎng)掩碼/24
在華為當中在命令前面加上undo是對命令行的.撤銷
[Huawei]display current-configuration 查看路由器當前配置 current:現(xiàn)在的 configuration:配置
[Huawei]display ip interface brief 顯示IP接口簡述
[Huawei]display ip routing-table 顯示ip路由表
[Huawei]display this 顯示當前配置
5、用戶界面配置
[Huawei]sysname R1 修改路由器名
[R1]undo info-center enable 關(guān)閉改名后發(fā)送推送消息
[Huawei]user-interface console 0 由系統(tǒng)視圖進入到控制臺視圖
[Huawei]idel-timeout 0 0 設置超時時間 ;0 0 為永不超時
[Huawei]screen-length 屏幕顯示行數(shù)
[Huawei]history-command max-size 設置命令顯示長度
【路由交換命令】相關(guān)文章:
路由器和交換機的基本命令09-25
Cisco交換機命令大全05-20
路由器route add命令詳解10-13
華為交換機配置命令詳解07-21
思科交換機配置命令大全10-11
交換機與路由器的區(qū)別08-30
cisco路由器常用命令10-06
交換機和路由器的區(qū)別07-29
路由器和交換機的區(qū)別06-17