目录

DHCP

DHCP(Dynamic Host Configuration Protocol,动态主机配置协议)是一个局域网的网络协议(计算机网络应用层协议 ),使用UDP协议工作。

主要有两个用途:给内部网络或ISP(网络服务供应商)自动分配IP地址,给用户或者内部网络管理员作为对所有计算机作中央管理的手段。通常被应用在大型的局域网络环境中,主要作用是集中管理、分配IP地址,使网络环境中的主机动态的获得IP地址、Gateway地址、DNS服务器地址等信息,并能够提升地址的使用率。

DHCP协议采用客户端/服务器模型,主机地址的动态分配任务由网络主机(Client)驱动。当DHCP服务器接收到来自网络主机申请地址的信息时,才会向网络主机发送相关的地址配置等信息,以实现网络主机地址信息的动态配置。DHCP有3个端口,其中UDP 67(DHCPServer)和UDP 68(DHCPClient)为正常的DHCP服务端口;546号端口用于DHCPv6 Client,而不用于DHCPv4,是为DHCP failover服务,这是需要特别开启的服务,DHCP failover是用来做“双机热备”的。

DHCP Relay

DHCP Relay(DHCPR):DHCP中继服务,也叫做DHCP中继代理可以实现在不同子网和物理网段之间处理和转发dhcp信息的功能。如果DHCP客户机与DHCP服务器在同一个物理网段,则客户机可以正确地获得动态分配的ip地址。如果不在同一个物理网段,则需要DHCP Relay Agent(中继代理)。用DHCP Relay代理可以去掉在每个物理的网段都要有DHCP服务器的必要,它可以传递消息到不在同一个物理子网的DHCP服务器,也可以将服务器的消息传回给不在同一个物理子网的DHCP客户机。

Setup DHCPServer

Software: dhcp.x86.64

ServiceName: dhcpd

step1. Install dhcp

yum install -y dhcpd

step2. Service config file (DHCPServer use static IP)

cp /usr/share/doc/dhcp-4.1.1/dhcp.conf.sample /etc/dhcp/dhcpd.conf

vim /etc/dhcp/dhcpd.conf

#one networkSegment one subnet
subnet subnetIPsegment netmask subnetNetmask{
range addressPool
option domain-name-servers DNS1,DNS2
option domain-name "domain.org" #default domain
option routes routesIP
default-lease-time leaseTime
max-lease-time leaseTime
}

step3. Start DHCP server

service dhcpd start
netstat -lpntu | grep :67 #Ensure the DHCP service start successfully

Setup ClientPort

We can check the leaseFile,URL: /var/lib/dhcpd/dhcpd.leases

可以在dhcpd.conf中设定,当client使用同一个IP到了租约的50%的时候,会再次的向DHCPServer发出请求要求续租,若此时DHCPServer关闭,ClientPort会有80%的时候再次发出请求要求续约。若达到了100%时间还没有得到DHCPServer的续约回应,则Client会再次的广播要求获取新的IP地址。如果网段中没有DHCPServer,HOST会为自己分配IP 169.254.0.0。

DHCP+DHCPRelay

Generally DHCPrelay and DHCP will bond in one server.Realize one DHCPServer satisfy more IP request of different networkSegment.DHCPRelayServer will receive the IP request of different networkSegment then give it to DHCP server deal with.

service:dchrelay

Setup DHCPRelay service

step1. We need three networkCard and delete VMware own dhcp service. And set the static ip for networkCard.

step2. Open system forward function.

vim /etc/sysctl.conf

net.ipv4.ip_forward = 1

Load sysctl configuration

sysctl -p

step3. Set relay interface and DHCPServer IP.

vim /etc.sysconfig/dhcrelay

INTERFACES="eth0 eth1 eth2"  #Relay interfacee
DHCPSERVERS="DHCPServerIP"

step4. Start dhcprelay service

service dhcrelay start

step5. Add three subnetSetting in the DHCPServer config file with /etc/dhcp/dhcpd.conf and restart service of dhcpd.

step6. Setup the static route rules in the DHCPServer.

Because the DHCPServer’s gatewayIP need assign to the internel gateway, so the DHCPRelayServer have to assign the route rules that the different subnetSegment computer can find the DHCPServer subnet interface.

For example:

route add -net subnet1SegmentPool gw DHCPServerSegmentInterfaceIP
#subnet1SegmentPool eg: 192.168.2.0/24
route add -net subnet2SegmentPool gw DHCPServerSegmentInterfaceIP
route -n #check the route rules.

step7. Check the route relay

ping -C 1 otherSubnetSegmentIP

Attantion:General DHCPServer’s gateway assign to the internel GatewayServer, so need to set the static route rules that DHCPServer can send the response to DHCPServerSubnetSegmentInterface then other subnetSegment will give the DHCPServer’s response.

Linux_DHCP&DHCP Relay的更多相关文章

  1. DHCP Relay 简介

    DHCP Relay(DHCPR)DHCP中继 也叫做DHCP中继代理 如果DHCP客户机与DHCP服务器在同一个物理网段,则客户机可以正确地获得动态分配的ip地址.如果不在同一个物理网段,则需要DH ...

  2. How to Use DHCP Relay over LAN? - DrayTek Corp

    Assuming Vigor2960 has two LAN networks. Network Administrator wants that, when the internal DHCP is ...

  3. VyOS 关于dhcp server 和dhcp relay 切换需要注意的

    dhcp server : /config/dhcpd.leases dhcp relay 两个dhcp 模式切换需要删除这个配置文件

  4. DHCP、DHCP Snooping及DHCP relay工作原理入门及实践(转)

    原文https://blog.51cto.com/5167020/2312718 序:DHCP服务相对简单,写本文的目的是为了讲一些DHCP安全方面的技术. 1.DHCP基础 DHCP 全称动态主机配 ...

  5. 配置DHCP Relay的功能原理是什么?

    DHCP中继代理,就是在DHCP服务器和客户端之间转发DHCP数据包.当DHCP客户端与服务器不在同一个子网上,就必须有DHCP中继代理来转发DHCP请求和应答消息.DHCP中继代理的数据转发,与通常 ...

  6. 思科交换机配置DHCP的四个方面

    这里我们主要讲解了思科交换机配置DHCP的相关内容.我们对网络拓扑先进行一下了解,然后对于其在进行一下说明,之后对于配置的代码和命令再进行一下解析. 思科交换机配置DHCP一.网络拓扑 思科交换机配置 ...

  7. linux下DHCP服务原理总结

    DHCP(全称Dynamic host configuration protocol):动态主机配置协议DHCP工作在OSI的应用层,可以帮助计算机从指定的DHCP服务器获取配置信息的协议.(主要包括 ...

  8. DHCP的若干原理解释

    转自:http://blog.chinaunix.net/uid-22287947-id-1775641.html 搜罗了几种关于dhcp的原理和过程解释 DHCP(Dynamic Host Conf ...

  9. H3C dhcp 中继

    需求描述RT1作为DHCP服务器创建两个全局地址池:192.168.10.0/24 192.168.20.0/24 RT1和RT3属于VLAN 10 RT2属于VLAN 20 在交换机上配置DHCP中 ...

随机推荐

  1. 清理Windows图标缓存 | 懒人屋

    原文:清理Windows图标缓存 | 懒人屋 文章背景 这是一个抄袭的文章,原文在参考资料中 运行环境 操作系统:Windows 10 x64(1903) 清理脚本 @echo off rem 关闭W ...

  2. [译]送给 ES6 开发者的7个 hack

    关注原来的 JavaScript hacks,上面有一些新的好东西.2018 使用 JavaScript 写代码真的又变得有意思了! Hack #1 — 交换变量 使用数组结构来交换值 let a = ...

  3. Android模拟器运行慢的解决方案

    在android开发的过程,发现android模拟器的速度不是一般的慢,那主要是因为android模拟器默认采用的是arm处理器造成的,这里主要提供两种方法: ① 利用intel虚拟硬件加速的方式,实 ...

  4. 42. Trapping Rain Water (JAVA)

    Given n non-negative integers representing an elevation map where the width of each bar is 1, comput ...

  5. Mysql逻辑架构介绍

    总体概览: 和其它数据库相比,MySQL有点与众不同,它的架构可以在多种不同场景中应用并发挥良好作用.主要体现在存储引擎的架构上,插件式的存储引擎架构将查询处理和其它的系统任务以及数据的存储提取相分离 ...

  6. 原生JS滚动条位置处理

    // 滚动条位置 var scrollPosition = { // 位置 result: 0, // 监听位置 rememberPosition: function () { var type = ...

  7. centos 安装代理服务 proxy server squild

    以下内容复制自https://blog.csdn.net/qingfengxulai/article/details/80853870 放置此处便于检索 1 安装 sudo yum install s ...

  8. PHP程序员要看的书单

    想提升自己,还得多看书!多看书!多看书! 下面是我收集到的一些PHP程序员应该看得书单及在线教程,自己也没有全部看完.共勉吧! Github地址:https://github.com/52fhy/ph ...

  9. 【JavaScript】DOM之BOM

    BOM 1.BOM是什么 提供了独立页面内容,与浏览器相关的一系列对象,管理窗口之间通信 2.Window对象 具有双重角色,对象即是允许JS访问浏览器窗口的一个对象,和ECMAScript规范中的G ...

  10. java调用存储过程的方式

    1.问号是入参和出参,出参要指定类型 CallableStatement pstmt = conn.prepareCall("{call dbo.UP_CodeUp_***(?,?,?,?, ...