01. 開篇:組建小型局域網
實驗任務
1、利用一台型號為2960的交換機將2pc機互連組建一個小型局域網;
2、分別設置pc機的ip地址;
3、驗證pc機間可以互通。
實驗設備
Switch_2960 1台;PC 2台;直連線

實驗設備配置
PC0
IP: 192.168.1.2
Submask: 255.255.255.0
Gateway: 192.168.1.1
PC1
IP: 192.168.1.3
Submask: 255.255.255.0
Gateway: 192.168.1.1
實驗驗證過程
打開【PC中 >> Desktop >> Commond prompt】
pc0上 ping 192.168.1.3(PC1)的ip地址

在 PC1上ping 192.168.1.2(PC0)的ip地址

分別在PC0和PC1上ping網關地址192.168.1.1

02. 交換機的基本配置和管理
技術原理
交換機的管理方式基本分為兩種:帶內管理和帶外管理。
通過交換機的Console端口管理交換機屬於帶外管理;這種管理方式不占用交換機的網絡端口,第一次配置交換機必須利用Console端口進行配置。交換機的命令行操作模式主要包括:
用戶模式 (EXEC模式) Switch> 特權模式 Switch# 全局配置模式 Switch(config) 端口模式 Switch(config-if)#
交換機常用的配置命令行
模式切換指令 enable 進入特權模式(一般簡寫為en) config t 進入全局配置模式 interface fa 0/1 進入交換機某個端口視圖模式 exit 返回到上級模式 end 從全局以下模式返回到特權模式 快捷指令 幫助信息(如? 、co?、copy?) 命令簡寫(如 en 的完整命令為 enable) 命令自動補全(Tab) 快捷鍵(ctrl+c中斷測試,ctrl+z退回到特權視圖) reload 重啟(在特權模式下) hostname X修改交換機名稱(在全局配置模式下) 端口配置指令 speed,duplex 配置交換機端口參數 show version 查看交換機版本信息 show running-config 查看當前生效的配置信息 show startup-config 查看保存在NVRAM中的啟動配置信息 show interface 查看端口信息 show mac-address-table 查看交換機的MAC地址 選擇某個端口Switch(config)# interface type mod/port (type:端口類型,通常有ethernet、Fastethernet、Gigabitethernet; mod:端口所在的模塊; port:在該模塊中的編號;):Switch(config)# interface fa 0/1; 選擇多個端口Switch(config)#interface type mod/startport-endport 如:Switch(config)# interface interface fa 0/1-5 //選擇端口 fa 0/1 ~ fa 0/5 Switch(config-if)#speed [10/100/auto] 設置端口通信速度 Switch(config-if)#duplex [half/full/auto] 設置端口單雙工模式 若交換機設置為auto以外的具體速度,此時應注意保證通信雙方也要有相同的設置值。 注意事項:在配置交換機時,要注意交換機端口的單雙工模式的匹配,如果鏈路一端設置的是全雙工,另一端是自動協商,則會造成響應差和高出錯率,丟包現象會很嚴重。
通常兩端設置為相同的模式。 密碼設置指令 設置進入特權模式的密碼 Switch(config)# enable password ****** 通過console端口連接設備及Telnet遠程登錄時所需的密碼; Switch(config)# line console 0 表示配置控制台線路,0是控制台的線路編號。 Switch(config-line)# login 用於打開登錄認證功能。 Switch(config-line)# password 5ijsj 設置進入控制台訪問的密碼
實驗設備
Switch_2960 1台;PC 1台;配置線;直通線

實驗配置設備
PC console端口【PC >> Desktop >>Terminal】
修改交換機名、端口
Switch>enable //進入特權模式 Switch#conf t //進入配置模式 Switch(config)#hostname S2960 //修改交換機名 S2960(config)#interface fa 0/1 //選擇端口 S2960(config-if)#speed 100 //修改端口配置 S2960(config-if)#duplex full S2960(config-if)#exit 同時將PC的網卡改成全雙工模式,100M速率,否則鏈路不通
查看交換機各項配置參數
Switch#show version Switch#show run Switch#show interface Switch#show mac-address-table Switch#config t
修改交換機特權
Switch(config)#enable password cisco //激活特權模式密碼為cisco Switch(config)#no enable password //取消特權模式密碼
修改交換機連接和telnet密碼
Switch(config)#line console 0 //選擇控制台線路 Switch(config-line)#password cisco //激活該控制台線路密碼為cisco Switch(config-line)#login //打開登錄認證功能 Switch(config-line)#no password //取消密碼
03. 交換機的Telnet遠程登陸配置
技術原理
實驗步驟
Switch(config)# int vlan 1 Switch(config-if)# ip address **IP** **submask***
3、配置用戶登錄密碼
Switch(config)# enable password ******* //設置進入特權模式的密碼 Switch(config)# line vty 0 4 // Switch(config-line)# password abc Switch(config-line)# login
實驗設備
實驗設備配置
Swicth0設置(通過PC0的terminal設置 )
Switch>en //進入特權模式 Switch#conf t //進入全局配置模式 Switch(config)#interface vlan 1 //創建並進入VLAN 1的接口視圖(默認交換機的所有端口都在VLAN1中) Switch(config-if)#ip address 192.168.1.1 255.255.255.0 //在VLAN 1 接口上配置交換機遠程管理的IP地址 Switch(config-if)#no shutdown //開啟接口 Switch(config-if)#exit Switch(config)#line vty 0 4 //進入遠程登錄用戶管理視圖,0-4個用戶 Switch(config-line)#login //打開登錄認證功能 Switch(config-line)#password cisco //配置遠程登錄的密碼為5ijsj,密碼明碼顯示 Switch(config-line)#privilege level 1 //配置遠程登錄用戶的權限為最低權限1(最高權限3) Switch(config-line)#end Switch#show run //顯示當前交換機配置情況
實驗驗證
PC0 桌面選項卡中的CMD,命令提示符
ping 192.168.1.1 //成功以后,再做下一步 telnet 192.168.1.1 輸入password:cisco //登錄成功,進入用戶模式 Switch>Enable//進入特權模式 Switch#
PC1 桌面選項卡中的CMD,命令提示符
ping 192.168.1.1 //成功以后,再做下一步 telnet 192.168.1.1 輸入password:cisco //登錄成功,進入用戶模式 Switch>Enable//進入特權模式 Switch#
04. 交換機的端口聚合配置
技術原理
interface range interface_name1 to interface_name2 Switchport mode trunk channel-group 1 mode on 加入鏈路組1並開啟 Switch#show etherchannel summary:顯示相關匯聚端口組的信息; 參數: interface_name1:聚合起始端口; interface_name2:聚合結束端口; trunk:表示端口可以轉發所有Vlan包,trunk mode 的接口可以同時傳輸多個VLAN信息的; trunk mode 常用在兩個SWITCH and ROUTER ,SWITCH and SWITCH 之間; channel-group: 將2個或多個物理端口組合在一起成為一條邏輯的鏈路 ,同時也形成了一個邏輯端口port-channel switchport mode access:直接接主機,所屬VLAN中的接口,都是access
實驗設備
實驗設備配置
Switch>enable Switch#config t Switch(config)#interface range fa 0/1-2 //同時選擇端口fa0/1 fa0/2 Switch(config-if-range)#Switchport mode trunk //設置端口模式為trunk Switch(config-if-range)#channel-group 1 mode on //加入鏈路組1並開啟 Switch(config-if-range)#exit Switch(config)#port-channel load-balance dst-ip //按照目標主機IP地址數據分發來實現負載平衡 Switch(config)#exit Switch#show etherchannel summary //顯示以太信道概況

Switch1
Switch>en Switch#config t Switch(config)#interface range f0/1-2 Switch(config-if-range)#Switchport mode trunk //設置端口模式為trunk Switch(config-if-range)#channel-group 1 mode on //加入鏈路組1並開啟 Switch(config-if-range)#exit Switch(config)#port-channel load-balance dst-ip //按照目標主機IP地址數據分發來實現以太網通道組負載平衡 Switch(config)#exit Switch#show etherchannel summary //顯示以太網通道組的情況
實驗驗證
PC0 ping PC1 Reply
PC1 ping PC0 Reply
05. 交換機划分Vlan配置
技術原理
1) VLAN是指在一個物理網段內。進行邏輯的划分,划分成若干個虛擬局域網,VLAN做大的特性是不受物理位置的限制,可以進行靈活的划分。VLAN具備了一個物理網段所具備的特性。相同VLAN內的主機可以相互直接通信,不同VLAN間的主機之間互相訪問必須經路由設備進行轉發,廣播數據包只可以在本VLAN內進行廣播,不能傳輸到其他VLAN中。
2)Port VLAN是實現VLAN的方式之一,它利用交換機的端口進行VALN的划分,一個端口只能屬於一個VLAN。
3)Tag VLAN是基於交換機端口的另一種類型,主要用於是交換機的相同Vlan內的主機之間可以直接訪問,同時對不同Vlan的主機進行隔離。Tag VLAN遵循IEEE802.1Q協議的標准,在使用配置了Tag VLAN的端口進行數據傳輸時,需要在數據幀內添加4個字節的8021.Q標簽信息,用於標示該數據幀屬於哪個VLAN,便於對端交換機接收到數據幀后進行准確的過濾。
實驗說明
在同一個局域網中,要實現PC0、PC2為同一個分組,PC1、PC3屬於同一個分組,PC0、PC1,PC2、PC3使用分別使用同一個交換機;
在4個PC使用同一個網關的情況下,將4個PC進行Vlan分組划分,實現兩個分組之間的相互隔離;
實驗步驟
1. 新建Packet Tracer拓撲圖;
2. 划分VLAN;
3. 將端口划分到相應VLAN中;
4. 設置Tag VLAN Trunk屬性;
5. 測試
實驗設備
Switch_2960 2台;PC 4台;直連線

實驗設備配置
IP: 192.168.1.2
Submark: 255.255.255.0
Gateway: 192.168.1.1
PC1
IP: 192.168.1.3
Submark: 255.255.255.0
Gateway: 192.168.1.1
PC2
IP: 192.168.1.4
Submark: 255.255.255.0
Gateway: 192.168.1.1
PC3
IP: 192.168.1.5
Submark: 255.255.255.0
Gateway: 192.168.1.1
Switch0
Switch>en Switch#conf t Switch(config)#vlan 2 //向交換機添加新的虛擬端口 vlan 2 Switch(config-vlan)#exit Switch(config)#vlan 3 //添加新的vlan 3 Switch(config-vlan)#exit Switch(config)#interface fa 0/1 //切換到fa 0/1端口,並將該端口綁定到vlan2 Switch(config-if)#switch access vlan 2 Switch(config-if)#exit Switch(config)#interface fa 0/2 //切換到fa 0/2端口,並將該端口綁定到vlan3 Switch(config-if)#switch access vlan 3 Switch(config-if)#exit Switch(config)#inter fa 0/24 //切換到fa 0/24(示例中為交換機連接端口), Switch(config-if)#switchport mode trunk //並將更改其連接模式為trunk Switch(config-if)#end Switch#show vlan //顯示交換機的 vlan 配置情況
Switch1
Switch>en Switch#conf t Switch(config)#vlan 2 Switch(config-vlan)#exit Switch(config)#vlan 3 Switch(config-vlan)#exit Switch(config)#interface fa 0/1 Switch(config-if)#switchport access vlan 2 Switch(config-if)#exit Switch(config)#inter fa 0/2 Switch(config-if)#switchport access vlan 3 Switch(config-if)#exit Switch(config)#inter fa 0/24 Switch(config-if)#switch mode trunk Switch(config-if)#end Switch#show vlan
實驗驗證
PC1 ping PC2 timeout
PC1 ping PC3 Reply
