首页 > 代码库 > DHCP的安装

DHCP的安装

DHCP简介

    DHCP是动态主机配置协议(Dynamic Host Configuration Protocol)的简称,是一种简化计算机IP地址分配管理的TCP/IP标准协议。网络管理员可以利用DHCP服务器动态分配IP地址及其相关的环境配置。

DHCP的工作过程

    DHCP客户使用两种不同的过程来与DHCP服务器通信并获得TCP/IP配置。当客户机首次启动并尝试加入网络时,执行的事初始化过程,而在客户机拥有IP租用之后将执行刷新过程。

DHCP的安装

安装DHCP

 #mkdir /mnt/cdrom

 #mount /dev/cdrom /mnt/cdrom/

mount: /dev/sr0 is write-protected,mounting read-only

 # cd/mnt/cdrom/Packages/

 # lsdhcp*

dhcp-4.2.5-27.el7.centos.x86_64.rpm

dhcp-common-4.2.5-27.el7.centos.x86_64.rpm

dhcp-libs-4.2.5-27.el7.centos.x86_64.rpm

 #rpm -Uvh dhcp-4.2.5-27.el7.centos.x86_64.rpm

warning:dhcp-4.2.5-27.el7.centos.x86_64.rpm: Header V3 RSA/SHA256 Signature, key IDf4a80eb5: NOKEY

Preparing...                          #################################[100%]

Updating / installing...

  1:dhcp-12:4.2.5-27.el7.centos     ################################# [100%]

 #rpm -qc dhcp

/etc/dhcp/dhcpd.conf

/etc/dhcp/dhcpd6.conf

/etc/openldap/schema/dhcp.schema

/etc/sysconfig/dhcpd

/var/lib/dhcpd/dhcpd.leases

/var/lib/dhcpd/dhcpd6.leases

 # cd/etc/dhcp/

 # cpdhcpd.conf dhcpd.conf.origin

 #cat /etc/dhcp/dhcpd.conf

         #

         #DHCP Server Configuration file.

         #   see /usr/share/doc/dhcp*/dhcpd.conf.example

         #   see dhcpd.conf(5) man page

         #

编辑dhcpd.conf

在最后添加如下信息

 # vi/etc/dhcp/dhcpd.conf

option domain-name"bigcloud.local";

option domain-name-servers 192.168.188.11,192.168.188.12;

 

#VLAN1

option routers 192.168.188.2 subnet192.168.188.0 network 255.255.255.0 {

        range 192.168.188.100 192.168.188.159;

       range 192.168.188.170 192.168.188.253;

       default-lease-time 259200;

       max-lease-time 259200;

}

 

#VLAN2

option routes 192.168.188.2 subnet192.168.189.0 network 255.255.255.0 {

       range 192.168.189.100 192.168.189.253;

       default-lease-time 691200;

       max-lease-time 691200;

}

 

host printer {

       hardware ethernet 00:12:34:56:78:90;

       fixed-address 192.168.188.111;

}

配置DHCPD为自动启动

 

 #chkconfig dhcpd on

Note: Forwarding request to ‘systemctlenable dhcpd.service‘.

 #systemctl enable dhcpd

测试

我们可以找一台物理机进行测试,看是否能分到ip

我们可以使用ipconfig /release释放ip

在使用ipconfig /renew 重新获取ip

我们就可以看到

以太网适配器本地连接:

   连接特定的DNS后缀............bigcloud.local

   本地连接IPv6地址.............fe80:bc6f:8cb2:2c8a:ee10%11

  IPv4地址.....................192.168.188.100

   子网掩码.....................255.255.255.0

   默认网关.....................192.168.188.2


DHCP的安装