拓扑图:
SW1、SW2:
en
conf t
vlan 10
name a
vlan 20
name b
int f0/1
switchport mode access
switchport access vlan 10
int f0/2
switchport mode access
switchport access vlan 20
int f0/3
switchport mode trunk
switchport trunk allowed vlan all
exit
SW0:
en
conf t
vlan 10
name a
vlan 20
name b
int range f0/1 - 3
switchport mode trunk
switchport trunk allowed vlan all
exit
R0:
en
conf t
int f0/0
no shut
int f0/0.10
encapsulation dot1Q 10
ip address 192.168.10.254 255.255.255.0
no shut
int f0/0.20
encapsulation dot1Q 20
ip address 192.168.20.254 255.255.255.0
no shut
exit
ip dhcp pool a-pool//定义IP地址池:a-pool
network 192.168.10.0 255.255.255.0//动态分配IP地址段
default-router 192.168.10.254//设定网关地址
dns-server 114.114.114.114//配置DNS地址
exit
//预留IP地址
ip dhcp excluded-address 192.168.10.1 192.168.10.10
ip dhcp excluded-address 192.168.10.254
ip dhcp pool b-pool
network 192.168.20.0 255.255.255.0
default-router 192.168.20.254
dns-server 8.8.8.8
exit
ip dhcp excluded-address 192.168.20.1 192.168.20.10
ip dhcp excluded-address 192.168.20.254
PC0、PC1、PC2、PC3:
IP Configuration选择:DHCP
相互之间均能ping通!
R0:
int f0/1
ip address 202.100.10.1 255.255.255.0
no shut
ip route 0.0.0.0 0.0.0.0 202.100.10.2
R1:
en
conf t
int f0/0
ip address 202.100.10.2 255.255.255.0
no shut
int f0/1
ip address 202.100.20.1 255.255.255.0
no shut
exit
ip route 192.168.10.0 255.255.255.0 202.100.10.1
ip route 192.168.20.0 255.255.255.0 202.100.10.1
PC4:
IP:202.100.20.2
Gateway:202.100.20.1
PC4 ping PC0、PC1、PC2、PC3 通!
PC0、PC1、PC2、PC3 ping PC4 通!