.(SWITCH 1.上的F0/1 F0/2 属于VLAN 2,SWITCH 2.上的F0/1 F0/2 属于VLAN 3)
![DHCP 服务的应用_休闲](https://s2.51cto.com/attachment/200808/200808271219813140140.jpg?x-oss-process=image/resize,m_fixed,w_1184)
switch(vlan)#vlan 2 name work02 (在SWITCH 2上时将此改为03)
switch(config)#int f0/2
switch(config-if)#switchport access vlan 2
Switch>Vlan Database
Switch(Vlan)>Vlan 2 Name server
Switch(Vlan)>Vlan 3 Name work03
Switch(vlan)>Vlan 4 Name work04
switch(config-if)#switchport access vlan 2
switch(config-if)#switchport access vlan 3
switch(config-if)#switchport access vlan 4
Switch(Config)>Int Vlan 2
Switch(Config-vlan)Ip Address 192.168.2.1 255.255.255.0
Switch(Config-vlan)No Shut
Switch(Config-vlan)>Int Vlan 3
Switch(Config-vlan)Ip Address 192.168.3.1 255.255.255.0
Switch(Config-vlan)No Shut
Switch(Config-vlan)>Int Vlan 4
Switch(Config-vlan)Ip Address 192.168.4.1 255.255.255.0
Switch(Config-vlan)No Shut
Switch(Config-vlan)Exit
/*注意:由于此时没有将端口分配置到VLAN2,3,4,所以各VLAN会DOWN掉,待将端口分配到各VLAN后,VLAN会起来*/
/*关键一步,若缺少以下两条命令,在VLAN中使用“IP HELPER-ADDRESS DHCP服务器地址”指定DHCP服务器,客户机仍然不能获得IP地址*/
Switch>Enable
Switch#Config t
Switch(Config)Service Dhcp
Switch(Config)Ip Dhcp Relay Information Option
/*VLAN 4中不须指定DHCP服务器地址*/
Switch(Config)Int Vlan 2
Switch(Config-vlan)Ip Helper-address 192.168.4.10
Switch(Config)Int Vlan 3
路由启用后,各VLAN间主机可互相访问
Switch(Config-vlan)End
Switch#Copy Run Start