DHCP配置示例dhcpd.conf

合集下载

dhcpd-config

dhcpd-config

DHCP服务器配置文件“/etc/dhcpd.conf”,以此为例。

ddns-update-style interim;ignore client-updates;subnet 192.168.0.0 netmask 255.255.255.0 {# --- default gatewayoption routers 192.168.0.1;option subnet-mask 255.255.255.0;option broadcast-address 192.168.0.255;option nis-domain "";option domain-name "";option domain-name-servers 192.168.1.1;option time-offset -18000; # Eastern Standard Time# option ntp-servers 192.168.1.1;# option netbios-name-servers 192.168.1.1;# --- Selects point-to-point node (default is hybrid). Don't change this unless# -- you understand Netbios very well# option netbios-node-type 2;range dynamic-bootp 192.168.0.128 192.168.0.254;default-lease-time 21600;max-lease-time 43200;# we want the nameserver to appear at a fixed addresshost ns {next-server ;hardware ethernet 12:34:56:78:AB:CD;fixed-address 207.175.42.254;option host-name “server”; #set client host name}}说明:默认下DHCP服务器配置文件dhcpd.conf在目录/etc下是空的,因此需要拷贝一份模板到此目录下,模板路径是/usr/share/doc/dhcp-3.0.3/dhcpd.conf.sample。

Linux1 DHCP服务器配置 主配置文件(dhcpd.conf)

Linux1 DHCP服务器配置  主配置文件(dhcpd.conf)

Linux1 DHCP服务器配置主配置文件(dhcpd.conf)使用Red Hat Enterprise Linux5.4自身携带的RPM包安装,安装结束后DHCP 端口监督程序dhcpd的主配置文件为/etc目录中名为dhcpd.conf的文件。

该文件通常包括3个部分,即parameters参数、declarations声明和option选项,如图9所示。

图9 dhcpd.conf文件DHCP的配置很简单,只要将dhcp.conf设置好即可。

不过编辑此文件时需要注意以下几点:●# 为批注符号。

●除了括号那一行外,其他每一行后面都要以“;”为结尾。

这是最容易出错的地方。

●设置的项目都有其独特的名称,形式为“<参数代码><设置内容>”,例如“default-lease-time 259200”。

●某些项目必须利用option来设置,形式为“option <参考代码><设置内容>”,例如“option domain-name “”;”。

DHCP的IP分配可分为动态IP和静态IP,其中需要了解的是,如果需要设置静态IP,则需要知道欲设置成静态IP的那台计算机的硬件地址(MAC地址),可使用arp及ifconfig命令来查询接口的MAC地址。

此外,还需进行如下几项设置。

1.整体设置(Global)整体设置包括设置租约期限、DNS的IP地址、路由器的IP地址、动态DNS (DDNS)更新的类型等。

当静态IP及动态IP内没有规范到某些设置时,则以整体设置值为准。

最常使用的参数如下:●Default-lease-time 时间默认的租约时间,单位为秒。

●Max-lease-time 时间最大租约时间,当客户端超过租约时间但尚未更新IP地址时,最长可以使用该IP地址的时间。

●Option domain-name “域名”如果在/etc/resolv.conf文件里设置了search,则表示当要搜索计算机名称时,DNS系统会主动帮客户端加上这个领域的名称。

Linux下配置完整安全的DHCP服务器详解

Linux下配置完整安全的DHCP服务器详解

名称dhcpd.conf - dhcpd 配置文件描述dhcpd.conf 文件包括ISC DHCP的dhcpd的配置信息。

dhcpd.conf文件是一个普通格式的ASCII码文档,它由内置的递归解析器解释。

dhcpd.conf文件可能会包含许多额外的tab和空格、空行,它们的目的是让文件更容易阅读。

其中的关键字对大小写不敏感。

注释语句可以放在任何位置(除了引号中)注释语句用# 开头,这一行结束时注释语句自然结束。

文件包括一组语句,语句在一对大括号中,包含参数和声明。

参数语句说明如何做一件事(例如,租期是多长时间),或者是否做一件事情。

(例如,dhcpd 是否为未知客户提供地址),或者给客户提供哪种参数(例如,使用网关220.177.244.7)。

声明用来描述网络的拓扑结构、网络上的客户,提供可以为客户端分配的地址,或者对某个客户端组应用组(group)参数。

在任何组参数中,所有的这些组参数必须比使用这些组参数的语句先出现。

网络声明包含多子网的网络(有些地方译为:超网,但超网太难理解了,这里叫“多子网网络”)和子网的拓扑声明。

对于有地址被动态分配给客户端的子网,子网声明中必须有一个range声明语句。

对于静态分配的地址,或者是已知客户的安装,每个客户端都必须使用一个host声明语句。

如果一个参数应用到一组声明中,这些声明并不只与某个子网相关,可以定义一个“组参数”。

对每一个要服务的子网,每个dhcp服务器连接的子网,都必须有一个子网声明,用来告诉dhcpd如何处理那个子网上的地址。

即使一个子网不需要分配任何地址,也需要一个子网声明。

一些物理网络上不只有一个IP子网存在,例如,如果一个网络需要一个8位的子网,但是当业务发展使总的节点数超过了254台,就需要增加一个8位的子网。

这时,就增加了一个新的物理网络,这种情况下,2个网络的子网声明必须包含在一个“多子网网络声明(超级作用域)”中。

有些网络的客户端不只有一个子网,可能会为同一子网中一些客户端分配的一些参数与其它的客户端不同。

DHCP的配置

DHCP的配置


安装DHCP服务
安装DHCP服务,需要Red Hat Linux 9的 第二张安装光盘的“/RedHat/RPMS/dhcp3.0pl1-23.i386.rpm”文件 ,文件备份在
“/bak”目录下,输入下面的命令进行DHCP服务的 安装。
[root@dns root]#rpm –ivh /bak/ dhcp-3.0pl1-23.i386.rpm
到菜单中的“dhcpd”项,按“空格键”选中, 再后按“TAB”键将光标移到“确定”按钮上, 并按“回车”键完成设置。 这样,DHCP服务只要开机后就会自动启动
配置客户端
请参见实训3.2DHCP的配置中的客户端设 置步骤配置客户端(windows 2000 prefessional)为自动获取IP地址,并通过 DOS下的“ipconfig /release”与“ipconfig /renew”释放与获得IP地址
详细案例的配置
第二部分
案例配置的环境要求
案例配置的环境如下,两台主机通过交叉线相连,或两台主机 与HUB相连。DNS服务器为LINUX操作系统,客户机为 WINDOW系列(如windows 2000 prof 客户机
案例配置的参数要求
确认是否已安装了DHCP服务
使用下面的命令验证是否已安装了DHCP服 务:
[root@dns root]#rpm -qa dhcp 备注:如果显示结果为“dhcp-3.0pl1-23”表
示已安装了DHCP服务
建立并编辑“/etc/dhcpd.conf”文件
DHCP服务安装后,会自动产生一个配置文件 的 模 板 “ / usr/share/doc/dhcp3.0pl1/dhcpd.conf.sample” ,通过把这个 文 件 复 制 到 “ / etc” 目 录 下 , 并 且 命 令 为 “dhcpd.conf”,然后对其进行编辑。

Linux下dhcpd服务器配置

Linux下dhcpd服务器配置

default-lease-time 86400;
maxlease-time 604800;
如果客户不继续请求DHCP地址,则86400秒后释放IP地址,否则最大允许租用的时间为604800秒。
option subnetmask 255.255.255.0;
option routers 200.1 1 7.207.1;
其中subnet×.×.×.×说明IP地址是否属于该子网;netmask×.×.×.×提供子网的一些参数;range×.×.×.× ×.×.×.×是DHCP服务器可以分配的IP地址范围;default-lease-time设置缺省的IP租用时间,常用的是86400秒(一天);maxleasetime是最大租用时间,常用的是604800(一周);option subnet-mask设置IP地址的子网掩码;option routers设置在DHCP发布IP地址的同时,把网关发布出去,这一项是用来指明网关的;option broadcast-address设置该子网的广播地址;option domain-name-servers设置DNS服务器IP地址option domain-name“”设置DNS域名。
一个DHCP配置文件的主要内容:
subnet 200.117.207.0 netmask 255.255.255.0
{
range 200.117.20ቤተ መጻሕፍቲ ባይዱ.10 200.117.207.100;
range 200.117.207.110 200.117.207.200;
允许DHCP服务器分配两段地址范围给客户,200.117.207.10~100或者200.117.207.100~200。

DHCP三种配置

DHCP三种配置

DHCP三种配置⼀ DHCP分配客户机IP地址[root@localhost ~]# rpm -q dhcp //检查dhcp服务是否安装[root@localhost ~]# mount /dev/cdron /media[root@localhost ~]# cd /media/Packages[root@localhost ~]# rpm -ivh dhcp-4.2.5-36.e17.centos.x86_64.rpm[root@localhost ~]# vim /etc/dhcp/dhcpd.conf## DHCP Server Configuration file.# see /usr/share/doc/dhcp*/dhcpd.conf.example# see dhcpd.conf(5) man page#~ [root@localhost ~]# cat /usr/share/doc/dhcp-4.2.5/dhcpd.conf.example >/etc/dhcp/dhcpd.conf [root@localhost ~]# vim /etc/dhcp/dhcpd.confoption domain-name "localhost";option domain-name-servers 202.106.0.20,8.8.8.8; //DNS解析default-lease-time 360; //IP地址默认租约max-lease-time 7200; //IP最⼤租约时间subnet 192.168.200.0 netmask 255.255.255.0 { //⽹段和⼦⽹掩码range 192.168.200.180 192.168.200.200; //分配IP地址地址池option routers 192.168.200.1; //⽹关}[root@localhost ~]# systemctl start dhcpd //开启dhcp服务[root@localhost ~]# vim /etc/sysconfig/network-scripts/ifcfg-eno16777728TYPE=EthernetBOOTPROTO=dhcp //修改DEFROUTE=yesPEERDNS=yesPEERROUTES=yesIPV4_FAILURE_FATAL=noIPV6INIT=yesIPV6_AUTOCONF=yesIPV6_DEFROUTE=yesIPV6_PEERDNS=yesIPV6_PEERROUTES=yesIPV6_FAILURE_FATAL=noNAME=eno16777728DEVICE=eno16777728ONBOOT=yes //可以改IPADDR=192.168.200.101NETMASK=255.255.255.0GATEWAY=192.168.200.1DNS1=202.106.0.20[root@localhost ~]# systemctl restart network //重启服务禁⽤并重启,活得地址池IP地址(客户机要进⼊NET模式)⼆DHCP固定IP地址[root@localhost ~]# cat /var/lib/dhcpd/dhcpd.leases //查看租约信息并获取⽹卡信息[root@localhost ~]# vim /etc/dhcp/dhcpd.conflease 192.168.200.15 {starts 5 2019/08/16 07:37:52;ends 5 2019/08/16 07:47:52;tstp 5 2019/08/16 07:47:52;cltt 5 2019/08/16 07:37:52;binding state active;next binding state free;rewind binding state free;hardware ethernet 00:0c:29:93:3e:e3;添加host win7 {hardware ethernet 00:0c:29:93:3e:e3;fixed-address 192.168.200.99; //固定IP地址若是win7客户机不成功cmd命令中输⼊ ipconfig /release 释放IPipconfig /renew 获取IP三 DHCP中继配置需要 DHCP服务器⼀个和两个⽹卡的DHCP中继中继器的配置情况如下:[root@localhost ~]# mount /dev/cdron /media[root@localhost ~]# cd /media/Packages[root@localhost ~]# rpm -ivh dhcp-4.2.5-36.e17.centos.x86_64.rpm[root@localhost ~]# vim /etc/sysconfig/network-scripts/ifcfg-eno16777728删除⽹关和DNS[root@localhost ~]#cp /etc/sysconfig/network-scripts/ifcfg-eno16777728 /etc/sysconfig/network-scripts/ifcfg-eno33554960 [root@localhost ~]#vim /etc/sysconfig/network-scripts/ifcfg-eno33554960修改并删除[root@localhost ~]# systemctl restart network[root@localhost ~]# dhcrelay 192.168.200.111 //开启中继服务在DHCP服务器的配置:[root@localhost ~]# vim /etc/dhcp/dhcpd.conf添加这四⾏命令subnet 192.168.100.0 netmask 255.255.255.0 {range 192.168.100.15 192.168.100.40;option routers 192.168.100.1;}[root@localhost ~]# systemctl restart dhcpd[root@localhost ~]# vim /etc/sysconfig/network-scripts/ifcfg-eno16777728在中继器中ping若要ping通 window 需要关闭防⽕墙[root@localhost ~]# systemctl disable firewalld.servicerm '/etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service' //关闭中继的防⽕墙rm '/etc/systemd/system/basic.target.wants/firewalld.service'。

dhcpd.conf配置文件

dhcpd.conf配置文件

Linux下DHCP服务器介绍:dhcpd.conf配置文件DHCP (Dynamic Host Configuration Protocol) 动态主机配置协议·为在同一网络的主机自动分配动态IP·[root@book named]# /sbin/ifconfig -a eth0 | grep MULTICAST #查看内核是否支持多播UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1·为使用DHCP服务器能满足某些挑剔的DHCP客户机,应在路由表中加入一个到地址255.255.255.255的路由。

·DHCP服务器必须能将数据包送到255.255.255.255的IP地址上,但Linux本身又将该地址作为本地子网的广播地---------------------------------------------------------------------------------------------------------/etc/dhcpd.conf通常包括三部分:parameters、declarations 、option。

1.DHCP配置文件中的parameters(参数):表明如何执行任务,是否要执行任务,或将哪些网络配置选项发送给客户参数解释ddns-update-style 配置DHCP-DNS 互动更新模式。

allow/igore client-updates 允许/忽略客户端机更新DNS记录。

default-lease-time 指定确省租赁时间的长度,单位是秒。

max-lease-time 指定最大租赁时间长度,单位是秒。

hardware 指定网卡接口类型和MAC地址。

server-name 通知DHCP客户服务器名称。

get-lease-hostnames flag 检查客户端使用的IP地址。

怎样用DHCP服务器给多个网段的客户端分配IP地址

怎样用DHCP服务器给多个网段的客户端分配IP地址

怎样用DHCP服务器给多个网段的客户端分配IP地址分享|2009-03-20 19:39 IP服务器专业回答ps帝师团队zhuguofu20042015-11-14 20:55(1)简单实现DHCP多作用域对于多作用域的配置,必须保证DHCP服务器能够侦听所有子网客户机的请求信息,下面将讲解配置多作用域的基本方法,为DHCP添加多个网卡连接每个子网,并发布多个作用域的声明。

注意:划分子网时,如果选择直接配置多作用域实现动态IP分配的任务,则必须要为DHCP 服务器添加多块网卡,并配置多个IP地址,否则DHCP服务器只能分配与其现有网卡IP 地址对应网段的作用域。

采用双网卡实现两个作用域1)网卡配置IP地址DHCP服务器有多块网卡时,需要使用ifconfig命令为每块网卡配置独立的IP地址,但要注意,IP地址配置的网段要与DHCP服务器发布的作用域对应哈~ifconfig eth0 192.168.2.1 netmask 255.255.255.0ifconfig eth1 192.168.3.1 netmask 255.255.255.02)编辑dhcpd.conf主配置文件当DHCP服务器网络环境搭建完毕后,可以编辑dhcpd.conf主配置文件完成多作用域的设置。

ddns-update-style none;ignore client-updates;subnet 192.168.2.0 netmask 255.255.255.0 {# --- default gatewayoption routers 192.168.2.1;option subnet-mask 255.255.255.0;option nis-domain "";option domain-name "";option domain-name-servers 192.168.2.2;option time-offset -18000; # Eastern Standard Time# option ntp-servers 192.168.1.1;# option netbios-name-servers 192.168.1.1;# --- Selects point-to-point node (default is hybrid). Don't change this unless# -- you understand Netbios very well# option netbios-node-type 2;range dynamic-bootp 192.168.2.50 192.168.2.250;default-lease-time 21600;max-lease-time 43200;# we want the nameserver to appear at a fixed addresshost ns {next-server ;hardware ethernet 12:34:56:78:AB:CD;fixed-address 207.175.42.254;}}subnet 192.168.3.0 netmask 255.255.255.0 {# --- default gatewayoption routers 192.168.3.1;option subnet-mask 255.255.255.0;option nis-domain "";option domain-name "";option domain-name-servers 192.168.2.2;option time-offset -18000; # Eastern Standard Time# option ntp-servers 192.168.1.1;# option netbios-name-servers 192.168.1.1;# --- Selects point-to-point node (default is hybrid). Don't change this unless# -- you understand Netbios very well# option netbios-node-type 2;range dynamic-bootp 192.168.3.50 192.168.3.250;default-lease-time 21600;max-lease-time 43200;max-lease-time 43200;}保存退出。

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

一、dhcpd.conf
## dhcpd.conf
# Managed by Ansible
# Do not edit manually
# option definitions common to all supported networks...
option domain-name "";
option domain-name-servers ;
#DHCP options
#DHCP parameters
# Classes
# Subnets
subnet 172.20.254.0 netmask 255.255.255.0 {
range 172.20.254.177 172.20.254.185;
option routers 172.20.254.1;
option broadcast-address 172.20.254.255;
}
# Hosts
# Shared networks
二、dhcpd.conf.sample
root@cqu_freebsd_006:/usr/local/etc # vim dhcpd.conf.sample
# dhcpd.conf
# Sample configuration file for ISC dhcpd
# option definitions common to all supported networks...
option domain-name "";
option domain-name-servers , ;
default-lease-time 600;
max-lease-time 7200;
# Use this to enble / disable dynamic dns updates globally.
#ddns-update-style none;
# If this DHCP server is the official DHCP server for the local
# network, the authoritative directive should be uncommented.
#authoritative;
# Use this to send dhcp log messages to a different log file (you also # have to hack syslog.conf to complete the redirection).
log-facility local7;
# No service will be given on this subnet, but declaring it helps the
# DHCP server to understand the network topology.
subnet 10.152.187.0 netmask 255.255.255.0 {
}
# This is a very basic subnet declaration.
subnet 10.254.239.0 netmask 255.255.255.224 {
range 10.254.239.10 10.254.239.20;
option routers , ;
}
# This declaration allows BOOTP clients to get dynamic addresses,
# which we don't really recommend.
subnet 10.254.239.32 netmask 255.255.255.224 {
range dynamic-bootp 10.254.239.40 10.254.239.60;
option broadcast-address 10.254.239.31;
option routers ;
}
# A slightly different configuration for an internal subnet.
subnet 10.5.5.0 netmask 255.255.255.224 {
range 10.5.5.26 10.5.5.30;
option domain-name-servers ;
option domain-name "";
option routers 10.5.5.1;
option broadcast-address 10.5.5.31;
default-lease-time 600;
max-lease-time 7200;
}
# Hosts which require special configuration options can be listed in # host statements. If no address is specified, the address will be # allocated dynamically (if possible), but the host-specific information # will still come from the host declaration.
host passacaglia {
hardwareethernet 0:0:c0:5d:bd:95;
filename "vmunix.passacaglia";
server-name "";
}
# Fixed IP addresses can also be specified for hosts. These addresses
# should not also be listed as being available for dynamic assignment.
# Hosts for which fixed IP addresses have been specified can boot using
# BOOTP or DHCP. Hosts for which no fixed address is specified can only # be booted with DHCP, unless there is an address range on the subnet
# to which a BOOTP client is connected which has the dynamic-bootp flag # set.
host fantasia {
hardwareethernet 08:00:07:26:c0:a5;
fixed-address ;
}
# You can declare a class of clients and then do address allocation
# based on that. The example below shows a case where all clients
# in a certain class get addresses on the 10.17.224/24 subnet, and all
# other clients get addresses on the 10.0.29/24 subnet.
class "foo" {
match if substring (option vendor-class-identifier, 0, 4) = "SUNW";
}
shared-network 224-29 {
subnet 10.17.224.0 netmask 255.255.255.0 {
option routers ;
}
subnet 10.0.29.0 netmask 255.255.255.0 {
option routers ;
}
pool {
allow members of "foo";
range 10.17.224.10 10.17.224.250;
}
pool {
deny members of "foo";
range 10.0.29.10 10.0.29.230;
}
}。

相关文档
最新文档