如果要跨vlan溝通的話,就必須要指派ipvlan

 ScreenHunter_02 Feb. 19 07.10  

要連結router的介面也必須要設定為trunk mode

Switch0(config)#interface gigabitethernet 1/1

Switch0(config-if)#switchport mode trunk

router上一個介面要連結多個vlan,要設定多個子介面,並指定子界面的ip,並啟用802.1Q封裝。

Router>en

Router#conf t

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

Router(config)#interface fastethernet 0/0

Router(config-if)#no sh 路由器所有的介面預設都是關閉的

 

Router(config-if)#

%LINK-5-CHANGED: Interface FastEthernet0/0, changed state to up

 

%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up

 

Router(config-if)#int fastethernet 0/0.10  將子界面的編號與vlan編號設定為相同

Router(config-subif)#

%LINK-5-CHANGED: Interface FastEthernet0/0.10, changed state to up

 

%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0.10, changed state to up

 

Router(config-subif)#encapsulation dot1q 10  啟用802.1q封裝,並對應vlan10

Router(config-subif)#ip address 192.168.1.254 255.255.255.0  指定子界面ip,使它成為vlan10Gateway

再設定子界面20對應到vlan20的部分

Router(config)#int fastethernet 0/0.20

Router(config-subif)#

%LINK-5-CHANGED: Interface FastEthernet0/0.20, changed state to up

 

%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0.20, changed state to up

 

Router(config-subif)#encapsulation dot1q 20

Router(config-subif)#ip address 192.168.2.254 255.255.255.0

這樣就設定完畢,要檢查一下trunk的狀態。

Switch0>sh int trunk

Port        Mode         Encapsulation  Status        Native vlan

Gig1/1      on           802.1q         trunking      1

 

Port        Vlans allowed on trunk

Gig1/1      1-1005

 

Port        Vlans allowed and active in management domain

Gig1/1      1,10,20

 

Port        Vlans in spanning tree forwarding state and not pruned

Gig1/1      1,10,20

接著來測試一下不同vlan是否可以互通了。

vlan1192.168.1.1 Ping Vlan2192.168.2.1

PC>ping 192.168.2.1

 

Pinging 192.168.2.1 with 32 bytes of data:

 

Request timed out.

Reply from 192.168.2.1: bytes=32 time=0ms TTL=127

Reply from 192.168.2.1: bytes=32 time=0ms TTL=127

Reply from 192.168.2.1: bytes=32 time=0ms TTL=127

 

Ping statistics for 192.168.2.1:

    Packets: Sent = 4, Received = 3, Lost = 1 (25% loss),

Approximate round trip times in milli-seconds:

    Minimum = 0ms, Maximum = 0ms, Average = 0msScreenHunter_02 Feb. 19 07.10  

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

林作倉

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