當前位置:才華齋>計算機>網路技術>

路由交換命令大全

網路技術 閱讀(3.08W)

進入console口進行本地配置使用者模式 xx>enable n特權模式 xx#configure terminal全域性配置模式 xx(config)#interface [f|s] n/m進入介面配置模式xx(config-if)#,下面是由本站小編為大家整理的路由交換命令大全,喜歡的可以收藏一下!瞭解更多詳情資訊,請關注應屆畢業生考試網!

路由交換命令大全

  「基礎配置」

進入console口進行本地配置使用者模式 xx>enable n特權模式 xx#configure terminal全域性配置模式 xx(config)#interface [f|s] n/m進入介面配置模式xx(config-if)#

進入(子)介面模式後配置IP(config-if)#ip addr A.B.C.D 子網掩碼啟用介面(config-if)#no shutdown配置速度(config-if)#speed {auto|10|100}配置介面工作模式(config-if)#duplex {auto|half|full}配置時鐘(序列口DCE端)

(config-if)#clock rate n反向操作(刪除配置)

no + 命令在換回介面上配多個ip(config-if)#ip addr A.B.C.D 子網掩碼(config-if)#ip addr A.B.C.D 子網掩碼 secondary檢視所有配置#show running-config

路由器關閉路由功能充當主機(config)#no ip routing為路由器設定閘道器(config)#ip default-gateway ip地址

改機器名字(config)#hostname yy控制線路超時(config)#line n(config-line)#exec-timeout 0 0關閉域名解析功能(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繫結靜態mac地址(config)#mac-address-table static H.H.H vlan n interface fx/x #show arp在主機上使用arp -a檢視arp資訊開啟交換機埠安全(防止連線主機惡意傳送隨機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 子網掩碼(config-if)#no shut

  「交換機vlan」

檢視vlan #show vlan-switch或是#show vlan建立vlan #vlan database(vlan)#vlan n將埠加入到vlan中(config-if)#switchport access vlan n給允許多個vlan的介面打trunk(config-if)#switchport mode trunk

  「單臂路由vlan」

路由器上配置子介面實現不同vlan之間通訊,先必須啟用其父介面,另外IP不允許重複(config)#interface fx/x.x(config-subif)#encapsulation dot1q vlan-id(config-subif)#ip addr A.C.D.E 子網掩碼(config-subif)#no shut

  「使用三層交換機交換虛擬介面」

交換機上配置虛擬交換介面實現不同vlan之間通訊,先必須在交換機上新增對應vlan(config)#int vlan n(config-if)#ip addr A.B.C.D 子網掩碼(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

  「埠聚合」

建立R1(config)#interface port-channel 1(config-if)#switchport trunk encapsulation dot1q(config-if)#switchport mode trunk將指定介面加入聚合組內#int range f x/x-x #channel-group 1 mode on檢視聚合介面#show etherchannel summary

  「生成樹協議」

基於vlan的生成樹可防止環路開啟生成樹協議(STP預設是開啟的,可省略)

(config)#spanning-tree vlan n修改生成樹協議優先順序(根網橋:mac最小、優先順序最小)

(config)#spanning-tree vlan n priority m交換機和主機之間連線的埠開啟portfast,可防止主機發送BPDU偽造資料(config-if)#spanning-tree portfast檢視生成樹#show spanning-tree [vlan n]

  「靜態路由」

檢視協議#show ip protocols檢視路由表#show ip route新增靜態路由(以預設路由舉例)

(config)#ip route {出介面|下一跳ip}浮動靜態路由(備份鏈路,在原鏈路失效後起作用)

(config)#ip route 出介面 AD管理距離靜態黑洞路由(config)#ip route null 0

  「RIP距離向量路由,動態路由」

配置RIP宣告直連網段(config)#router rip(config-router)#network 網段更改為版本2(config-router)#version {2|1}關閉自動彙總(如果被其他網路隔開時,最好關閉自動彙總)

(config-router)#no auto-summary設定被動介面(只接受更新,不宣告自己)

(config-router)#passive-interface 介面單播更新(只和指定的ip交換路由資訊)

(config-router)#neighbor ip地址清除路由表內容#clear ip route *

  「OSPF鏈路狀態路由,動態路由」

配置OSPF宣告直連網路(config)#router ospf <程序號>(config-router)#router-id <任意ip地址>(config-router)#network <ip網段> <反掩碼> area n重啟OSPF程序#clear ip ospf process檢視介面的OSPF資訊#show ip ospf interface檢視鄰居表#show ip ospf neighbor檢視鏈路資料表#show ip ospf database <?>