网络拓扑:
PC地址:
PC0:192.168.10.2 255.255.255.0
PC1:192.168.20.2 255.255.255.0
PC2:172.16.10.2 255.255.255.0
PC3:172.16.20.2 255.255.255.0
sw0:
Switch>en
Switch#conf t
Switch(config)#hostname sw0
sw0(config)#exit
sw0#vlan database
sw0(vlan)#vlan 10
VLAN 10 added:
Name: VLAN0010
sw0(vlan)#vlan 20
VLAN 20 added:
Name: VLAN0020
sw0(vlan)#exit
sw0#conf t
sw0(config)#int f0/1
sw0(config-if)#switchport access vlan 10
sw0(config-if)#no shutdown
sw0(config-if)#exit
sw0(config)#int f0/9
sw0(config-if)#switchport access vlan 20
sw0(config-if)#no shutdown
sw0(config-if)#exit
sw0(config)#int f0/24
sw0(config-if)#switchport mode trunk
sw0(config-if)#no shutdown
sw0(config-if)#exit
sw1同上:
核心交换机msw0:
Switch>en
Switch#conf t
Switch(config)#hostname msw0
msw0(config)#exit
msw0#vlan database
msw0(vlan)#vlan 10
VLAN 10 added:
Name: VLAN0010
msw0(vlan)#vlan 20
VLAN 20 added:
Name: VLAN0020
msw0(vlan)#exit
msw0#conf t
msw0(config)#int vlan 10
msw0(config-if)#ip add 192.168.10.1 255.255.255.0
msw0(config-if)#exit
msw0(config)#int vlan 20
msw0(config-if)#ip add 192.168.20.1 255.255.255.0
msw0(config-if)#no shutdown
msw0(config-if)#exit
msw0(config)#int g1/0/1
msw0(config-if)#no switchport
msw0(config-if)#ip add 192.168.1.2 255.255.255.0
msw0(config-if)#no shutdown
msw0(config-if)#exit
msw0(config)#ip routing
msw0(config)#exit
msw0#wr
msw0#conf t
msw0(config)#ip route 0.0.0.0 0.0.0.0 192.168.1.1
msw0(config)#exit
注意!
核心交换机msw1同上
测试PC0可以ping通PC1.
路由器配置:
Router>en
Router#conf t
Router(config)#int f0/0
Router(config-if)#no shutdown
Router(config-if)#ip add 192.168.1.1 255.255.255.0
Router(config-if)#exit
Router(config)#int f0/1
Router(config-if)#no shutdown
Router(config-if)#ip add 172.16.1.1 255.255.255.0
Router(config-if)#exit
Router(config)#ip route 192.168.10.0 255.255.255.0 192.168.1.2
Router(config)#ip route 192.168.20.0 255.255.255.0 192.168.1.2
Router(config)#ip route 172.16.10.0 255.255.255.0 172.16.1.2
Router(config)#ip route 172.16.20.0 255.255.255.0 172.16.1.2
Router(config)#exit
Router#wr
测试PC0可以ping通PC2,没有配置静态路由则ping不通