天天看點

十五、配置虛拟區域網路(VLAN)

十五、配置虛拟區域網路(VLAN)

實驗目的:1、學習VLAN的配置及作用。

                      2、學習單臂路由的配置及作用。

                      3、在交換機sw1900上建立vlan11、vlan22;PC0 加入vlan11 ,PC1加入vlan22;  R2配置單臂路由,使得PC1和PC2可以通信。

實驗拓撲:

十五、配置虛拟區域網路(VLAN)

1、ip位址表:

PC0                                         172.16.10.2/24     GW    172.16.10.1

PC1                                         172.16.20.2/24     GW    172.16.20.1

R2                F0.1                    172.16.10.1/24

R2                F0.2                    172.16.20.1/24

2、

sw1900的配置:

sw1900(config)#interface f0/24

sw1900(config-if)#switchport mode trunk

sw1900(config-if)#switchport trunk  allow vla all

sw1900(config-vlan)#exit

sw1900(config)#vlan 11

sw1900(config)#vlan 22

sw1900(config)#interface fastEthernet 0/1

sw1900(config-if)#switchport access vlan 11

sw1900(config)#interface fastEthernet 0/2

sw1900(config-if)#switchport acc vla 22

R2的配置:

Router(config)#inter f0/0

Router(config-if)#no shut //激活端口

R2(config)#interface f0/0.1 //進入子接口

R2(config-subif)#encapsulation dot1Q 11 //11為交換機中配置的vlan的id

R2(config-subif)#ip address 172.16.10.1 255.255.255.0

R2(config-subif)#exit

R2(config)#interface f0/0.2

R2(config-subif)#encapsulation dot1Q 22

R2(config-subif)#ip address 172.16.20.1 255.255.255.0

驗證:pc0和pc1互相ping的資訊分别如下

PC>ping 172.16.20.2

Pinging 172.16.20.2 with 32 bytes of data:

Reply from 172.16.20.2: bytes=32 time=147ms TTL=127

Reply from 172.16.20.2: bytes=32 time=153ms TTL=127

Reply from 172.16.20.2: bytes=32 time=131ms TTL=127

Reply from 172.16.20.2: bytes=32 time=155ms TTL=127

Pinging 172.16.10.2 with 32 bytes of data:

Reply from 172.16.10.2: bytes=32 time=171ms TTL=127

Reply from 172.16.10.2: bytes=32 time=146ms TTL=127

Reply from 172.16.10.2: bytes=32 time=161ms TTL=127

Reply from 172.16.10.2: bytes=32 time=202ms TTL=127

結論:

1、可見網絡可以互通信,配置成功了。

2、在區域網路中,通過交換機上配置VLAN可以減少主機通信廣播域的範圍,當VLAN之間有部分主機需要通信,但交換機不支援三層交換時,可以采用一台路由器做單臂路由實作VLAN的互通.

繼續閱讀