单臂路由的跨VLAN流量转发
R1只通过物理接口连接SW1,在逻辑上通过两个子接口.10和.20来连接SW1
[R1]interface GigabitEthernet 0/0/0.10
[R1-GigabitEthernet0/0/0.10]dot1q termination vid 10 #配置802.1Q封装并且指定端口PVID
[R1-GigabitEthernet0/0/0.10]ip address 192.168.0.254 24
[R1-GigabitEthernet0/0/0.10]undo shutdown
Info: Interface GigabitEthernet0/0/0.10 is not shutdown.
[R1-GigabitEthernet0/0/0.10]arp broadcast enable #启用子接口ARP广播
[R1-GigabitEthernet0/0/0.10]quit
[R1]interface GigabitEthernet 0/0/0.20
[R1-GigabitEthernet0/0/0.20]dot1q termination vid 20
[R1-GigabitEthernet0/0/0.20]ip address 172.16.0.254 24
[R1-GigabitEthernet0/0/0.20]undo shutdown
Info: Interface GigabitEthernet0/0/0.20 is not shutdown.
[R1-GigabitEthernet0/0/0.20]arp broadcast enable
[R1-GigabitEthernet0/0/0.20]quit
SW1 配置
[SW1]vlan batch 10 20 #创建两个VLAN
Info: This operation may take a few seconds. Please wait for a moment...done.
[SW1]interface Ethernet 0/0/1
[SW1-Ethernet0/0/1]port link-type trunk #使这个端口可以承载不同VLAN的流量
[SW1-Ethernet0/0/1]port trunk allow-pass vlan 10 20 #放行VLAN10、20的流量
[SW1-Ethernet0/0/1]quit
[SW1]interface Ethernet 0/0/3
[SW1-Ethernet0/0/3]port link-type access
[SW1-Ethernet0/0/3]port default vlan 10
[SW1-Ethernet0/0/3]quit
[SW1]interface Ethernet 0/0/4
[SW1-Ethernet0/0/4]port link-type access
[SW1-Ethernet0/0/4]port default vlan 20
[SW1-Ethernet0/0/4]quit
VLAN10、20都包括接口G0/0/0,接口打上VLAN标签TG允许VLAN10、20的流量通过
小结
这种配置方式可以节省物理接口数量。