DHCP实现:

注意:

(1)实现DHCP服务前,先将网络已有DHCP服务,如:vmware中的DHCP关闭,防止冲突
(2)DHCP服务器本身采用静态IP
(3)必须配置和DHCP网卡的静态IP所在网段的subnet 段,否则DHCP服务无法启动

DHCP服务的实现软件:
dhcp(CentOS 7 之前版本) 或 dhcp-server(CentOS 8 中的包名)

dhcp服务配置文件:/etc/dhcp/dhcpd.conf

dhcp服务配置范例文件:/usr/share/doc/dhcp*/dhcpd.conf.example

1、关闭vmware中的DHCP

2、安装dhcp

[root@centos7 ~]#yum install -y dhcp

3、复制并修改配置文件,给指定主机分配固定IP

[root@centos7 ~]#rpm -ql dhcp
/etc/NetworkManager
/etc/NetworkManager/dispatcher.d
/etc/NetworkManager/dispatcher.d/12-dhcpd
/etc/dhcp/dhcpd.conf
/etc/dhcp/dhcpd6.conf
/etc/dhcp/scripts
/etc/dhcp/scripts/README.scripts
/etc/openldap/schema/dhcp.schema
/etc/sysconfig/dhcpd
/usr/bin/omshell
/usr/lib/systemd/system/dhcpd.service
/usr/lib/systemd/system/dhcpd6.service
/usr/lib/systemd/system/dhcrelay.service
/usr/sbin/dhcpd
/usr/sbin/dhcrelay
/usr/share/doc/dhcp-4.2.5
/usr/share/doc/dhcp-4.2.5/dhcpd.conf.example
/usr/share/doc/dhcp-4.2.5/dhcpd6.conf.example
/usr/share/doc/dhcp-4.2.5/ldap
/usr/share/doc/dhcp-4.2.5/ldap/README.ldap
/usr/share/doc/dhcp-4.2.5/ldap/dhcp.schema
/usr/share/doc/dhcp-4.2.5/ldap/dhcpd-conf-to-ldap
/usr/share/man/man1/omshell.1.gz
/usr/share/man/man5/dhcpd.conf.5.gz
/usr/share/man/man5/dhcpd.leases.5.gz
/usr/share/man/man8/dhcpd.8.gz
/usr/share/man/man8/dhcrelay.8.gz
/usr/share/systemtap/tapset/dhcpd.stp
/var/lib/dhcpd
/var/lib/dhcpd/dhcpd.leases
/var/lib/dhcpd/dhcpd6.leases
[root@centos7 ~]#cp /usr/share/doc/dhcp-4.2.5/dhcpd.conf.example /etc/dhcp/dhcpd.conf
cp: overwrite ‘/etc/dhcp/dhcpd.conf’? y
[root@centos7 ~]#ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00inet 127.0.0.1/8 scope host lovalid_lft forever preferred_lft foreverinet6 ::1/128 scope hostvalid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000link/ether 00:0c:29:33:b7:af brd ff:ff:ff:ff:ff:ffinet 10.0.0.7/24 brd 10.0.0.255 scope global noprefixroute eth0valid_lft forever preferred_lft foreverinet6 fe80::31c3:e200:902b:ae0e/64 scope link noprefixroutevalid_lft forever preferred_lft forever
[root@centos7 ~]#vim /etc/dhcp/dhcpd.conf
[root@centos7 ~]#cat /etc/dhcp/dhcpd.conf
# dhcpd.conf
#
# Sample configuration file for ISC dhcpd
## option definitions common to all supported networks...
option domain-name "example.org";
option domain-name-servers 223.5.5.5, 180.76.76.76;default-lease-time 86400;
max-lease-time 106400;# 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.0.0.0 netmask 255.255.255.0 {range 10.0.0.150 10.0.0.180;option routers 10.0.0.2;
}# 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 rtr-239-0-1.example.org, rtr-239-0-2.example.org;
}# 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 rtr-239-32-1.example.org;
}# 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 ns1.internal.example.org;option domain-name "internal.example.org";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 testhost {hardware ethernet 00:0c:29:33:b7:af;fixed-address 10.0.0.123;
}
host passacaglia {hardware ethernet 0:0:c0:5d:bd:95;filename "vmunix.passacaglia";server-name "toccata.fugue.com";
}# 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 {hardware ethernet 08:00:07:26:c0:a5;fixed-address fantasia.fugue.com;
}# 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 rtr-224.example.org;}subnet 10.0.29.0 netmask 255.255.255.0 {option routers rtr-29.example.org;}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;}
}

4、启动dhcp服务,查看dhcp客户端申请地址的过程

[root@centos7 ~]#systemctl start dhcpd
[root@centos7 ~]#dhclient -d
Internet Systems Consortium DHCP Client 4.2.5
Copyright 2004-2013 Internet Systems Consortium.
All rights reserved.
For info, please visit https://www.isc.org/software/dhcp/Listening on LPF/eth0/00:0c:29:33:b7:af
Sending on   LPF/eth0/00:0c:29:33:b7:af
Sending on   Socket/fallback
DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 4 (xid=0x508cbce0)
DHCPREQUEST on eth0 to 255.255.255.255 port 67 (xid=0x508cbce0)
DHCPOFFER from 10.0.0.7
DHCPACK from 10.0.0.7 (xid=0x508cbce0)
bound to 10.0.0.123 -- renewal in 37907 seconds.
[root@centos7 ~]#ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00inet 127.0.0.1/8 scope host lovalid_lft forever preferred_lft foreverinet6 ::1/128 scope hostvalid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000link/ether 00:0c:29:33:b7:af brd ff:ff:ff:ff:ff:ffinet 10.0.0.7/24 brd 10.0.0.255 scope global noprefixroute eth0valid_lft forever preferred_lft foreverinet 10.0.0.123/24 brd 10.0.0.255 scope global secondary dynamic eth0valid_lft 86259sec preferred_lft 86259secinet6 fe80::31c3:e200:902b:ae0e/64 scope link noprefixroutevalid_lft forever preferred_lft forever

搭建dhcp服务,实现ip地址申请分发相关推荐

  1. 飞凌 修改ip地址 linux,linux上搭建DHCP服务

    linux上搭建DHCP服务 1.首先安装DHCP服务需要的软件包 yum install dhcp* 2.手工编译DHCP主配置文件/etc/dhcp/dhcpd.conf 配置内容如下 ddns- ...

  2. 搭建DHCP服务实现动态分配IP地址-NTP网络同步时间

    一. DHCP服务概述 1. DHCP的介绍 名称:DHCP (Dynamic Host Configuration Protocol)动态主机配置协议. 功能:DHCP(Dynamic Host C ...

  3. Linux / CentOs 7搭建DHCP服务

    在前面介绍了怎么在Windows server 2016中搭建DHCP服务, 我们今天介绍如何在Linux / CentOS 7操作系统中搭建DHCP服务? 跟在Windows server 2016 ...

  4. NetScaler通过DHCP服务器获取IP地址

    NetScaler通过DHCP服务器获取IP地址 DHCP 选项参考 https://www.iana.org/assignments/bootp-dhcp-parameters/bootp-dhcp ...

  5. dhcp服务器批量修改ip租期,dhcp服务器的ip地址租期默认是多久

    dhcp服务器的ip地址租期默认是多久 内容精选 换一换 Atlas 200 DK开发者板支持通过USB端口或者网线与Ubuntu服务器进行连接,连接示例图如图1所示.Atlas 200 DK连接Ub ...

  6. 卸载系统的dhcp服务器,dhcp服务器释放ip地址

    dhcp服务器释放ip地址 内容精选 换一换 用户的弹性云服务器已绑定EIP,但是无法连接到Internet.弹性云服务器通过EIP访问Internet的流程如图1所示:本问题请按照以下思路进行排查处 ...

  7. DHCP如何分配IP地址

    这次为了实现DHCP分配IP地址,我用到了eNSP软件,下面给大家写一些这个软件中一些基础配置 设备的基础配置: < Huawei > <>代表了当下所在的模式,不同的模式具有 ...

  8. linux云计算架构师:搭建DHCP服务和NTP网络时间同步

    全套学习资料移步至公众号[学神来啦]更多学习资料添加扣扣资源群:661308959 本节所讲内容:   3.1  DHCP服务器工作原理   3.2  实战:使用DHCP动态分配IP地址   3.3 ...

  9. 搭建DHCP服务和NTP网络时间同步

    DHCP服务器工作原理 DHCP服务概述: 名称:DHCP (Dynamic Host Configuration Protocol)动态主机配置协议. 功能:DHCP(Dynamic Host Co ...

最新文章

  1. 炒菜机器人煎鸡蛋视频_我的生活小技巧,今天才发现鹅油那么好用,炸鸡蛋炸豆腐都挺好...
  2. oracle每小时分组查询,Oracle 天内按小时分组查询有关问题
  3. 2020-07-15 CVPR2020 表示学习论文讨论(4) 笔记
  4. 22504!Windows 11 新预览版发布
  5. 这10个人,总是牛逼的无话可说
  6. 【POJ - 2337】Catenyms(欧拉图相关,欧拉通路输出路径,tricks)
  7. 基于动态混合高斯模型的商品价格模型算法
  8. html禁止转义reg,HTML转义 - Reg表达式?
  9. layui table勾选框的修改_layui表格(Table)下添加可更新拉选择框select
  10. node爬取cnode首页数据
  11. cad2020打印样式放在哪个文件夹_CAD图形打印相关问题!
  12. 信息系统分析与设计 第十章 系统总体设计
  13. 经典前端框架,一个时代的落幕:如何看待layui 官网将于 2021年10月13日 进行下线?
  14. 64位系统装32位mysql有问题吗_32位系统部署到64位下常见问题及解决
  15. html中按钮怎么设置渐变色,CSS3渐变色按钮
  16. 图片添加水印及打印文件
  17. ThinkPHP5.0+七牛云SDK文件上传
  18. FPC软排线结构的奥秘
  19. 雨听 | 英语学习笔记(五)~作文范文:学生退学
  20. DataBinding原理----单向数据绑定(3)

热门文章

  1. linux查询服务器cpu核数_查看linux服务器CPU数量
  2. 如何修改网游服务器,定期修改网游服务器密码确保数据安全
  3. Ubuntu16.04安装卸载Kinetic
  4. 【科普】Xilinx 3D IC技术简介
  5. 应用启动失败,因为没有QT平台可以初始化
  6. ERROR: flag ‘flagfile‘ was defined more than once
  7. php 虚拟机速度慢,[译]PHP虚拟机(PHP Virtual Machine)
  8. GBase 8s灾备集群HAC介绍
  9. jQuery的模糊匹配
  10. 11-15ov9281双摄-应用运行命令