所以假如環境如下:

 ScreenHunter_08 Feb. 18 14.59.jpg  

我們要先觀察一下switch上所設定的vlan:

Switch#show vlan

 

VLAN Name                             Status    Ports

---- -------------------------------- --------- -------------------------------

1    default                          active    Fa0/1, Fa0/2, 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, Fa0/24

                                                Gig1/1, Gig1/2

上面可以看的出來,目前所有的端口都是在預設下的vlan1

 

那麼該如何切割vlan?

假定有個環境如下:

 ScreenHunter_08 Feb. 18 14.59.jpg  

這四台電腦是可以互通的

Packet Tracer PC Command Line 1.0

PC>ping 192.168.1.2

 

Pinging 192.168.1.2 with 32 bytes of data:

 

Reply from 192.168.1.2: bytes=32 time=0ms TTL=128

Reply from 192.168.1.2: bytes=32 time=0ms TTL=128

Reply from 192.168.1.2: bytes=32 time=4ms TTL=128

Reply from 192.168.1.2: bytes=32 time=0ms TTL=128

 

Ping statistics for 192.168.1.2:

    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),

Approximate round trip times in milli-seconds:

    Minimum = 0ms, Maximum = 4ms, Average = 1ms

 

PC>ping 192.168.1.3

 

Pinging 192.168.1.3 with 32 bytes of data:

 

Reply from 192.168.1.3: bytes=32 time=0ms TTL=128

Reply from 192.168.1.3: bytes=32 time=0ms TTL=128

Reply from 192.168.1.3: bytes=32 time=0ms TTL=128

Reply from 192.168.1.3: bytes=32 time=0ms TTL=128

 

Ping statistics for 192.168.1.3:

    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),

Approximate round trip times in milli-seconds:

    Minimum = 0ms, Maximum = 0ms, Average = 0ms

 

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=0ms TTL=128

Reply from 192.168.1.4: bytes=32 time=0ms TTL=128

Reply from 192.168.1.4: bytes=32 time=0ms TTL=128

Reply from 192.168.1.4: bytes=32 time=0ms 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 = 0ms, Maximum = 0ms, Average = 0ms

 

PC>

首先我們先切割vlan10vlan20

Switch>en

Switch#conf t

Enter configuration commands, one per line.  End with CNTL/Z.

Switch(config)#vlan10

                   ^

% Invalid input detected at '^' marker.

       

Switch(config)#vlan 10

Switch(config-vlan)#vlan 20

Switch(config-vlan)#exit

Switch(config)#exit

Switch#

%SYS-5-CONFIG_I: Configured from console by console

 

Switch#show vlan

 

VLAN Name                             Status    Ports

---- -------------------------------- --------- -------------------------------

1    default                          active    Fa0/1, Fa0/2, 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, Fa0/24

                                                Gig1/1, Gig1/2

10   VLAN0010                         active   

20   VLAN0020                         active    

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

10   enet  100010     1500  -      -      -        -    -        0      0

20   enet  100020     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

------- --------- ----------------- ------------------------------------------

 

接著就必須將端口指定給設定好的vlan

Switch#conf t

Enter configuration commands, one per line.  End with CNTL/Z.

Switch(config)#interface fastethernet 0/1

Switch(config-if)#switchport access vlan 10

Switch(config-if)#exit

Switch(config)#interface fastethernet 0/2

Switch(config-if)#switchport access vlan 10

 

一個一個端口設定太慢了

Switch(config)#interface range fastethernet 0/3 - 4

Switch(config-if-range)#switchport access vlan 20

 

再檢查一次目前vlan的狀況,可以看到目前1~2vlan103~4vlan20

Switch#show vlan

 

VLAN Name                             Status    Ports

---- -------------------------------- --------- -------------------------------

1    default                          active    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, Fa0/24

                                                Gig1/1, Gig1/2

10   VLAN0010                         active    Fa0/1, Fa0/2

20   VLAN0020                         active    Fa0/3, Fa0/4

 

所以不同vlan就無法互通了

PC>ping 192.168.1.2

 

Pinging 192.168.1.2 with 32 bytes of data:

 

Reply from 192.168.1.2: bytes=32 time=1ms TTL=128

Reply from 192.168.1.2: bytes=32 time=0ms TTL=128

Reply from 192.168.1.2: bytes=32 time=0ms TTL=128

Reply from 192.168.1.2: bytes=32 time=0ms TTL=128

 

Ping statistics for 192.168.1.2:

    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),

Approximate round trip times in milli-seconds:

    Minimum = 0ms, Maximum = 1ms, Average = 0ms

 

PC>ping 192.168.1.3

 

Pinging 192.168.1.3 with 32 bytes of data:

 

Request timed out.

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:

 

Request timed out.

Request timed out.

Request timed out.

Request timed out.

 

Ping statistics for 192.168.1.4:

    Packets: Sent = 4, Received = 0, Lost = 4 (100% loss),

創作者介紹
創作者 林作倉 的頭像
林作倉

林作倉

林作倉 發表在 痞客邦 留言(0) 人氣()