實驗設備:
三層交換機一台,主機若干台,直通線若干
實驗目的:
實現客戶機從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客戶端提供服務。