您的位置:首页 > 理论基础

利用三层交换机实现不同VLAN间的访问

2011-08-03 16:48 573 查看
【实验名称】
VLAN/802.1Q-VLAN间的通信
【实验目的】
通过三层交换机实现VLAN间互相通信
【实验功能】
使在同一VLAN里的计算机系统能跨交换机进行相互通信,而在不同VLAN里的计算机系统也能进行相互通信
【实验设备】
三层交换机(1台)、普通可网管交换机(1台)、直连线(3条)
【实验拓扑】




【实验步骤】
三层交换机:3Switch1
Switch>enable
Switch#configure terminal
Switch(config)#vlan 10
Switch(config-vlan)#exit
Switch(config)#vlan 20
Switch(config-vlan)#exit
Switch(config)#interface fastEthernet 0/5
Switch(config-if)#switchport access vlan 10
Switch(config-if)#exit
Switch(config)#interface fastEthernet 0/15
Switch(config-if)#switchport access vlan 20
Switch(config-if)#exit
Switch(config)#interface fastEthernet 0/24
Switch(config-if)#switchport mode trunk

二层交换机:Switch1
Switch>enable
Switch#configure terminal
Switch(config)#vlan 10
Switch(config-vlan)#exit
Switch(config)#interface fastEthernet 0/5
Switch(config-if)#switchport access vlan 10
Switch(config)#interface fastEthernet 0/24
Switch(config-if)#switchport mode trunk
现在我们把192.168.10.1 、192.168.10.2分别给VLAN10 里的2个PC
192.168.10.3 给VLAN 20的 PC
此时发现
PC>ping 192.168.10.2
Pinging 192.168.10.2 with 32 bytes of data:
Reply from 192.168.10.2: bytes=32 time=93ms TTL=128
Reply from 192.168.10.2: bytes=32 time=78ms TTL=128
Reply from 192.168.10.2: bytes=32 time=93ms TTL=128
Reply from 192.168.10.2: bytes=32 time=94ms TTL=128
Ping statistics for 192.168.10.2:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 78ms, Maximum = 94ms, Average = 89ms
PC>ping 192.168.10.3
Pinging 192.168.10.3 with 32 bytes of data:
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Ping statistics for 192.168.10.3:
Packets: Sent = 4, Received = 0, Lost = 4 (100% loss),
相同VLAN可以通信 不同VLAN 不可通信!
本章节关键就在这里!
继续在三层交换机配置
Switch(config)#interface vlan 10 (进入虚拟VLAN接口)
Switch(config-if)#no shutdown
Switch(config-if)#ip address 192.168.10.254 255.255.255.0 (配置IP地址 即VLAN10网关)
Switch(config-if)#exit
Switch(config)#interface vlan 20
Switch(config-if)#no shutdown
Switch(config-if)#ip address 192.168.20.254 255.255.255.0

这时把VLAN20的PC IP改成192.168.20.1 因为要和网关一个网段 (开始配置是为了证明不通VLAN 就算一个网段IP亦不可通)
VLAN10 的PC 网关改为192.168.10.254 VLAN 20PC网关 192.168.20.254
此时:
PC>ping 192.168.10.1
Pinging 192.168.10.1 with 32 bytes of data:
Reply from 192.168.10.1: bytes=32 time=62ms TTL=127
Reply from 192.168.10.1: bytes=32 time=63ms TTL=127
Reply from 192.168.10.1: bytes=32 time=31ms TTL=127
Reply from 192.168.10.1: bytes=32 time=62ms TTL=127
Ping statistics for 192.168.10.1:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 31ms, Maximum = 63ms, Average = 54ms
PC>ping 192.168.10.2
Pinging 192.168.10.2 with 32 bytes of data:
Reply from 192.168.10.2: bytes=32 time=94ms TTL=127
Reply from 192.168.10.2: bytes=32 time=93ms TTL=127
Reply from 192.168.10.2: bytes=32 time=78ms TTL=127
Reply from 192.168.10.2: bytes=32 time=94ms TTL=127
Ping statistics for 192.168.10.2:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 78ms, Maximum = 94ms, Average = 89ms
全网互通!
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息