設定 Cisco Switch 連接埠屬性
Cisco Switch預設連接埠設定自動偵測連接埠速度和雙工狀態,也就是Auto-speed,Auto-duplex,一般情況下不需要對每個連接埠進行設定。
但根據Cisco的技術白皮書,接入改連接埠的網路設備的資訊情況下,建議直接配置相應的速度以及雙工資訊。
speed命令可以選擇搭配10,100和auto,分別代表10Mb/s,100Mb/s和自動協商速度。
duplex命令也可以選擇full,half和auto,分別代表全雙工,半雙工和自動協商雙工狀態。
description命令用於描述特定連接埠名字,建議對特殊連接埠進行描述。
假設現在接入連接埠1的設備速度為100Mb/s,雙工狀態為全雙工:
• 進入接口0/1的設定模式 Switch(config)# interface fastethernet 0/1
• 設定該連接埠的速率為100Mb/s Switch(config-if)# speed 100
• 設定該連接埠為全雙工 Switch(config-if)# duplex full
• 設定該連接埠描述為up_to_mis Switch(config-if)# description up_to_mis
• 退回到特權模式 Switch(config-if)# end
• 查詢連接埠0/1的設定結果 Switch# show interface fastethernet 0/1
Cisco Switch iOS Recovery
1. 用控制線連接Switch console,用帶有xmodem功能的終端軟件連接。
2. 拔掉Switch後的電源線重新啟動Switch
3. 在超級終端輸入:
switch:
switch:flash_init//會出現如下提示:
Initializing Flash…
4. 輸入拷貝指令:
switch:copy xmodem: flash:image_filename.bin
//出現如下提示:
Begin the Xmodem or Xmodem-1K transfer now…
5. 系統提示不斷出現C這個字母就可以開始傳文件了
6. 點擊超級終端菜單:
傳送—發送文件,在協議選項中選擇Xmodem或者Xmodem-1K協議,然後選擇ios的影像文件(*.bin),開始傳送。
7. 傳送完畢後提示:
File “xmodem:” successfully copied to ….
switch:
8. 在提示符下輸入
switch:boot
啟用新的ios系統
Cisco Switch Password Recovery與清除舊有設定方式?
1. 拔掉電源線
2. 插回電源線同時按住面板上的Mode按鈕
3. switch:flash_init
4. 再輸入 load_helper
5. Dir flash :
列出在flash中的檔案
6. rename flash:config.text flash:config.old
修改config.text檔名,密碼存在此處
7. boot
重新開機
8. 輸入 n
來跳過初始化設定
9. 輸入 enable
10. 輸入 rename flash:config.old flash:config.text
將設定檔案改回原來名稱
11. #copy flash:config.text system:running-config
把設config.text寫回到running-config
12. # config t
進入config mode 修改密碼
# enable secretxxxxxx
13. # write memory (或 copy running-config startup-config)
將修改完畢後的密碼存檔,在reboot測試新密碼與設定內容
補充:若此台Switch不需保留設定檔,現有的config.text刪掉,vlan.dat刪除後重新開機,這樣設定檔就完全是乾淨的。
erase startup-config 將設定檔內容清空指令
Delete vlan.dat 指令來刪除vlan檔
所有之前設定過的內容清空後,記得先修改新密碼在做後續設定
一般發生網路異常,最直接的方式就是分析異常流量的內容
簡單來說有下列步驟
1. 首先確認異常的流量地方
在好幾百個Port的地方要找出不尋常流量的Switch Port, 本身就是一個難題, 這是需要平常就花時間在紀錄每個Port的流量, 才能在緊急時比對每個port目前的流量和以前是否不一樣。一般免費的 Solution是用MRTG來做流量的記錄。
2. 進行流量管理
在確認異常Port之後,可直接下指令將該異常 Switch Port 關閉停用,再觀察整個網路環境是否己改善. 如果想找出異常流量的內容,就必須用網路封包分析軟體(eg: sniffer, Ethereal 或是 Windows內建的網路分析軟體),收集異常Port的流量內容再加以分析. 除非你能將網路封包分析軟體直接安裝到使用異常流量的主機內,直接抓取,不然你就一定要利用Mirror Port的方式來進行。
如何設定Mirror Port:
以Cisco 2950為例
#config t
先設定要監控的是那個port
#monitor session “number” “source” interface “mod_number/port_number” both
switch # monitor session 1 source int f0/14
再設定要把上述Port的流量全部導入另一個port
#monitor session “number” “destination” interface “mod_mnumber/port_number”
seitch #monitor session 1 destination int f0/15
最後把安裝網路封包分析軟體的電腦,接上 swithc port f0/15,這樣就可以進行接收分析在port f0/14 中所有封包活動的內容了
Cisco網路交換機於區域網路中接口類型主要有四種:
Access/ Trunk/ Multi/ Dot1q-tunnel
1. access: 主要用來接入終端設備,如PC機、伺服器、列印伺服器等。
2. trunk:主要用在連接其它交換機,以便在線路上承載多個vlan。
3. multi:在一個線路中承載多個vlan,但不像trunk,它不對承載的數據打標簽。主要用於接入支援多vlan的伺服器或者一些網路分析設備。現在基本不使用此類接口,在cisco的網路設備中,也基本不支援此類接口了。
4. dot1q-tunnel:用在Q-in-Q隧道配置中。
Cisco網路設備支援動態協商連接埠的工作狀態,這為網路設備的實施提供了一定的方便(但不建議使用動態方式)。 Cisco動態協商協議從最初的 DISL(Cisco私有協議) 發展到DTP (公有協議)。根據動態協議的實現方式,Cisco網路設備接口主要分為下面幾種模式:
1. switchport mode access:
強制接口成為access接口,並且可以與對方主動進行協商,誘使對方成為access模式。
2. switchport mode dynamic desirable:
主動與對協商成為Trunk接口的可能性,如果鄰居接口模式為Trunk/desirable/auto之一,則接口將變成trunk接口工作。如果不能 形成trunk模式,則工作在access模式。這種模式是現在交換機的默認模式。
3. switchport mode dynamic auto:
只有鄰居交換機主動與自己協商時才會變成Trunk接口,所以它是一種被動模式,當鄰居接口為Trunk/desirable之一時,才會成為 Trunk。如果不能形成trunk模式,則工作在access模式。
4. switchport mode trunk:
強制接口成為Trunk接口,並且主動誘使對方成為Trunk模式,所以當鄰居交換機接口為trunk/desirable/auto時會成為Trunk接口。
5. switchport nonegotiate:
嚴格的說,這不算是種接口模式,它的作用隻是阻止交換機接口發出DTP數據包,它必須與switchport mode trunk或者switchport mode access一起使用。。
6. switchport mode dot1q-tunnel:
配置交換機接口為隧道接口(非Trunk),以便與用戶交換機的Trunk接口形成不對稱鏈路。
VTP (VLAN Trunking Protocol)
VTP 簡單的說, 是 Cisco 自己產品的專屬協定, 可以在 Cisco 交換器間, 自動散播可用的 VLAN 資訊。
這個練習我將 VLAN 號碼改了, 希望大家可以不用偷看 Core Switch的設定, 只要在Switch1 和 Switch2上啟用VTP, 就可以利用 VTP 自動的方式取得 Core Swtich 上的 兩個 VLAN 資訊。
Switch1 和 Switch2 先扮演 VTP Client 的腳色, 收聽 VTP Server (這個例子就是 Core Switch) 所放送出來的 VLAN 資訊。
• Client 設定:
Switch1(config)#vtp mode client
Switch1(config)#vtp domain ccna
Switch1(config)#
• Server 設定:
CoreSwitch(config)#vtp mode server client
CoreSwitch(config)#vtp domain ccnaccna
CoreSwitch(config)#
和 VLAN 設定一樣, 我們無法使用 show run 來看設定的內容, 只能使用 show vtp status.
• Switch1:
Switch1#show vtp status
VTP Version : 2
Configuration Revision: 4
Maximum VLANs supported locally : 255
Number of existing VLANs: 7
VTP Operating Mode: Client
VTP Domain Name: ccna
VTP Pruning Mode: Disabled
VTP V2 Mode: Disabled
VTP Traps Generation: Disabled
MD5 digest: 0x9E 0x49 0xD8 0xC7 0xED 0x7C 0xB2 0x01
Configuration last modified by 20.1.1.101 at 3-1-93 00:01:58
Switch1#
• CoreSwitch:
CoreSwitch#show vtp status
VTP Version: 2
Configuration Revision: 4
Maximum VLANs supported locally : 255
Number of existing VLANs: 7
VTP Operating Mode: Server
VTP Domain Name: ccna
VTP Pruning Mode: Disabled
VTP V2 Mode: Disabled
VTP Traps Generation: Disabled
MD5 digest: 0x9E 0x49 0xD8 0xC7 0xED 0x7C 0xB2 0x01
Configuration last modified by 20.1.1.101 at 3-1-93 00:01:58
Local updater ID is 20.1.1.101 on interface Vl1 (lowest numbered VLAN interface found)
CoreSwitch#
步驟1.查詢目前 Switch 使用的 IOS
• 使用 show boot 指令查詢可知目前使用的 IOS 檔案為 c2950-i6q4l2-mz.121-19.EA1a.bin
Switch#show boot
BOOT path-list:flash:c2950-i6q4l2-mz.121-19.EA1a.bin
Config file:flash:/config.text
Private Config file:flash:/private-config.text
Enable Break:no
Manual Boot:NO
HELPER path-list:
NVRAM/Config file
buffer size:32768
• 查看 flash 空間使用狀況
Switch#show file systems | include flash:
*77414403240960flashrw flash
77414403240960unknownrwzflash:
• 列出 flash 內檔案清單及使用狀況
Switch#dir flash:
Directory of flash:/
2-rwx108Mar 01 1993 00:03:15info
3-rwx2980487Mar 01 1993 00:04:32c2950-i6q4l2-mz.121-19.EA1a.bin
4drwx640Mar 01 1993 00:05:22html
15-rwx108Mar 01 1993 00:05:22info.ver
17-rwx350Jan 01 1970 00:01:25env_vars
18-rwx856Mar 01 1993 00:00:18vlan.dat
7741440 bytes total (3240960 bytes free)
步驟2.設定 Switch 管理 IP
• 若您的 Switch 已設定管理 IP,則請忽略此步驟,下列為設定 Switch 管理 IP 至預設的 VLAN (VLAN1) 上
Switch#conf t//進入 Configure 模式
Switch(config)#int vlan 1//進入 VLAN 1
Switch(config-if)#ip address 192.168.1.1 255.255.255.0//指定 IP Address
Switch(config-if)#no shutdown//啟用 VLAN 1
Switch(config-if)#exit
Switch(config)#exit
Switch#sh interfaces vlan 1 //顯示 VLAN1 資訊
Vlan1 is up, line protocol is down
Hardware is CPU Interface, address is 000c.8504.9d80 (bia 000c.8504.9d80)
Internet address is 192.168.1.1/24//VLAN 1 的 IP 設定成功
• Switch 設定 IP Address 完成後,確定 Switch 跟 TFTP Server 的主機能互相 Ping 得到
TFTP Server 啟動服務 (UDP Port 69) 後去 Ping Switch
C:\>netstat -na | find “:69” //確定 TFTP Service 有啟動
UDP0.0.0.0:69*:*
C:\>ping 192.168.1.1//確定與 Switch 能溝通
Ping 192.168.1.1 (使用 32 位元組的資料):
回覆自 192.168.1.1: 位元組=32 時間=4ms TTL=255
回覆自 192.168.1.1: 位元組=32 時間=1ms TTL=255
回覆自 192.168.1.1: 位元組=32 時間=1ms TTL=255
回覆自 192.168.1.1: 位元組=32 時間=1ms TTL=255
192.168.1.1 的 Ping 統計資料:
封包: 已傳送 = 4,已收到 = 4, 已遺失 = 0 (0% 遺失),
大約的來回時間 (毫秒):
最小值 = 1ms,最大值 = 4ms,平均 = 1ms
從 Switch 去 Ping TFTP Server
Switch#ping 192.168.1.2 //確定 Switch 能與 TFTP Server 溝通
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.1.2, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 1/3/8 ms
步驟3.備份目前的 IOS
• Switch#copy flash:c2950-i6q4l2-mz.121-19.EA1a.bin tftp
//將目前 IOS 上傳至 TFTP Server 上
Address or name of remote host []? 192.168.1.2
//指定 TFTP Server IP Address
Destination filename [c2950-i6q4l2-mz.121-19.EA1a.bin]?
//目前 IOS 上傳至 TFTP Server 後的檔案名稱
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
2980487 bytes copied in 19.124 secs (131084 bytes/sec)