文档章节

DHCP服务器配置----转

柳白子
 柳白子
发布于 2016/10/13 15:38
字数 825
阅读 19
收藏 0
DHCP:Dynamic Host Configuration Protocol前身是bootp
lease:租约
续租:租约到一半的时候就要申请续租
广播:第一个响应的服务器
广播申请,广播响应
广播回复确认


IP:
MASK:
GATEWAY:
DNS:

Client----->DHCPDISCOVER
			DHCPOFER<--------Server
Client----->DHCPREQUEST
            DHCPACK<-----Server
以上都广播报文


续租:
Client----->DHCPREQUEST
			DHCPACK<-------Server
以上为单播

DHCP不能跨网段进行

需要配置路由器的DHCP-RELAY,DHCP中继


DHCP分配的网段要在某一个网卡的地址在同一网段内
[root@salt-master ~]# yum install dhcp
Loaded plugins: fastestmirror
Setting up Install Process
Loading mirror speeds from cached hostfile
iso                                                                                                                                                                 | 3.7 kB     00:00     
Not using downloaded repomd.xml because it is older than what we have:
  Current   : Mon May 23 07:51:24 2016
  Downloaded: Sun May 22 13:52:33 2016
Resolving Dependencies
--> Running transaction check
---> Package dhcp.x86_64 12:4.1.1-51.P1.el6.centos will be installed
--> Finished Dependency Resolution

Dependencies Resolved

===========================================================================================================================================================================================
 Package                                Arch                                     Version                                                       Repository                             Size
===========================================================================================================================================================================================
Installing:
 dhcp                                   x86_64                                   12:4.1.1-51.P1.el6.centos                                     iso                                   823 k

Transaction Summary
===========================================================================================================================================================================================
Install       1 Package(s)

Total download size: 823 k
Installed size: 1.9 M
Is this ok [y/N]: y
Downloading Packages:
dhcp-4.1.1-51.P1.el6.centos.x86_64.rpm                                                                                                                              | 823 kB     00:00     
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Warning: RPMDB altered outside of yum.
  Installing : 12:dhcp-4.1.1-51.P1.el6.centos.x86_64                                                                                                                                   1/1 
  Verifying  : 12:dhcp-4.1.1-51.P1.el6.centos.x86_64                                                                                                                                   1/1 

Installed:
  dhcp.x86_64 12:4.1.1-51.P1.el6.centos                                                                                                                                                    

Complete!
[root@salt-master ~]# rpm -ql dhcp
/etc/dhcp
/etc/dhcp/dhcpd.conf
/etc/dhcp/dhcpd6.conf
/etc/openldap/schema/dhcp.schema
/etc/portreserve/dhcpd
/etc/rc.d/init.d/dhcpd
/etc/rc.d/init.d/dhcpd6
/etc/rc.d/init.d/dhcrelay
/etc/rc.d/init.d/dhcrelay6
/etc/sysconfig/dhcpd
/etc/sysconfig/dhcpd6
/etc/sysconfig/dhcrelay
/etc/sysconfig/dhcrelay6
/usr/bin/omshell
/usr/sbin/dhcpd
/usr/sbin/dhcrelay
/usr/share/doc/dhcp-4.1.1
/usr/share/doc/dhcp-4.1.1/3.0b1-lease-convert
/usr/share/doc/dhcp-4.1.1/IANA-arp-parameters
/usr/share/doc/dhcp-4.1.1/README.ldap
/usr/share/doc/dhcp-4.1.1/api+protocol
/usr/share/doc/dhcp-4.1.1/dhclient-tz-exithook.sh
/usr/share/doc/dhcp-4.1.1/dhcpd-conf-to-ldap
/usr/share/doc/dhcp-4.1.1/dhcpd.conf.sample
/usr/share/doc/dhcp-4.1.1/dhcpd6.conf.sample
/usr/share/doc/dhcp-4.1.1/draft-ietf-dhc-ldap-schema-01.txt
/usr/share/doc/dhcp-4.1.1/ms2isc
/usr/share/doc/dhcp-4.1.1/ms2isc/Registry.perlmodule
/usr/share/doc/dhcp-4.1.1/ms2isc/ms2isc.pl
/usr/share/doc/dhcp-4.1.1/ms2isc/readme.txt
/usr/share/doc/dhcp-4.1.1/sethostname.sh
/usr/share/doc/dhcp-4.1.1/solaris.init
/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
/var/lib/dhcpd
/var/lib/dhcpd/dhcpd.leases
/var/lib/dhcpd/dhcpd6.lease

[root@salt-master ~]# cp /usr/share/doc/dhcp-4.1.1/dhcpd.conf.sample /etc/dhcp/dhcpd.conf 
cp: overwrite `/etc/dhcp/dhcpd.conf'? y

DHCP-Server:UDP/67
DHCP-Client:UDP/68
[root@salt-master ~]# vim /etc/dhcp/dhcpd.conf 

option domain-name "uplooking.com";
option domain-name-servers 192.168.1.200;
default-lease-time 600;
max-lease-time 7200;
log-facility local7;
subnet 192.168.1.0 netmask 255.255.255.0 {
        option routers          192.168.1.1;
        option subnet-mask      255.255.255.0;
        option time-offset      -18000;
        range 192.168.1.220 192.168.1.223;
        default-lease-time 21600;
        max-lease-time 43200;
}
[root@salt-master ~]# /etc/init.d/dhcpd start
Starting dhcpd:                                            [  OK  ]
[root@salt-master ~]# netstat -anutlp|grep dhcp
udp        0      0 0.0.0.0:67                  0.0.0.0:*                               2085/dhcpd 

找一台服务器由于多个dhcp的存在他可能不会选则自己的服务器或者你想给服务器指定IP地址
[root@salt-master ~]# vim /etc/dhcp/dhcpd.conf 

option domain-name "uplooking.com";
option domain-name-servers 192.168.1.200;
default-lease-time 600;
max-lease-time 7200;
log-facility local7;
subnet 192.168.1.0 netmask 255.255.255.0 {
        option routers          192.168.1.1;
        option subnet-mask      255.255.255.0;
        option time-offset      -18000;
        range 192.168.1.223 192.168.1.224;
        default-lease-time 21600;
        max-lease-time 43200;
        host ns2 {
                hardware ethernet 00:0C:29:38:1E:F7;
                fixed-address 192.168.1.201;
        }
}
添加host选项
注意这个地址一定部在range的范围之内
另外有专用的话等级比自动分配要高



客户端
[root@salt-master ~]# dhclient -h
Internet Systems Consortium DHCP Client 4.1.1-P1
Copyright 2004-2010 Internet Systems Consortium.
All rights reserved.
For info, please visit https://www.isc.org/software/dhcp/
Usage: dhclient [-4|-6] [-SNTP1dvrx] [-nw] [-p <port>] [-s server]
                [-cf config-file] [-lf lease-file][-pf pid-file] [-e VAR=val]
                [-I <dhcp-client-identifier>] [-B]
                [-H <host-name> | -F <fqdn.fqdn>] [-timeout <timeout>]
                [-V <vendor-class-identifier>]
                [-R <request option list>]
                [-sf script-file] [interface]
客户端直接
dhclient命令就可以用了手动获取dhcp分配地址
dhclient -d选项工作在前台

© 著作权归作者所有

共有 人打赏支持
柳白子
粉丝 8
博文 118
码字总数 137799
作品 0
成都
私信 提问
路由器DHCP和DHCP中继的配置

路由器 DHCP和DHCP中继的配置 路由器作为DHCP服务器: 1.配置router的地址:Route(config)# hostname gateway (更改主机名字) Gateway(config)# interface gigabitethernet 0/0 Gateway(conf...

技术小胖子
2017/11/14
0
0
AP1242G胖转瘦,廋转胖

无线AP1242G胖转瘦 准备工作:console线接上,网线接上。 ap>en password:Cisco ap#config t ap(config)#inter BVI1 可以在BVI1接口上配置一个固定ip,在实际使用中发现如果配置为固定ip地址...

xuchenghui88
2012/06/14
0
0
DHCP协议及在路由器上配置方法

DHCP概述 动态主机配置协议(DHCP) 是一种帮助网络管理员管理及自动分配IP地址及配置参数的.在不使用DHCP的情况下,管理员必须手动为每台终端配置IP地址/子网掩码/网关,等IP配置,在大型的网络中...

乌龟漫步
2016/12/09
0
0
88、交换机安全欺骗攻击配置实验之DHCP Snooping

1、DHCP Snooping解析 开启DHCP Snooping后,默认所有的端口都为untrusted接口。 untrusted接口:可以接收Discovery消息,但当收到Offer消息后,会直接Drop掉,不发任何DHCP消息。 trusted接...

技术小胖子
2017/11/17
0
0
centos7安装dhcp服务器并由客户端动态获取IP地址

主机架构: dhcp服务器配置: a. 安装软件: b. 更改配置文件:vim /etc/dhcp/dhcpd.conf c. 启动服务: 客户端服务器配置: a. 修改网卡配置文件:vim /etc/sysconfig/network-scripts/ifcf...

科技小能手
2017/11/12
0
0

没有更多内容

加载失败,请刷新页面

加载更多

pg_lightool基于basebackup的单表恢复和块恢复

开源软件pg_lightool,实现了基于wal日志的块恢复。详情参见博客:https://my.oschina.net/lcc1990/blog/1931485。由于wal日志中FPW的不确定性,它不能作为一个数据库恢复的解决方案。目前对...

movead
20分钟前
2
0
对比剖析Swarm Kubernetes Marathon编排引擎

Docker Native Orchestration 基本结构 Docker Engine 1.12 集成了原生的编排引擎,用以替换了之前独立的Docker Swarm项目。Docker原生集群(Swarm)同时包括了(Docker Engine \/ Daemons)...

Linux就该这么学
21分钟前
2
0
Mybatis的结果集处理

此时我们已经可以把整段的SQL语句取出,但还并没有在数据库中去执行,我们可以先来分析一下配置文件中SQL语句执行后的结果集是如何处理的。 Mybatis会将结果集按照映射配置文件中定义的映射规...

算法之名
34分钟前
19
0
Spring Boot(Spring的自动整合框架)

Spring Boot 是一套基于Spring框架的微服务框架,由于Spring是一个轻量级的企业开发框架,主要功能就是用于整合和管理其他框架,想法是将平时主流使用到的框架的整合配置预先写好,然后通过简...

花漾年华
37分钟前
2
0
Windows下条件变量的实现

条件变量是什么? 是一种同步对象。 条件变量有什么用? 用于复杂的、多线程的、多核的程序中,实现多个线程间同步任务。 条件变量与其它同步对象的区别? 与事件、互斥锁、segment等同步对象...

shzwork
38分钟前
1
1

没有更多内容

加载失败,请刷新页面

加载更多

返回顶部
顶部