1.安装centos 6.0 dhcp 服务

 [root@localhost ~]#   yum install dhcp -y Centos6,安装的时候出现,Transaction Check Error:  file /usr/share/man/man5/dhcp-eval.5.gz from install of dhcp-common-12:4.1.1-43.P1.el6.centos.i686 conflicts with file from package dhclient-12:4.1.1-12.P1.el6.i686  file /usr/share/man/man5/dhcp-options.5.gz from install of dhcp-common-12:4.1.1-43.P1.el6.centos.i686 conflicts with file from package dhclient-12:4.1.1-12.P1.el6.i686Error Summary

发现dhclient有冲突,yum remove dhclient,连带的NetworkManager也卸载了。

 [root@localhost ~]#   yum install dhcp -y  成功安装[root@localhost ~]# cp /usr/share/doc/dhcp-4.1.1/dhcpd.conf.sample /etc/dhcp/dhcpd.conf

[root@localhost ~]# /etc/init.d/dhcpd restart

正在启动 dhcpd:                                           [失败]

[root@localhost ~]# tail -l /var/log/messagesFeb  2 21:09:23 localhost dhcpd:Feb  2 21:09:23 localhost dhcpd: This version of ISC DHCP is based on the release availableFeb  2 21:09:23 localhost dhcpd: on ftp.isc.org.  Features have been added and other changesFeb  2 21:09:23 localhost dhcpd: have been made to the base software release in order to makeFeb  2 21:09:23 localhost dhcpd: it work better with this distribution.Feb  2 21:09:23 localhost dhcpd:Feb  2 21:09:23 localhost dhcpd: Please report for this software via the CentOS Bugs Database:Feb  2 21:09:23 localhost dhcpd:     http://bugs.centos.org/Feb  2 21:09:23 localhost dhcpd:Feb  2 21:09:23 localhost dhcpd: exiting.

以上没有日志找不出什么问题,然后调试命令看看哪里报错了!

[root@localhost ~]#  /usr/sbin/dhcpd restart   #调试命令Internet Systems Consortium DHCP Server 4.1.1-P1Copyright 2004-2010 Internet Systems Consortium.All rights reserved.For info, please visit https://www.isc.org/software/dhcp//etc/dhcp/dhcpd.conf line 114: 192.168.20.10 (262): expecting IP address or hostname  next-server "192.168.20.10"               ^/etc/dhcp/dhcpd.conf line 114: expecting a parameter or declaration  next-server "192.168.20.10";                             ^/etc/dhcp/dhcpd.conf line 115: unexpected end of file^Configuration file errors encountered -- exitingThis version of ISC DHCP is based on the release availableon ftp.isc.org.  Features have been added and other changeshave been made to the base software release in order to makeit work better with this distribution.Please report for this software via the CentOS Bugs Database:    http://bugs.centos.org/exiting.

[root@localhost ~]# vi /etc/dhcp/dhcpd.conf  # 配置如下subnet 192.168.20.0 netmask 255.255.255.0 {  range 192.168.20.100 192.168.20.200;  option domain-name-servers ns1.internal.example.org;  option domain-name "internal.example.org";  option routers 192.168.20.10;  option broadcast-address 192.168.20.255;  default-lease-time 600;  max-lease-time 7200;  filename "pxelinux.0";  next-server 192.168.20.10; 这里不需要双引号}

以上修改了发现可以启动但是起来有out了。还是继续找原因。

[root@localhost ~]# service dhcpd restart正在启动 dhcpd:                                           [确定][root@localhost ~]# /etc/init.d/dhcpd statusdhcpd 已死,但 pid 文件仍存[root@localhost ~]# tail -f /var/log/messagesFeb  3 02:12:49 localhost dhcpd: This version of ISC DHCP is based on the release availableFeb  3 02:12:49 localhost dhcpd: on ftp.isc.org.  Features have been added and other changesFeb  3 02:12:49 localhost dhcpd: have been made to the base software release in order to makeFeb  3 02:12:49 localhost dhcpd: it work better with this distribution.Feb  3 02:12:49 localhost dhcpd:Feb  3 02:12:49 localhost dhcpd: Please report for this software via the CentOS Bugs Database:Feb  3 02:12:49 localhost dhcpd:     http://bugs.centos.org/Feb  3 02:12:49 localhost dhcpd:Feb  3 02:12:49 localhost dhcpd: exiting.Feb  3 02:12:49 localhost kernel: type=1400 audit(1422900769.294:87): avc:  denied  { setgid } for  pid=4606 comm="dhcpd" capability=6  scontext=unconfined_u:system_r:dhcpd_t:s0 tcontext=unconfined_u:system_r:dhcpd_t:s0 tclass=capability  大概的意思就是启动dhcp连接读取系统文件被denied,就查找相关权限;[root@localhost ~]#  /usr/sbin/dhcpd restartInternet Systems Consortium DHCP Server 4.1.1-P1Copyright 2004-2010 Internet Systems Consortium.All rights reserved.For info, please visit https://www.isc.org/software/dhcp/Not searching LDAP since ldap-server, ldap-port and ldap-base-dn were not specified in the config fileWrote 0 class decls to leases file.Wrote 0 deleted host decls to leases file.Wrote 0 new dynamic host decls to leases file.Wrote 0 leases to leases file.No subnet declaration for restart (no IPv4 addresses).** Ignoring requests on restart.  If this is not what   you want, please write a subnet declaration   in your dhcpd.conf file for the network segment   to which interface restart is attached. **Not configured to listen on any interfaces!This version of ISC DHCP is based on the release availableon ftp.isc.org.  Features have been added and other changeshave been made to the base software release in order to makeit work better with this distribution.Please report for this software via the CentOS Bugs Database:    http://bugs.centos.org/exiting.[root@localhost ~]# ls -l /etc/dhcp/dhcpd.conf-rw-r--r--. 1 root root 3626 2月   3 02:17 /etc/dhcp/dhcpd.conf  #显示root用户[root@localhost ~]# vi /etc/init.d/dhcpdprog=dhcpd    #user=root    #原先是dhcpd    改为rootgroup=root   # #原先是dhcpd  改为rootexec=/usr/sbin/dhcpdlockfile=/var/lock/subsys/dhcpdpidfile=/var/run/dhcpd.pidstatedir=/var/lib/dhcpd改完重试一下![root@localhost ~]# service dhcpd restart关闭 dhcpd:                                               [确定]正在启动 dhcpd:                                           [确定][root@localhost ~]# ps -ax | grep dhcpdWarning: bad syntax, perhaps a bogus '-'? See /usr/share/doc/procps-3.2.8/FAQ 4992 ?        Ss     0:00 /usr/sbin/dhcpd -user root -group root 4996 pts/1    S+     0:00 grep dhcpd