1. 网络拓扑
2. R1配置
#在GE0/0/0口上创建子接口GE0/0/0.10:
[R1]interface GigabitEthernet0/0/0.10
[R1-GigabitEthernet0/0/0.10]dot1q termination vid 10 #该子接口对应VLAN10
[R1-GigabitEthernet0/0/0.10]arp broadcast enable
[R1-GigabitEthernet0/0/0.10]ip address 192.168.10.253 24
[R1-GigabitEthernet0/0/0.10]vrrp vrid 10 virtual-ip 192.168.10.254
[R1-GigabitEthernet0/0/0.10]vrrp vrid 10 priority 120
[R1-GigabitEthernet0/0/0.10]vrrp vrid 10 track interface Gi0/0/1 reduced 30
#在GE0/0/0口上创建子接口GE0/0/0.20:
[R1]interface GigabitEthernet0/0/0.20
[R1-GigabitEthernet0/0/0.20]dot1q termination vid 20
[R1-GigabitEthernet0/0/0.20]arp broadcast enable
[R1-GigabitEthernet0/0/0.20]ip address 192.168.20.253 24
[R1-GigabitEthernet0/0/0.20]vrrp vrid 20 virtual-ip 192.168.20.254
[R1]interface GigabitEthernet 0/0/1
[R1-GigabitEthernet0/0/1]ip address 10.1.1.1 30
[R1]ip route-static 0.0.0.0 0 10.1.1.2
3. R2配置
#在GE0/0/0口上创建子接口GE0/0/0.10:
[R2]interface GigabitEthernet0/0/0.10
[R2-GigabitEthernet0/0/0.10]dot1q termination vid 10
[R2-GigabitEthernet0/0/0.10]arp broadcast enable
[R2-GigabitEthernet0/0/0.10]ip address 192.168.10.252 24
[R2-GigabitEthernet0/0/0.10]vrrp vrid 10 virtual-ip 192.168.10.254
#在GE0/0/0口上创建子接口GE0/0/0.20:
[R2]interface GigabitEthernet0/0/0.20
[R2-GigabitEthernet0/0/0.20]dot1q termination vid 20
[R2-GigabitEthernet0/0/0.20]arp broadcast enable
[R2-GigabitEthernet0/0/0.20]ip address 192.168.20.252 24
[R2-GigabitEthernet0/0/0.20]vrrp vrid 20 virtual-ip 192.168.20.254
[R2-GigabitEthernet0/0/0.20]vrrp vrid 20 priority 120
[R2-GigabitEthernet0/0/0.20]vrrp vrid 20 track interface Gi0/0/1 reduced 30
[R2]interface GigabitEthernet 0/0/1
[R2-GigabitEthernet0/0/1]ip address 10.2.2.2 30
[R2]ip route-static 0.0.0.0 0 10.2.2.1
4. SW配置
[SW]vlan batch 10 20
[SW-GigabitEthernet0/0/1]port link-type access
[SW-GigabitEthernet0/0/1]port default vlan 10
[SW-GigabitEthernet0/0/2]port link-type access
[SW-GigabitEthernet0/0/2]port default vlan 20
[SW-GigabitEthernet0/0/23]port link-type trunk
[SW-GigabitEthernet0/0/23]port trunk allow-pass vlan 10 20
[SW-GigabitEthernet0/0/24]port link-type trunk
[SW-GigabitEthernet0/0/24]port trunk allow-pass vlan 10 20
5. Net1配置
[Net1-GigabitEthernet0/0/1]ip address 10.1.1.2 30
[Net1-GigabitEthernet0/0/2]ip address 10.2.2.1 30
[Net1]interface LoopBack 0
[Net1-LoopBack0]ip address 1.1.1.1 32
#为Net1添加去往192.168.10.0/24及192.168.20.0/24网段的静态路由:
[Net1]ip route-static 192.168.10.0 24 10.1.1.1
[Net1]ip route-static 192.168.10.0 24 10.2.2.2
[Net1]ip route-static 192.168.20.0 24 10.1.1.1
[Net1]ip route-static 192.168.20.0 24 10.2.2.2
6. 查看配置