1. 网络拓扑
2. SW配置
[SW] vlan batch 10 20
[SW] interface gigabitEthernet 0/0/1
[SW-gigabitEthernet0/0/1] port link-type access
[SW-gigabitEthernet0/0/1] port default vlan 10
[SW] interface gigabitEthernet 0/0/2
[SW-gigabitEthernet0/0/2] port link-type access
[SW-gigabitEthernet0/0/2] port default vlan 20
配置vlanif10及vlanif20:
[SW] interface Vlanif 10
[SW-vlanif10] ip address 192.168.10.254 24
[SW] interface Vlanif 20
[SW-vlanif20] ip address 192.168.20.254 24
[SW] vlan 200
[SW] interface vlanif 200
[SW-vlanif200] ip address 192.168.200.1 24
将连接路由器的接口加入VLAN200
[SW-gigabitEthernet0/0/24] port link-type access
[SW-gigabitEthernet0/0/24] port default vlan 200
[SW] ip route-static 0.0.0.0 0.0.0.0 192.168.200.2
3. Router配置
[Router-GigabitEthernet0/0/0] ip address 192.168.200.2 24
在路由器上创建环回接口Loopback0:
[Router] interface loopback 0
[Router-loopback0] ip address 8.8.8.8 24
[Router] ip route-static 192.168.10.0 24 192.168.200.1
[Router] ip route-static 192.168.20.0 24 192.168.200.1
4. 查看配置