首页 > 代码库 > DHCP的搭建

DHCP的搭建

系统 环境:

[root@RHCE ~]# cat /etc/redhat-release 

CentOS Linux release 7.2.1511 (Core) 

[root@RHCE ~]# uname -r 

3.10.0-327.el7.x86_64

[root@RHCE ~]# ip addr show enp0s8 | awk ‘NR==3{print $2}‘ 

192.168.235.36/24

[root@RHCE ~]# yum install -y dhcp

[root@RHCE ~]# cp -a /usr/share/doc/dhcp-4.2.5/dhcpd.conf.example /etc/dhcp/dhcpd.conf


[root@RHCE ~]# cat /etc/dhcp/dhcpd.conf 

subnet 192.168.235.0 netmask 255.255.255.0 {

  range 192.168.235.10 192.168.235.20;

 default-lease-time 600;

 max-lease-time 7200;

}


#可以看到我们的配置非常少,此处主要演示是 安装服务 更多配置在  man 5 dhcpd.conf


[root@RHCE ~]#  systemctl start dhcpd

[root@RHCE ~]# setenforce 0

[root@RHCE ~]# systemctl stop firewalld


另开启一台虚拟机windows server 2003  与 DHCP服务器在同一个VM里面


技术分享

可以看到 windows server 2003 可以获取到 IP地址


[root@RHCE ~]# cat /var/lib/dhcpd/dhcpd.leases 

# The format of this file is documented in the dhcpd.leases(5) manual page.

# This lease file was written by isc-dhcp-4.2.5


server-duid "\000\001\000\001 k\264U\010\000‘x\377\204";


lease 192.168.235.10 {

  starts 1 2017/03/27 11:32:21;

  ends 1 2017/03/27 11:42:21;

  cltt 1 2017/03/27 11:32:21;

  binding state active;

  next binding state free;

  rewind binding state free;

  hardware ethernet 08:00:27:2a:05:ad;                #客户机的MAC地址

  uid "\001\010\000‘*\005\255"; 

  client-hostname "cqwu-8b3601776c";

}

技术分享

本文出自 “梦1场ー〉╯” 博客,请务必保留此出处http://cqwujiang.blog.51cto.com/10808946/1910894

DHCP的搭建