Packet Tracer 5.0實驗(三) 交換機划分VLAN配置


一、實驗目標

  • 理解虛擬 LAN(VLAN)基本原理;
  • 掌握一般交換機按端口划分 VLAN的配置方法;
  • 掌握Tag VLAN配置方法。

 

二、實驗背景

某一公司內財務部、銷售部的PC通過2台交換機實現通信;要求財務部和銷售部內的PC可以互通,但為了數據安全起見,銷售部和財務部需要進行隔離,現要在交換機上做適當配置來實現這一目的。

 

三、技術原理

  • VLAN是指在一個物理網段內,進行邏輯的划分,划分成若干個虛擬局域網。VLAN最大的特性是不受物理位置的限制,可以進行靈活的划分。VLAN具備了一個物理網段所具備的特性。相同VLAN內的主機可以相互直接通信,不同VLAN間的主機之間互相訪問必須經由路由設備進行轉發。廣播數據包只可以在本VLAN內進行廣播,不能傳輸到其他VLAN中。
  • Port VLAN是實現VLAN的方式之一,它利用交換機的端口進行VLAN的划分,一個端口只能屬於一個VLAN。
  • Tag VLAN是基於交換機端口的另外一種類型,主要用於使交換機的相同VLAN內的主機之間可以直接訪問,同時對於不同VLAN的主機進行隔離。Tag VLAN遵循IEEE802.1Q協議的標准。在使用配置了Tag VLAN的端口進行數據傳輸時,需要在數據幀內添加4個字節的802.1Q標簽信息,用於標示該數據幀屬於哪個VLAN,便於對端交換機收到數據幀后進行准確的過濾。

 

四、實驗步驟

實驗拓撲

1、設置四台PC機IP地址如圖所示。

2、對交換機S1進行設置。

Switch>en
Switch#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
Switch(config)#hostname S1                             //設置主機名
S1(config)#vlan 2                                      //划分VLAN 2
S1(config-vlan)#exit
S1(config)#vlan 3                                      //划分VLAN 3
S1(config-vlan)#exit
S1(config)#interface fa0/1
S1(config-if)#switchport access vlan 2                 //將fa0/1划分到VLAN 2
S1(config-if)#exit
S1(config)#interface fa0/2
S1(config-if)#switchport access vlan 3                 //將fa0/2划分到VLAN 3
S1(config-if)#exit
S1(config)#interface fa0/24                            //設置fa0/24端口模式為trunk
S1(config-if)#switchport mode trunk
S1(config-if)#end
S1#
%SYS-5-CONFIG_I: Configured from console by console

S1#show vlan                                           //查看VLAN划分情況

VLAN Name                             Status    Ports
---- -------------------------------- --------- -------------------------------
1    default                          active    Fa0/3, Fa0/4, Fa0/5, Fa0/6
                                                Fa0/7, Fa0/8, Fa0/9, Fa0/10
                                                Fa0/11, Fa0/12, Fa0/13, Fa0/14
                                                Fa0/15, Fa0/16, Fa0/17, Fa0/18
                                                Fa0/19, Fa0/20, Fa0/21, Fa0/22
                                                Fa0/23, Gig1/1, Gig1/2
2    VLAN0002                         active    Fa0/1
3    VLAN0003                         active    Fa0/2
1002 fddi-default                     act/unsup
1003 token-ring-default               act/unsup
1004 fddinet-default                  act/unsup
1005 trnet-default                    act/unsup

VLAN Type  SAID       MTU   Parent RingNo BridgeNo Stp  BrdgMode Trans1 TranS1
---- ----- ---------- ----- ------ ------ -------- ---- -------- ------ ------
1    enet  100001     1500  -      -      -        -    -        0      0
2    enet  100002     1500  -      -      -        -    -        0      0
3    enet  100003     1500  -      -      -        -    -        0      0
1002 fddi  101002     1500  -      -      -        -    -        0      0   
1003 tr    101003     1500  -      -      -        -    -        0      0   
1004 fdnet 101004     1500  -      -      -        ieee -        0      0   
1005 trnet 101005     1500  -      -      -        ibm  -        0      0   

Remote SPAN VLANs
------------------------------------------------------------------------------


Primary Secondary Type              Ports
------- --------- ----------------- ------------------------------------------
S1#show running-config
Building configuration...

Current configuration : 1080 bytes
!
version 12.2
no service timestamps log datetime msec
no service timestamps debug datetime msec
no service password-encryption
!
hostname S1
!
!
!
interface FastEthernet0/1
 switchport access vlan 2
!
interface FastEthernet0/2
 switchport access vlan 3
!
interface FastEthernet0/3
!
......
!
interface FastEthernet0/24
 switchport mode trunk
!
interface GigabitEthernet1/1
!
interface GigabitEthernet1/2
!
interface Vlan1
 no ip address
 shutdown
!
!
line con 0
!
line vty 0 4
 login
line vty 5 15
 login
!
!
end


S1#

3、對交換機S2進行設置。

Switch>en
Switch#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
Switch(config)#hostname S2
S2(config)#vlan 2
S2(config-vlan)#exit
S2(config)#vlan 3
S2(config-vlan)#exit
S2(config)#interface fa0/1
S2(config-if)#switchport access vlan 2
S2(config-if)#exit
S2(config)#interface fa0/2
S2(config-if)#switchport access vlan 3
S2(config-if)#exit
S2(config)#interface fa0/24
S2(config-if)#switchport mode trunk 
S2(config-if)#end
S2#
%SYS-5-CONFIG_I: Configured from console by console

S2#show vlan

VLAN Name                             Status    Ports
---- -------------------------------- --------- -------------------------------
1    default                          active    Fa0/3, Fa0/4, Fa0/5, Fa0/6
                                                Fa0/7, Fa0/8, Fa0/9, Fa0/10
                                                Fa0/11, Fa0/12, Fa0/13, Fa0/14
                                                Fa0/15, Fa0/16, Fa0/17, Fa0/18
                                                Fa0/19, Fa0/20, Fa0/21, Fa0/22
                                                Fa0/23, Gig1/1, Gig1/2
2    VLAN0002                         active    Fa0/1
3    VLAN0003                         active    Fa0/2
1002 fddi-default                     act/unsup 
1003 token-ring-default               act/unsup 
1004 fddinet-default                  act/unsup 
1005 trnet-default                    act/unsup 

VLAN Type  SAID       MTU   Parent RingNo BridgeNo Stp  BrdgMode Trans1 Trans2
---- ----- ---------- ----- ------ ------ -------- ---- -------- ------ ------
1    enet  100001     1500  -      -      -        -    -        0      0
2    enet  100002     1500  -      -      -        -    -        0      0
3    enet  100003     1500  -      -      -        -    -        0      0
1002 fddi  101002     1500  -      -      -        -    -        0      0   
1003 tr    101003     1500  -      -      -        -    -        0      0   
1004 fdnet 101004     1500  -      -      -        ieee -        0      0   
1005 trnet 101005     1500  -      -      -        ibm  -        0      0   

Remote SPAN VLANs
------------------------------------------------------------------------------


Primary Secondary Type              Ports
------- --------- ----------------- ------------------------------------------
S2#show running-config 
Building configuration...

Current configuration : 1080 bytes
!
version 12.2
no service timestamps log datetime msec
no service timestamps debug datetime msec
no service password-encryption
!
hostname S2
!
!
!
interface FastEthernet0/1
 switchport access vlan 2
!
interface FastEthernet0/2
 switchport access vlan 3
!
interface FastEthernet0/3
!
......
!
interface FastEthernet0/24
 switchport mode trunk
!
interface GigabitEthernet1/1
!
interface GigabitEthernet1/2
!
interface Vlan1
 no ip address
 shutdown
!
!
line con 0
!
line vty 0 4
 login
line vty 5 15
 login
!
!
end


S2#

 

五、驗證

打開PC1的Command Prompt

Packet Tracer PC Command Line 1.0
PC>ipconfig

IP Address......................: 192.168.1.2
Subnet Mask.....................: 255.255.255.0
Default Gateway.................: 192.168.1.1

PC>ping 192.168.1.3

Pinging 192.168.1.3 with 32 bytes of data:

Request timed out.                            //不同VLAN間無法PING通
Request timed out.
Request timed out.
Request timed out.

Ping statistics for 192.168.1.3:
    Packets: Sent = 4, Received = 0, Lost = 4 (100% loss),

 
PC>ping 192.168.1.4

Pinging 192.168.1.4 with 32 bytes of data:

Reply from 192.168.1.4: bytes=32 time=172ms TTL=128                //相同VLAN可以PING通
Reply from 192.168.1.4: bytes=32 time=78ms TTL=128
Reply from 192.168.1.4: bytes=32 time=63ms TTL=128
Reply from 192.168.1.4: bytes=32 time=79ms TTL=128

Ping statistics for 192.168.1.4:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 63ms, Maximum = 172ms, Average = 98ms


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM