Centos6.5-DHCPServer安装,


1、查询dhcp有没有被安装,如下没有被安装

[zfp@localhost ~]$ rpm -q dhcp
package dhcp is not installed
[zfp@localhost ~]$

2、查询yum网络源中有关dhcp的rpm包

[root@localhost zfp]# yum list |grep dhcp
dhcp.x86_64                        12:4.1.1-53.P1.el6.centos.1 updates         
dhcp-common.x86_64                 12:4.1.1-53.P1.el6.centos.1 updates         
dhcp-devel.i686                    12:4.1.1-53.P1.el6.centos.1 updates         
dhcp-devel.x86_64                  12:4.1.1-53.P1.el6.centos.1 updates         
sblim-cmpi-dhcp.i686               1.0-1.el6                   base            
sblim-cmpi-dhcp.x86_64             1.0-1.el6                   base            
sblim-cmpi-dhcp-devel.i686         1.0-1.el6                   base            
sblim-cmpi-dhcp-devel.x86_64       1.0-1.el6                   base            
sblim-cmpi-dhcp-test.x86_64        1.0-1.el6                   base 

3、安装dhcp

[root@localhost zfp]# yum install dhcp -y

4、查询是否安装成功

[root@localhost zfp]# rpm -q dhcp
dhcp-4.1.1-53.P1.el6.centos.1.x86_64
[root@localhost zfp]#

查询安装的含有dhcp字符串包名的rpm包
[root@localhost zfp]# rpm -qa |grep dhcp
dhcp-common-4.1.1-53.P1.el6.centos.1.x86_64
dhcp-4.1.1-53.P1.el6.centos.1.x86_64

5、修改配置文件/etc/dhcp/dhcpd.conf

不同的发行版不一定是/etc/dhcp/dhcpd.conf这个文件,也可能是/etc/dhcpd.conf,centos6.5发行版是/etc/dhcp/dhcpd.conf

[root@localhost zfp]#vim /etc/dhcp/dhcpd.conf

ddns-update-style interim;      #表示dhcp服务器和dns服务器的动态信息更新模式 

ignore client-updates;          #忽略客户端更新

subnet 192.168.145.0 netmask 255.255.255.0 {        #意思是我所分配的ip地址所在的网段为192.168.145.0 子网掩码为255.255.255.0

   range 192.168.145.200 192.168.145.210;            #租用IP地址的范围

  option domain-name-servers 8.8.8.8;

  option domain-name "example.org";

  option routers 192.168.145.100;                    #路由器地址,这里是当前 dhcp 机器的IP地址

  option subnet-mask 255.255.255.0;                  #子网掩码

  default-lease-time 600;                            #默认租约时间

  max-lease-time 7200;                              #最大租约时间

#host myhost {                                      #设置主机声明

#hardware ethernet 08:00:27:2C:30:8C;            #指定dhcp客户的mac地址

#fixed-address 192.168.145.155;                  #给指定的mac地址分配ip

# }

}


[root@localhost zfp]#vim /etc/sysconfig/dhcpd
DHCPDARGS=eth0     #指定在eth0网卡上提供dhcpserver服务

6、开启dhcp服务

[root@localhost zfp]# service dhcpd status
dhcpd (pid  4478) 正在运行...
[root@localhost zfp]#

如果有报错,查看dhcp服务开启的时候,报什么错误cat /var/log/messages  或者tail -f /var/log/messages &

如下是正常开启dhcp服务的log信息

Jan  1 03:09:42 localhost dhcpd: Internet Systems Consortium DHCP Server 4.1.1-P1
Jan  1 03:09:42 localhost dhcpd: Copyright 2004-2010 Internet Systems Consortium.
Jan  1 03:09:42 localhost dhcpd: All rights reserved.
Jan  1 03:09:42 localhost dhcpd: For info, please visit https://www.isc.org/software/dhcp/
Jan  1 03:09:42 localhost dhcpd: Not searching LDAP since ldap-server, ldap-port and ldap-base-dn were not specified in the config file
Jan  1 03:09:42 localhost dhcpd: Wrote 0 leases to leases file.
Jan  1 03:09:42 localhost dhcpd: Listening on LPF/eth0/00:0c:29:9b:2d:be/192.168.145.0/24
Jan  1 03:09:42 localhost dhcpd: Sending on   LPF/eth0/00:0c:29:9b:2d:be/192.168.145.0/24
Jan  1 03:09:42 localhost dhcpd: Sending on   Socket/fallback/fallback-net

[root@localhost network-scripts]# netstat -anulp | grep :67
udp        0      0 0.0.0.0:67                  0.0.0.0:*                               4591/dhcpd         
[root@localhost network-scripts]#

End Of File

 

相关内容

    暂无相关文章