实验设备:
三层交换机一台,主机若干台,直通线若干
实验目的:
实现客户机从DHCP(动态主机配置协议)服务器上获取动态IP地址。
实验步骤:
1、划分VLAN
Switch>enable Switch#config Configuring from terminal, memory, or network [terminal]? Enter configuration commands, one per line. End with CNTL/Z. Switch(config)#vlan 100 Switch(config-vlan)#exit Switch(config)#vlan 200 Switch(config-vlan)#exit
2、分配端口
Switch(config-if)#interface range fastEthernet 0/1-10 Switch(config-if-range)#Switchport access vlan 100 Switch(config-if-range)#interface range fastEthernet 0/11-20 Switch(config-if-range)#Switchport access vlan 200 Switch(config-if-range)#exit
3、给VLAN设置IP
Switch(config)#interface vlan 100 %LINK-5-CHANGED: Interface Vlan100, changed state to up %LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan100, changed state to up Switch(config-if)#ip address 192.168.100.1 255.255.255.0 Switch(config-if)#no shutdown Switch(config-if)#interface vlan 200 %LINK-5-CHANGED: Interface Vlan200, changed state to up %LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan200, changed state to up Switch(config-if)#ip address 192.168.200.1 255.255.255.0 Switch(config-if)#no shutdown
查看配置结果(ctrl+c快速回到特权模式下)
Switch(config-if)#^Z Switch# %SYS-5-CONFIG_I: Configured from console by console Switch#show running-config
4、配置DHCP地址池
(1)给VLAN100配置
Switch# config Configuring from terminal, memory, or network [terminal]? Enter configuration commands, one per line. End with CNTL/Z. Switch(config)#ip dhcp pool test1
(2)给VLAN200配置
Switch#config Configuring from terminal, memory, or network [terminal]? Enter configuration commands, one per line. End with CNTL/Z. Switch(config)#ip dhcp pool test2
5、设置网段、网关、域名DNS
(1)给VLAN100配置
Switch(dhcp-config)#network 192.168.100.0 255.255.255.0 Switch(dhcp-config)#default-router 192.168.100.1 Switch(dhcp-config)#dns-server 211.84.144.68 Switch(dhcp-config)#
(2)给VLAN200配置
Switch(dhcp-config)#network 192.168.200.0 255.255.255.0 Switch(dhcp-config)#default-router 192.168.200.1 Switch(dhcp-config)#dns-ser Switch(dhcp-config)#dns-server 211.84.144.68 Switch(dhcp-config)#
6、动态获取IP
单击主机→桌面→IP配置→选动态获取(DHCP)
实验结果:
若一切配置全部完成好,则就可以进行IP的动态获取
补充:
DHCP是动态主机设置协议,是一个局域网的网络协议,使用UDP协议工作。
主要有两个用途:
(1)用于内部网或网络服务供应商自动分配IP地址;
(2)给用户用于内部网管理员作为对所有计算机作中央管理的手段。
DHCP具有以下功能:
1、保证任何IP地址在同一时刻只能由一台DHCP客户机所使用。
2、DHCP应当可以给用户分配永久固定的IP地址。
3、DHCP应当可以同用其他方法获得IP地址的主机共存(如手工配置IP地址的主机)。
4、DHCP服务器应当向现有的BOOTP客户端提供服务。