Router 作爲 DHCP 服務器:
1、配置 Router 地址:
Route> enable
Router# configure terminal
Router(config)# no ip domain lookup //關閉域名查詢功能;
Router(config)# hostname GateWay //路由器命名爲GateWay;
GateWay(config)# interface gi0/1 //進入gi0/1端口;
GateWay(config-if)# no shutdown //開啓端口;
GateWay(config-if)# ip address 192.168.1.254 255.255.255.0 //端口配置IP地址;
2、配置 DHCP 地址池:
GateWay(config)# ip dhcp pool A //建立名爲A的DHCP地址池;
GateWay(dhcp-config)# network 192.168.1.0 255.255.255.0 //DHCP自動分配IP的範圍;
GateWay(dhcp-config)# default-router 192.168.1.254 //配置自動分配IP的網關;
GateWay(dhcp-config)# dns-server 8.8.8.8 //配置自動分配的DNS地址;
3、啓動 DHCP 服務 :
GateWay(config)# service dhcp
4、配置 DHCP 客戶端 :
點擊 - ”DHCP“ ;
5、驗證命令:
在服務器端的驗證命令:
GateWay# show ip dhcp binding
GateWay# show running-config
在客戶端的驗證:
運行--> cmd ---> ipconfig /all
6、特殊地址處理:
內網有業務服務器,編址如下:
web - 192.168.1.20 /24
email - 192.168.1.75 /24
FTP - 192.168.1.88 /24
OA - 192.168.1.166 /24
DHCP 地址排除命令:
GateWay(config)# ip dhcp excluded-address 192.168.1.1 192.168.1.10
(low地址) (high地址)
注意:
low 地址與 high 地址不同,則表示一段連續的IP;如果相同,則表示”排除一個地址“;
如果要執行這一步操作的時候,先排除地址,再在路由器上啓動DHCP服務。
=============================================================
Switch 作爲 DHCP 服務器:
1、配置交換機的IP地址:
(二層交換機上端口不可配置地址,所以我們地址配置在VLAN1上)
Switch> enable
Switch# configure termainal
Switch(config)# hostname SW1
SW1(config)# interface vlan 1 //進入VLAN1 的端口;
SW1(config-if)# no shutdown //開始端口;
SW1(config-if)# ip address 192.168.1.250 255.255.255.0 //爲端口配置IP地址;
2、配置 DHCP 地址池 :
SW1(config)# ip dhcp pool B //建立名爲B的DHCP地池;
SW1(dhcp-config)# network 192.168.1.0 255.255.255.0 //DHCP自動分配IP的範圍; SW1(dhcp-config)# default-router 192.168.1.1 //配置自動分配IP的網關;
SW1(dhcp-config)# dns-server 8.8.8.8 //配置自動分配的DNS地址;
3、啓動 DHCP 服務 :
SW1(config)# service dhcp
4、配置 DHCP 客戶端 ;
5、驗證:
SW1# show ip interface brief // 查看交換機接口IP地址配置;
SW1# show running-config //查看 DHCP 的相關配置命令;
SW1# show ip dhcp binding //查看DHCP服務器分配成功的IP地址;
=============================================================
服務器上配置DHCP: