「ISC DHCP」

  CREATED BY JENKINSBOT
DHCP

DHCP服务端口是UDP 67和UDP 68,这两个端口是正常的DHCP服务端口,可以理解为一个发送,一个接收。

DHCP failover

546 端口为DHCP failover服务,他是需要特别开启的服务,一般情况下如果你不开启他是不会有546端口的,
DHCP failover是用来做“双机热备”,比如:你有两台服务器,一台出现故障了,那一台可以继续接力不影响正常工作,我们也称“热备份”

官网:https://www.isc.org/

链接:ftp://ftp.isc.org/isc/dhcp/4.3.4/dhcp-4.3.4.tar.gz

编译:

0x02、内核需要支持 Packet socket:

Networking support —> [CONFIG_NET]

Networking options —>
<*> Packet socket [CONFIG_PACKET]

0x03、内核开启 IPv6支持:

Networking support —> [CONFIG_NET]

Networking Options —>
<*> The IPv6 Protocol —> [CONFIG_IPV6]

(如果没有 IPv6 支持,在源码目录下执行 patch,patch -Np1 -i dhcp-4.3.4-missing_ipv6-1.patch)

0x04、编译

patch -Np1 -i ../dhcp-4.3.4-client_script-1.patch &&
CFLAGS=”-D_PATH_DHCLIENT_SCRIPT=’\”/sbin/dhclient-script\”‘ \

-D_PATH_DHCPD_CONF=’\”/etc/dhcp/dhcpd.conf\”‘ \

-D_PATH_DHCLIENT_CONF=’\”/etc/dhcp/dhclient.conf\”‘” \

./configure –prefix=/usr \

–sysconfdir=/etc/dhcp \

–localstatedir=/var \

–with-srv-lease-file=/var/lib/dhcpd/dhcpd.leases \

–with-srv6-lease-file=/var/lib/dhcpd/dhcpd6.leases \

–with-cli-lease-file=/var/lib/dhclient/dhclient.leases \

–with-cli6-lease-file=/var/lib/dhclient/dhclient6.leases &&

make -j1

0x05、安装
如果只想安装客户端

make -C client install &&
mv -v /usr/sbin/dhclient /sbin &&
install -v -m755 client/scripts/linux /sbin/dhclient-script

如果只想安装服务端

make -C server install

安装完整的包:

make install &&
mv -v /usr/sbin/dhclient /sbin &&
install -v -m755 client/scripts/linux /sbin/dhclient-script
#安装的文件有:
dhclient: DHCP 客户端实现;
dhclient-script: dhclient 使用 dhclient-script 用来配置接口. 支持调用自定义的 dhclient-{entry,exit}-hooks 文件;
dhcpd: DHCP 和 BOOTP 的实现;
dhcrelay:(DHCP Relay agent) 在一个没有 DCHP 服务器的子网中,接受 DHCP 和 BOOTP 请求并传播给其他子网的 DHCP 服务器;
omshell: 通过 OMAPI(Object Management API),用于连接、查询、修改 DHCP Server 状态的交互终端

配置,分为客户端配置和服务端配置:

0x01、client 配置(man 5 dhclient.conf ):

cat > /etc/dhcp/dhclient.conf << “EOF”
#prepend domain-name-servers 127.0.0.1;
request subnet-mask, broadcast-address, time-offset, routers,

domain-name, domain-name-servers, domain-search, host-name,

netbios-name-servers, netbios-scope, interface-mtu,

ntp-servers;

require subnet-mask, domain-name-servers;

#timeout 60;

#retry 60;

#reboot 10;

#select-timeout 5;

#initial-interval 2;

EOF

#用来存储 dhclient 信息;
install -v -dm 755 /var/lib/dhclient

#动态获取 IP 地址
dhclient -v eth0

0x02、server 配置(man 5 dhcpd.conf):

cat > /etc/dhcp/dhcpd.conf << “EOF”
# Use this to enble / disable dynamic dns updates globally.
ddns-update-style none;

# option definitions common to all supported networks…
option domain-name “example.org”;
option domain-name-servers ns1.example.org, ns2.example.org;

default-lease-time 600;
max-lease-time 7200;

# 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;
}
EOF

#用于存储dhcp 服务器信息
install -v -dm 755 /var/lib/dhcpd