单臂路由实现vlan间相互通信
概述
单臂路由是指路由器的一个网络端口上通过配置子接口(或者逻辑接口,即不存在真的物理子接口)的方式,实现相互隔离的不同VLAN之间的互联互通。单臂路由的结构。
配置子接口时,需要注意以下几点:
1、必须围殴每个子接口分配一个IP地址。该IP地址与子接口所属VLAN位于同一网段中;
2、需要在子接口上配置802.1Q封装,用于剥除和添加VLAN Tag,从而实现VLAN间相互通信;
3、在子接口上执行arpbroadcast enable启用子接口的ARP广播功能。
实验拓扑
实验思路
Ⅰ配置终端设备的IP地址、子网掩码、网关地址;
Ⅱ配置交换机,创建VLAN,并添加进相应的端口中,配置Access端口,配置Trunk端口;
Ⅲ配置路由器,配置子接口参数,子接口的IP地址对应的就是VLAN 的网关地址;
切记要开启子接口的ARP广播功能。
实验操作
配置计算机、服务器IP参数
配置交换机S1
(1)创建VLAN,并添加端口。命令如下。
[S1]vlan batch 10 20 Info: This operation may take a few seconds. Please wait for a moment...done. [S1]interface Ethernet0/0/1 [S1-Ethernet0/0/1]port link-type access [S1-Ethernet0/0/1]port default vlan 10 [S1-Ethernet0/0/1]quit [S1]int [S1]interface Ethernet0/0/2 [S1-Ethernet0/0/2]port link-type access [S1-Ethernet0/0/2]port default vlan 20 [S1-Ethernet0/0/2]quit [S1]
(2)配置交换机S1的Trunk端口,命令如下。
[S1]interface GigabitEthernet 0/0/1 [S1-GigabitEthernet0/0/1]port link-type trunk [S1-GigabitEthernet0/0/1]port trunk allow-pass vlan 10 20 [S1-GigabitEthernet0/0/1]display this # interface GigabitEthernet0/0/1 port link-type trunk port trunk allow-pass vlan 10 20 # return [S1-GigabitEthernet0/0/1]quit [S1]
交换机S1配置完成后,先测试一下PC1与Server1之间是否能正常通信,测试结果不能。
配置路由器R1
配置子接口
①配置子接口参数
[R1]interface GigabitEthernet 0/0/1.10 //进入子接口配置视图.10 [R1-GigabitEthernet0/0/1.10]ip address 192.168.1.254 24 //配置子接口IP地址,此接口为对应VLAN 网关地址 [R1-GigabitEthernet0/0/1.10]dot1q termination vid 10 //配置802.1Q封装,对应VLAN 为VLAN 10 Jul 10 2020 23:22:31-08:00 R1 %%01IFNET/4/LINK_STATE(l)[0]:The line protocol IP on the interface GigabitEthernet0/0/1.10 has entered the UP state. [R1-GigabitEthernet0/0/1.10]arp broadcast enable //开启子接口的ARP广播功能!!! [R1-GigabitEthernet0/0/1.10]display this [V200R003C00] # interface GigabitEthernet0/0/1.10 dot1q termination vid 10 ip address 192.168.1.254 255.255.255.0 arp broadcast enable # return [R1-GigabitEthernet0/0/1.10]quit [R1]int [R1]interface GigabitEthernet 0/0/1.20 //进入子接口配置视图.20 [R1-GigabitEthernet0/0/1.20]ip address 192.168.2.254 24 [R1-GigabitEthernet0/0/1.20]dot1q termination vid 20 //配置802.1Q封装,对应VLAN 为VLAN 20 Jul 10 2020 23:23:26-08:00 R1 %%01IFNET/4/LINK_STATE(l)[1]:The line protocol IP on the interface GigabitEthernet0/0/1.20 has entered the UP state. [R1-GigabitEthernet0/0/1.20]arp broadcast enable //开启子接口的ARP广播功能!!! [R1-GigabitEthernet0/0/1.20]display this [V200R003C00] # interface GigabitEthernet0/0/1.20 dot1q termination vid 20 ip address 192.168.2.254 255.255.255.0 arp broadcast enable # return [R1-GigabitEthernet0/0/1.20]quit [R1]
补充说明
1、配置802.1Q封装的作用时是在接收VLAN 数据时将剥掉的VLAN 标签进行三层转发,在发送数据时,将会把与该子接口对应的VLAN 标签添加到 VLAN 数据中。
2、开启子接口的ARP广播功能后,子接口才能主动发送ARP广播报文,以及向外转发IP报文。
②查看子接口配置信息,命令如下。
[R1]display ip interface brief *down: administratively down ^down: standby (l): loopback (s): spoofing The number of interface that is UP in Physical is 4 The number of interface that is DOWN in Physical is 2 The number of interface that is UP in Protocol is 3 The number of interface that is DOWN in Protocol is 3 Interface IP Address/Mask Physical Protocol GigabitEthernet0/0/0 unassigned down down GigabitEthernet0/0/1 unassigned up down GigabitEthernet0/0/1.10 192.168.1.254/24 up up GigabitEthernet0/0/1.20 192.168.2.254/24 up up GigabitEthernet0/0/2 unassigned down down NULL0 unassigned up up(s) [R1]
③查看路由表信息,命令如下。
[R1]display ip routing-table Route Flags: R - relay, D - download to fib ------------------------------------------------------------------------------ Routing Tables: Public Destinations : 10 Routes : 10 Destination/Mask Proto Pre Cost Flags NextHop Interface 127.0.0.0/8 Direct 0 0 D 127.0.0.1 InLoopBack0 127.0.0.1/32 Direct 0 0 D 127.0.0.1 InLoopBack0 127.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0 192.168.1.0/24 Direct 0 0 D 192.168.1.254 GigabitEthernet 0/0/1.10 192.168.1.254/32 Direct 0 0 D 127.0.0.1 GigabitEthernet 0/0/1.10 192.168.1.255/32 Direct 0 0 D 127.0.0.1 GigabitEthernet 0/0/1.10 192.168.2.0/24 Direct 0 0 D 192.168.2.254 GigabitEthernet 0/0/1.20 192.168.2.254/32 Direct 0 0 D 127.0.0.1 GigabitEthernet 0/0/1.20 192.168.2.255/32 Direct 0 0 D 127.0.0.1 GigabitEthernet 0/0/1.20 255.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0
测试
在PC1上利用ping命令测试与Server1的通信情况
至此,实验结束~