CISCO交換機配置命令及釋義
1.設置交換機名稱
switch(config)#hostname DSHD
DSHD(config)#
2.設置交換機管理IP地址
switch(config)#interface vlan1
switch(config)#ip address 10.1.1.1 255.255.255.0
switch(config-if)#no shutdown
switch(config-if)#exit
switch#show run
3.設置交換機特權模式登錄口令:
switch> enable
Password:
switch# configure terminal
Enter configuration commands, one per line. End with Ctrl+Z.
switch (config)# line vty 0 4
switch (config-line)# password xxxx(xxxx是Telnet用戶登錄口令)
switch (config-line)# exit
switch (config)# enable password xxxx(xxxx特權用戶模式的口令)
4.設置 交換機內部時鐘
switch#show clock
* 18:37:04.104 UTC Mon Jul 30 2008
switch# clock set 9:00:00 Jan 1 2001
switch#show clock
09:00:04.123 UTC Mon Jan 1 2008
5.設置secret登錄命令:
switch(config)# enable secret ASB
switch(config)#exit
switch#show running-config
……….
Enable secret 5 $1228899030dieiiop
……….
#同樣配置telnet和console的口令,並加密(service password-encryption).
switch(config)# service password-encryption
switch(config)#line console 0
switch(config-line)#password xxxxxx
switch(config-line)#line vty 0 4
switch(config-line)#password yyyyyy
switch(config-line)#login
switch(cnfig-line)#end
6.設置交換機日誌信息
(1)輸出 : 分爲Console、Telnet、Buffer、Host四個方向。
(2)日誌等級分爲8級,0級最高.使用logging buffer level 修改記錄等級。
emergency 0 緊急:系統不可用
alert 1 告警:需要立即行動
critical 2 關鍵:關鍵狀態
error 3 錯誤:錯誤狀態
warning 4 警告:警告狀態
notification 5 通知:正常但重要狀態
informational 6 信息:僅是信息消息
debug 7 調試:調試消息
switch(config)#logging buffered //把日誌記錄到buffer中的配置命令.
switch(config)#logging buffered informational //等級爲6,informational
switchr(config)#show logging //顯示buffer中的logging信息.
switch(config)# service timestamps log datetime //給日誌信息打時間標記
7.設置交換機SNMP信息
switch(config)# access-list 10 permit 172.18.129.100 log
//配置snmp訪問控制列表
switch(config)# snmp-server community ********** RW 10
//配置讀寫字符串
switch(config)# snmp-server trap-source Vlan1000
//配置trap的源地址
switch(config)# snmp-server host 172.18.129.100 **********
//配置接收trap的主機地址及特定字符串
8.打開和關閉端口
//缺省狀態下,端口是關閉的
Switch(config)#interface fastethernet 0/1
Switch(config-if)#shutdown //關閉端口
Switch(config)#interface fastethernet 0/1
Switch(config-if))#no shutdown //打開端口
9.設置端口描述
# 描述命令說明了以太網端口的作用.
Switch(config)#interface fastethernet 0/1
Switch(config-if)#description : connected to CC1
10.設置端口雙工狀態
Switch(config)#interface fastethernet 0/1
Switch(config-if)# duplex { half | full | auto }
//其中half爲半雙工,full爲全雙工,auto爲自動協商。
11.設置端口速率(流量設置)
Switch(config)#interface fastethernet 0/1
Switch(config-if)# speed { 10 | 100 | 1000 | auto}
//其中10爲10M,100爲100M,1000爲1000M,auto爲自動協商。
Switch(config-if)#no speed
//恢復端口缺省速率配置。
12.設置以太網端口的工作模式(access和trunk)
// 指明端口工作在access模式下
Switch(config-if)#switchport mode access
//指明端口工作在trunk模式下
Switch(config-if)#switchport mode trunk
說明 :
0、以太網端口有二種工作模式:Access和Trunk。
1、端口工作在Access模式下只能屬於1個VLAN,一般用於接用戶計算機的端口;
2、端口工作在Trunk模式下可以屬於多個VLAN,可以接收和發送多個VLAN的報文,一般用於交換機之間連接的端口;
3、可以使用switchport access vlan vlan_number指明端口屬於什麼vlan。
12. 設置鏈路聚合(EtherChannel)
switch(config)#interface fastethernet 0/1
switch(config-if)# channel- group channel-group-number mode {auto [non-silent] | desirable [non-silent] | on}
注意 :
1、快速以太網信道鏈路上的所有端口必須是同一個VLAN的成員,或者必須是Trunk端口。
2、如果快速以太網信道鏈路內的端口是trunk端口,則這些端口必須有相同的vlan範圍。
3、快速以太網信道鏈路內的所有端口的速度和雙工模式設置必須相同。
13.trunk配置及封裝
switch(config)#interface GigabitEthernet1/0/2
switch(config-if)# switchport trunk encapsulation dot1q
switch(config-if)# switchport mode trunk
1、接入(access)鏈路:接入鏈路只是一個VLAN的成員。這個VLAN被稱爲端口的本地VLAN。連接到這個端口上的設備完全不知道存着一個VLAN。設備只是根據被配置在該設備上的第3層信息認爲它是網絡或子網的一部分。爲了保證使它不需要知道VLAN的存在,交換機負責在幀被髮送到未端設備之前將VLAN信息從幀中拿掉。接入鏈路是屬於一個、並且只屬於一個VLAN的端口,這個端口不能從另一個VLAN接收信息,除非該信息已經選擇過路由了。這個端口也不能發送信息到另一個VLAN,除非這個端口可以訪問路由器。
2、幹道(trunk)鏈路:幹道鏈路可以承載多個VLAN。幹道鏈路的得名是來自電話系統中的幹道(trunk),它們能夠傳輸多個電話對話。幹道鏈路通常被用來將交換機連接到其他交換機,或者將交換機連接到路由器。Cisco在快速以太網和千兆以太網端口上支持幹道鏈路。
目前Cisco所使用的有兩種標識技術如下:
a、Cisco交換機間鏈路(ISL): 用於互連多臺交換機的cisco專有封裝協議。該該協議在 Catalyst 交換機和路由器上被支持
b、IEEE802.1Q標準:它通過 在幀頭插入一個VLAN標識符來標識VLAN。
14.配置二層、三層VLAN
//創建vlan
switch#vlan database
switch(config-vlan)# vlan valn_id name vlan_name
switch(config-vlan)# no vlan vlan_id
//創建三層vlan
switch(config)# interface vlan_id
switch(config-vlan)# ip address 172.168.1.1 255.255.255.0
switch(config-vlan)# no shutdown
//端口加入vlan
switch(config)# interface g1/0/10
Switch(config-if)#switchport mode access
Switch(config-if)#switchport access vlan vlan_id
Switch(config-if)#no shutdown
15.HSRP配置
//主交換機上standby的配置
interface Vlan10
description "uplink"
ip address 172.18.128.53 255.255.255.248
standby 10 ip 172.18.128.50 //standby_id=10,standby_ip= 172.18.128.50
standby 10 priority 105 //配置優先級,數值越大,優先級越高
standby 10 preempt //配置搶佔模式
//從交換機上standby的配置
interface Vlan10
description "uplink"
ip address 172.18.128.54 255.255.255.248
standby 10 ip 172.18.128.50
查看命令:show standby
16.VTP配置
switch#vlan database
switch(config-vlan)# vtp domain domain-name
switch(config-vlan)# vtp mode { server | client | transparent }
說明 :
1、VTP(VLAN Trunk Protocol,VLAN幹道協議)的功能與GVRP(IEEE 802.1Q的標準協議)相同。
2、VTP Server維護該VTP域中所有VLAN信息列表,可以增加、刪除或修改VLAN。
3、VTP Client也維護該VTP域中所有VLAN信息列表,但不能增加、刪除或修改VLAN,任何變化的信息必須從VTP Server發佈的通告報文中接收。
4、VTP Transparent不參與VTP工作,它雖然忽略所有接收到的VTP信息,但能夠將接收到的VTP報文轉發出去。它只擁有本設備上的VLAN信息。
5、其中,VTP Server和VTP Client必須處於同一個VTP域,且一個交換機只能位於一個VTP域中。
6、同一個VTP域內的所有交換機的域名必須相同;
7、同一個VTP域內的交換機必須鄰接;
8、同一個VTP域內的鄰接交換機之間的Trunk鏈路必須激活。
9、VTP的版本號是用來同步整個交換VLAN的信息的,只有VTP的Server上的高配置版本號才能同步低的,相同配置版本號的兩個VLAN數據庫不會更新對方,可以使用以下幾種辦法可以清除VTP的版本號:
a.將VTP的域名改掉,再改回來;
b.將VTP的版本號改掉,再改回來;
c.將VTP的模式改爲透明模式,再改回來。
17.配置生成樹協議
//配置根網橋:
switch(config)# spanning-tree vlan vlan-id root primary [diameter net-diameter [hello-time seconds]]
//配置備用根網橋:
switch(config)# spanning-tree vlan vlan-id root secondary [diameter net-diameter [hello-time seconds]]
//修改端口優先級:
switch(config)#interface interface-id
switch(config-if)# spanning-tree port-priority priority
//修改端口路徑開銷:
switch(config)#interface interface-id
switch(config-if)# spanning-tree cost cost
STP的基本原理是,通過在交換機之間傳遞一種特殊的協議報文(IEEE 802.1D協議將這種協議報文稱爲“配置消息”)來確定網絡的拓撲結構。配置消息中包含了足夠的信息來保證交換機完成生成樹計算。
配置消息中主要包括以下內容:
樹根的ID:由樹根的優先級和MAC地址組合而成;
到樹根的最短路徑開銷;
指定交換機的ID:由指定交換機的優先級和MAC地址組合而成;
指定端口的ID:由指定端口的優先級和端口編號組成
配置消息的生存期:MessageAge;
配置消息的最大生存期:MaxAge;
配置消息發送的週期:HelloTime;
端口狀態遷移的延時:ForwardDelay。
18.靜態路由設置
配置靜態路由示例:
ip route 0.0.0.0 0.0.0.0 172.18.128.49
刪除靜態路由示例
no ip route 0.0.0.0 0.0.0.0 172.18.128.49
19.動態路由設置
OSPF路由設置
router ospf添加ospf路由配置
no router ospf刪除ospf路由配置
RIP路由設置
router rip添加rip路由配置
no router rip刪除rip路由配置
EIGRP路由配置
Router eigrp添加eigrp路由配置
no router eigrp刪除eigrp路由配置