CentOS 7 配置DHCP服务器

一、DHCP介绍
  DHCP 动态主机管理协议(Dynamic Host Configuration Protocol) 是一种基于UDP协议且仅限于局域网的网络协议,主要用途是为局域网内部设备或网络供应商自动分配IP地址,通常会应用在大型的局域网内存在比较多的移动办公设备,DHCP协议能够实现集中的管理、分配IP地址。

  DHCP服务程序能够使局域网内的主机自动且动态的获取IP地址、子网掩码、网关地址以及DNS服务器地址等信息,且能够有效的提升地址的使用率,提高配置效率,减少管理和维护成本。

  

 DHCP协议能够保证任何IP地址在同一时刻只能由一台DHCP客户端使用,且能够为指定主机分配固定的IP地址。

  

二、DHCP服务程序的常见术语:
    作用域:一个完整的IP地址段,DHCP服务器根据作用域来管理网络的分布、分配IP地址及其他配置参数。
    超级作用域:用于支持同一物理网络上多个逻辑IP地址自网段,包含作用域列表,并对子作用域统一管理。
    排除范围:将某些IP地址在作用域中排除,确保这些IP地址不会被提供给DHCP客户端。
    地址池:在定义DHCP服务的作用域并应用排除范围后,剩余用来动态分配给DHCP客户机的IP地址范围。
    租约:即DHCP客户机能够使用动态分配到的IP地址的时间。
    预约:保证局域子网中特定设备总是获取到相同的IP地址。

三、配置

  **************环境&注意事项*************

  系统:cent OS 7 ;

  DHCP服务器:固定IP地址;

  客户端和服务器能相互通信。

  *********************************************


  1.安装DHCP服务器:    #两种方式
    rpm -ivh dhcp-3.0.1-59.EL4.i386.rpm 
    yum -y install dhcp

  2.复制dhcpd配置文件的样本:

1 # cp /usr/share/doc/dhcp-4.2.5/dhcpd.conf.example  /etc/dhcp/dhcpd.conf 

  

  3.编辑DHCP配置文件:

 1 vi /etc/dhcpd.conf
 2 ddns-update-style interim;
 3 ignore client-updates;
 4 subnet 192.168.0.0 netmask 255.255.255.0 {
 5 # --- default gateway
 6         option routers                  192.168.0.1;
 7         option subnet-mask              255.255.255.0;
 8         option nis-domain               "domain.org";
 9         option domain-name              "domain.org";                            #域名
10         option domain-name-servers      192.168.1.1;
11         option time-offset              -18000; # Eastern Standard Time
12 #       option ntp-servers              192.168.1.1;
13 #       option netbios-name-servers     192.168.1.1;
14 # --- Selects point-to-point node (default is hybrid). Don't change this unless
15 # -- you understand Netbios very well
16 #       option netbios-node-type 2;
17         range dynamic-bootp 192.168.0.128 192.168.0.254;
18         default-lease-time 21600;
19         max-lease-time 43200;
20         # we want the nameserver to appear at a fixed address
21         host ns {
22                 next-server marvin.redhat.com;
23                 hardware ethernet 12:34:56:78:AB:CD;
24                 fixed-address 207.175.42.254;
25         }
26 }
27  
28 #修改为
29 ddns-update-style none;                                                 #关闭dhcp服务器和dns服务器内部更新自动协商
30 ignore client-updates;
31 subnet 172.16.10.0 netmask 255.255.255.0 {                               
32         option routers                  172.16.10.2;                       #网关
33         option subnet-mask              255.255.255.0;                     #子网掩码
34         option domain-name-servers      202.103.24.68,202.103.0.117;       #DNS服务器地址
35         option time-offset              -18000; # Eastern Standard Time
36 # --- Selects point-to-point node (default is hybrid). Don't change this unless
37 # -- you understand Netbios very well
38 #       option netbios-node-type 2;
39         range dynamic-bootp 172.16.10.100 172.16.10.200;                   #地址池
40         default-lease-time 21600;                                          #默认租约时间(秒)
41         max-lease-time 43200;                                                                                  #最大租约时间(秒)
42         # we want the nameserver to appear at a fixed address
43         host JTWD01-28 {
44                 next-server marvin.redhat.com;
45                 hardware ethernet 00:1E:90:17:CC:67;                       #根据主机网卡mac地址分配IP地址
46                 fixed-address 172.16.10.88;                                #分配的固定IP地址
47         }
48 }

  4.重启DHCP服务:

1 # systemctl restart dhcpd

猜你喜欢

转载自www.cnblogs.com/wangqian723/p/10168453.html