三种不同的方式实现VLAN间路由-实验案例
VLAN路由-每个VLAN一个物理接口
在二层交换机上配置VLAN,路由器为每一个VLAN分配一个物理接口。
设备规划表
SWA配置
[SWA]vlan batch 2 3
[SWA]interface GigabitEthernet0/0/1
[SWA-GigabitEthernet0/0/1]port link-type access
[SWA-GigabitEthernet0/0/1]port default vlan 2
[SWA-GigabitEthernet0/0/1]interface GigabitEthernet0/0/2
[SWA-GigabitEthernet0/0/2]port link-type access
[SWA-GigabitEthernet0/0/2]port default vlan 3
[SWA-GigabitEthernet0/0/2]interface GigabitEthernet0/0/3
[SWA-GigabitEthernet0/0/3]port link-type access
[SWA-GigabitEthernet0/0/3]port default vlan 2
[SWA-GigabitEthernet0/0/3]interface GigabitEthernet0/0/4
[SWA-GigabitEthernet0/0/4]port link-type access
[SWA-GigabitEthernet0/0/4]port default vlan 3
PTA配置
[RTA]interface GigabitEthernet0/0/1
[RTA-GigabitEthernet0/0/1]ip address 192.168.2.254 24
[RTA]interface GigabitEthernet0/0/2
[RTA-GigabitEthernet0/0/2]ip address 192.168.3.254 24
验证
主机A与主机B之间可以互ping通
VLAN路由-单臂路由
将交换机和路由器之间的链路配置为Trunk链路,并且在路由器上创建子接口以支持VLAN路由。
设备规划表
SWA配置
[SWA]vlan batch 2 3
[SWA]interface GigabitEthernet0/0/1
[SWA-GigabitEthernet0/0/1]port link-type trunk
[SWA-GigabitEthernet0/0/1]port trunk allow-pass vlan 2 3
[SWA-GigabitEthernet0/0/1]interface GigabitEthernet0/0/2
[SWA-GigabitEthernet0/0/2]port link-type access
[SWA-GigabitEthernet0/0/2]port default vlan 2
[SWA-GigabitEthernet0/0/2]interface GigabitEthernet0/0/3
[SWA-GigabitEthernet0/0/3]port link-type access
[SWA-GigabitEthernet0/0/3]port default vlan 3
PTA配置
[RTA]interface GigabitEthernet0/0/1.2
[RTA-GigabitEthernet0/0/1.2]dot1q termination vid 2
[RTA-GigabitEthernet0/0/1.2]ip address 192.168.2.254 24
[RTA-GigabitEthernet0/0/1.2]arp broadcast enable
[RTA]interface GigabitEthernet0/0/1.3
[RTA-GigabitEthernet0/0/1.3]dot1q termination vid 3
[RTA-GigabitEthernet0/0/1.3]ip address 192.168.3.254 24
[RTA-GigabitEthernet0/0/1.3]arp broadcast enable
验证
主机A与主机B之间可以互ping通
VLAN路由-三层交换
在三层交换机为每个VLAN创建一个VLANIF接口作为网关。
设备规划表
SWA配置
[SWA]vlan batch 2 3
[SWA]interface GigabitEthernet0/0/1
[SWA-GigabitEthernet0/0/1]port link-type access
[SWA-GigabitEthernet0/0/1]port default vlan 2
[SWA-GigabitEthernet0/0/1]interface GigabitEthernet0/0/2
[SWA-GigabitEthernet0/0/2]port link-type access
[SWA-GigabitEthernet0/0/2]port default vlan 3
[SWA]interface vlanif 2
[SWA-Vlanif2]ip address 192.168.2.254 24
[SWA-Vlanif2]quit
[SWA]interface vlanif 3
[SWA-Vlanif3]ip address 192.168.3.254 24
[SWA-Vlanif3]quit
验证
主机A与主机B之间可以互ping通