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.i686 Error 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/messages Feb 2 21:09:23 localhost dhcpd: Feb 2 21:09:23 localhost dhcpd: This version of ISC DHCP is based on the release available Feb 2 21:09:23 localhost dhcpd: on ftp.isc.org. Features have been added and other changes Feb 2 21:09:23 localhost dhcpd: have been made to the base software release in order to make Feb 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-P1 Copyright 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 -- exiting This version of ISC DHCP is based on the release available on ftp.isc.org. Features have been added and other changes have been made to the base software release in order to make it 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 status dhcpd 已死,但 pid 文件仍存 [root@localhost ~]# tail -f /var/log/messages Feb 3 02:12:49 localhost dhcpd: This version of ISC DHCP is based on the release available Feb 3 02:12:49 localhost dhcpd: on ftp.isc.org. Features have been added and other changes Feb 3 02:12:49 localhost dhcpd: have been made to the base software release in order to make Feb 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 restart Internet Systems Consortium DHCP Server 4.1.1-P1 Copyright 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 file Wrote 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 available on ftp.isc.org. Features have been added and other changes have been made to the base software release in order to make it 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/dhcpd prog=dhcpd # user=root #原先是dhcpd 改爲root group=root # #原先是dhcpd 改爲root exec=/usr/sbin/dhcpd lockfile=/var/lock/subsys/dhcpd pidfile=/var/run/dhcpd.pid statedir=/var/lib/dhcpd 改完重試一下! [root@localhost ~]# service dhcpd restart 關閉 dhcpd: [確定] 正在啓動 dhcpd: [確定] [root@localhost ~]# ps -ax | grep dhcpd Warning: 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