使用路由器实现多个VLAN之间的互相通信,将路由器接口配置为各电脑终端的网关IP。
路由器R1的配置
<Huawei>system-view
[Huawei]sysname R1
[R1]interface GigabitEthernet 0/0/0
[R1-GigabitEthernet0/0/1]ip address 192.168.10.254 24
[R1-GigabitEthernet0/0/1]q
[R1]interface GigabitEthernet 0/0/1
[R1-GigabitEthernet0/0/1]ip address 192.168.20.254 24
[R1-GigabitEthernet0/0/1]q
[R1]display ip interface brief
交换机SW1的配置
[sw1]vlan batch 10 20
[sw1]interface GigabitEthernet 0/0/1
[sw1-GigabitEthernet0/0/11]port link-type access
[sw1-GigabitEthernet0/0/11]port default vlan 10
[sw1]interface GigabitEthernet 0/0/2
[sw1-GigabitEthernet0/0/11]port link-type access
[sw1-GigabitEthernet0/0/11]port default vlan 10
[sw1]interface GigabitEthernet 0/0/10
[sw1-GigabitEthernet0/0/11]port link-type access
[sw1-GigabitEthernet0/0/11]port default vlan 20
[sw1]interface GigabitEthernet 0/0/11
[sw1-GigabitEthernet0/0/11]port link-type access
[sw1-GigabitEthernet0/0/11]port default vlan 20
[sw1]interface GigabitEthernet 0/0/23
[sw1-GigabitEthernet0/0/23]port link-type access ;注意这时可以不用Trunk
[sw1-GigabitEthernet0/0/23]port default vlan 10
[sw1-GigabitEthernet0/0/23]q
[sw1]interface GigabitEthernet 0/0/24
[sw1-GigabitEthernet0/0/23]port link-type access
[sw1-GigabitEthernet0/0/24]port default vlan 20
[sw1-GigabitEthernet0/0/24]
这样配置完成后,VLAN10与VLAN20电脑之间就能通了。
PC1通过交换机G0/0/1口,经过G0/0/23口到达路由器G0/0/0;
经过路由器转发,经过G0/0/1到达交换机G0/0/24口,再转发到G0/0/10口,到达PC5;
这样有几个VLAN,那么路由器就需要几个接口,几条线路,那么路由器成本太高,因些单臂路由就出现了。