配置成功的显示:R1#conf t
Enter configuration commands, one per line. End with CNTL/Z.
R1(config)#in fa0/0
R1(config-if)#no ip add
R1(config-if)#no shut
R1(config-if)#exit
R1(config)#R1(config)#int fa0/0.1
R1(config-subif)#encap dot1q 10
R1(config-subif)#ip add 192.168.10.1 255.255.255.0
R1(config-subif)#no shut
R1(config-subif)#int fa0/0.2
R1(config-subif)#encap dot1q 20
R1(config-subif)#ip add 192.168.20.1 255.255.255.0
R1(config-subif)#no shu
R1(config-subif)#no shut
R1(config-subif)#exit
R1(config)#exit
R1#show ip int brief
Interface IP-Address OK? Method Status Protocol
FastEthernet0/0 unassigned YES manual up up
FastEthernet0/0.1 192.168.10.1 YES manual up up
FastEthernet0/0.2 192.168.20.1 YES manual up up
FastEthernet0/1 unassigned YES unset administratively down down
配置成功后,可以使用show ip dhcp pool指令来查询配置:R1(config)#ip dhcp pool vlan10
R1(dhcp-config)#network 192.168.10.0 255.255.255.0
R1(dhcp-config)#default-router 192.168.10.1
R1(dhcp-config)#dns-server 192.168.10.1
R1(dhcp-config)#domain-name test1.com
R1(dhcp-config)#exit
R1(config)#ip dhcp excluded-address 192.168.10.1 192.168.10.10
R1(config)#ip dhcp pool vlan20
R1(dhcp-config)#network 192.168.20.0 255.255.255.0
R1(dhcp-config)#default-router 192.168.20.1
R1(dhcp-config)#dns-server 192.168.20.1
R1(dhcp-config)#domain-name test2.com
R1(dhcp-config)#exit
R1(config)#exit
R1#
接着,对R3进行配置,划分出两个VLAN——VLAN 10和VLAN 20,分别对应上面的fa0/0.1和fa0/0.2,配置如下:R1#show ip dhcp pool
Pool vlan10 :
Utilization mark (high/low) : 100 / 0
Subnet size (first/next) : 0 / 0
Total addresses : 254
Leased addresses : 0
Pending event : none
1 subnet is currently in the pool :
Current index IP address range Leased addresses
192.168.10.1 192.168.10.1 - 192.168.10.254 0
Pool vlan20 :
Utilization mark (high/low) : 100 / 0
Subnet size (first/next) : 0 / 0
Total addresses : 254
Leased addresses : 0
Pending event : none
1 subnet is currently in the pool :
Current index IP address range Leased addresses
192.168.20.1 192.168.20.1 - 192.168.20.254 0
b.建立两个VLAN:R3#conf t
Enter configuration commands, one per line. End with CNTL/Z.
R3(config)#int fa1/0
R3(config-if)#switchport mode trunk
R3(config-if)#no shut
R3(config-if)#exit
R3(config)#exit
R3#
c.将C1、C2分别划入到不同的VLAN中:R3(vlan)#vlan 10
VLAN 10 added:
Name: VLAN0010
R3(vlan)#vlan 20
VLAN 20 added:
Name: VLAN0020
R3(vlan)#exit
最后,在VPCS中,分别测试,结果如图,IP成功自动分配:R3(config)#int fa1/1
R3(config-if)#shutdown
R3(config-if)#switchport mode access
R3(config-if)#no shut
R3(config-if)#switchport access vlan 10
R3(config-if)#exitR3(config)#int fa1/2
R3(config-if)#shutdown
R3(config-if)#switchport mode access
R3(config-if)#no shut
R3(config-if)#switchport access vlan 20
R3(config-if)#exit
评论