配置DHCP为四个部门动态分配IP地址
SW1(config)#vlan range 10,20,30,40,100
SW1(config-vlan-range)#exit
SW1(config)#interface vlan 10
SW1(config-if-VLAN 10)#ip address 192.168.10.254 255.255.255.0
SW1(config)#interface vlan 20
SW1(config-if-VLAN 20)#ip address 192.168.20.254 255.255.255.0
SW1(config)#interface vlan 30
SW1(config-if-VLAN 30)#ip address 192.168.30.254 255.255.255.0
SW1(config)#interface vlan 40
SW1(config-if-VLAN 40)#ip address 192.168.40.254 255.255.255.0
SW1(config)#interface vlan 100
SW1(config-if-VLAN 10)#ip address 192.168.100.254 255.255.255.0SW1(config)#interface gigabitEthernet 0/1
SW1(config-if-GigabitEthernet 0/1)#switchport mode trunk?
SW1(config-if-GigabitEthernet 0/1)#switchport trunk allowed vlan remove 1-4094
SW1(config-if-GigabitEthernet 0/1)#switchport trunk allowed vlan add 10,20,100SW1(config)#interface gigabitEthernet 0/2
SW1(config-if-GigabitEthernet 0/2)#switchport mode trunk?
SW1(config-if-GigabitEthernet 0/2)#switchport trunk allowed vlan remove 1-4094
SW1(config-if-GigabitEthernet 0/2)#switchport trunk allowed vlan add 30,40,100
?
SW2(config)#vlan range 10,20,100
SW2(config-vlan-range)#exit
SW2(config)#interface vlan 100
SW2(config-if-VLAN 100)#ip address 192.168.100.1 255.255.255.0SW2(config)#interface gigabitEthernet 0/1
SW2(config-if-GigabitEthernet 0/1)#switchport mode trunk?
SW2(config-if-GigabitEthernet 0/1)#switchport trunk allowed vlan remove 1-4094
SW2(config-if-GigabitEthernet 0/1)#switchport trunk allowed vlan add 10,20,100SW2(config)#interface gigabitEthernet 0/2?
SW2(config-if-GigabitEthernet 0/2)#switchport mode access?
SW2(config-if-GigabitEthernet 0/2)#switchport access vlan 10
SW2(config)#interface gigabitEthernet 0/3?
SW2(config-if-GigabitEthernet 0/3)#switchport mode access?
SW2(config-if-GigabitEthernet 0/3)#switchport access vlan 20
SW3(config)#vlan range 10,20,100
SW3(config-vlan-range)#exit
SW3(config)#interface vlan 100
SW3(config-if-VLAN 100)#ip address 192.168.100.2 255.255.255.0SW3(config)#interface gigabitEthernet 0/1
SW3(config-if-GigabitEthernet 0/1)#switchport mode trunk?
SW3(config-if-GigabitEthernet 0/1)#switchport trunk allowed vlan remove 1-4094
SW3(config-if-GigabitEthernet 0/1)#switchport trunk allowed vlan add 30,40,100
SW3(config)#interface gigabitEthernet 0/2?
SW3(config-if-GigabitEthernet 0/2)#switchport mode access?
SW3(config-if-GigabitEthernet 0/2)#switchport access vlan 30
SW3(config)#interface gigabitEthernet 0/3
SW3(config-if-GigabitEthernet 0/3)#switchport mode access?
SW3(config-if-GigabitEthernet 0/3)#switchport access vlan 40
service dhcp
SW1(config)#ip dhcp pool vlan10
SW1(dhcp-config)#network 192.168.10.0 255.255.255.0
SW1(dhcp-config)#default-router 192.168.10.254SW1(config)#ip dhcp pool vlan20
SW1(dhcp-config)#network 192.168.20.0 255.255.255.0
SW1(dhcp-config)#default-router 192.168.20.254
SW1(config)#ip dhcp pool vlan30
SW1(dhcp-config)#network 192.168.30.0 255.255.255.0
SW1(dhcp-config)#default-router 192.168.30.254SW1(config)#ip dhcp pool vlan40
SW1(dhcp-config)#network 192.168.40.0 255.255.255.0
SW1(dhcp-config)#default-router 192.168.40.254
service dhcp
service dhcp