不同vlan间通信

Vlan间通信:

 

可通过路由器进行通信------用到的技术叫做单臂路由

可通过交换机进行通信------用到的技术叫做创建虚拟接口SVI并设置对应vlan中的计算机的网关为vlan的虚拟接口地址

 

网络拓扑:

-----通过路由器

不同vlan间通信_第1张图片

 

实验配置:

交换机1:

Switch>en

Switch#conf t

Enter configuration commands, one per line. End withCNTL/Z.

Switch(config)#vlan 2

Switch(config-vlan)#exit

Switch(config)#vlan 3

Switch(config-vlan)#exit

Switch(config)#interface fastEthernet 0/2

Switch(config-if)#switchport access vlan 2

Switch(config-if)#exit

Switch(config)#interface fastEthernet 0/3

Switch(config-if)#switchport access vlan 3

Switch(config-if)#exit

Switch(config)#interface fastEthernet 0/1

Switch(config-if)#switchport mode trunk         //将1口设置为trunk链路

交换机2:

Switch>en

Switch#conf t

Enter configuration commands, one per line. End withCNTL/Z.

Switch(config)#vlan 4

Switch(config-vlan)#exit

Switch(config)#vlan 5

Switch(config-vlan)#exit

Switch(config)#interface fastEthernet 0/23

Switch(config-if)#switchport access vlan 4

Switch(config-if)#exit

Switch(config)#interface fastEthernet 0/22

Switch(config-if)#switchport access vlan 5

Switch(config-if)#exit

Switch(config)#interface fastEthernet 0/24

Switch(config-if)#switchport mode trunk

Switch(config-if)#end

Switch#show running-config

Building configuration...

 

Current configuration : 1052 bytes

!

version 12.1

no service timestamps log datetime msec

no service timestamps debug datetime msec

no service password-encryption

!

hostname Switch

!

!

!

spanning-tree mode pvst

!

interface FastEthernet0/1

!

………

interface FastEthernet0/4

……….

interface FastEthernet0/9

……

!

interface FastEthernet0/22

switchport access vlan 5

!

interface FastEthernet0/23

switchport access vlan 4

!

interface FastEthernet0/24

switchport mode trunk

 

 

路由器配置:

接口0/0命令清单

Router>enable

Router#conf t

Enter configuration commands, one per line. End withCNTL/Z.

Router(config)#interface fastEthernet 0/0

Router(config-if)#no ip address

Router(config-if)#exit

Router(config)#interface fastEthernet 0/0.2

Router(config-subif)#encapsulation dot1Q 2

Router(config-subif)#ip address 192.168.2.1 255.255.255.0

Router(config-subif)#exit

Router(config)#interface fastEthernet 0/0.3

Router(config-subif)#encapsulation dot1Q 3

Router(config-subif)#ip address 192.168.3.1 255.255.255.0

Router(config-subif)#exit

Router(config)#interface fastEthernet 0/0

Router(config-if)#noshutdown

 

接口0/1命令清单

Router(config)#interface fastEthernet 0/1

Router(config-if)#no ip address

Router(config-if)#exit

Router(config)#interface fastEthernet 0/1.4

Router(config-subif)#encapsulation dot1Q 4

Router(config-subif)#ip address 192.168.4.1255.255.255.0

Router(config-subif)#exit

Router(config)#interface fastEthernet 0/1.5

Router(config-subif)#encapsulation dot1Q 5

Router(config-subif)#ip address 192.168.5.1255.255.255.0

Router(config-subif)#exit

Router(config)#interfacefastEthernet 0/1

Router(config-if)#noshutdown

 

 

验证:

PC>ping 192.168.3.100

 

Pinging 192.168.3.100 with 32 bytes of data:

 

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

Reply from 192.168.3.100: bytes=32 time=13ms TTL=127

Reply from 192.168.3.100: bytes=32 time=14ms TTL=127

Reply from 192.168.3.100: bytes=32 time=13ms TTL=127

 

Ping statistics for 192.168.3.100:

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

Approximate round trip times in milli-seconds:

Minimum = 0ms, Maximum = 14ms, Average = 10ms

 

PC>ping 192.168.4.100

 

Pinging 192.168.4.100 with 32 bytes of data:

 

Request timed out.

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

Reply from 192.168.4.100: bytes=32 time=12ms TTL=127

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

 

Ping statistics for 192.168.4.100:

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

Approximate round trip times in milli-seconds:

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

 

PC>ping 192.168.5.100

 

Pinging 192.168.5.100 with 32 bytes of data:

 

Request timed out.

Reply from 192.168.5.100: bytes=32 time=13ms TTL=127

Reply from 192.168.5.100: bytes=32 time=13ms TTL=127

Reply from 192.168.5.100: bytes=32 time=14ms TTL=127

 

Ping statistics for 192.168.5.100:

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

Approximate round trip times in milli-seconds:

Minimum = 13ms, Maximum = 14ms, Average = 13ms

 

为各个配置IP时记得配上网关!

补充:所谓单臂路由就是指使用IEEE 802.1Q来启动一个路由器上的子接口成为干道模式,实现vlan间的通信

 

本实验到此成功。(交换机的配置下次上传)

你可能感兴趣的:(高级路由交换)