Linux部署DHCP服务

Debian下使用docker镜像部署DHCP服务

拉取networkboot/dhcpd镜像

1
docker pull networkboot/dhcpd

新建data/dhcpd.conf文件

1
touch /data/dhcpd.conf

修改data/dhcpd.conf文件

1
2
3
4
5
6
subnet 204.254.239.0 netmask 255.255.255.224 {
option subnet-mask 255.255.0.0;
option domain-name "cname.nmslwsnd.com";
option domain-name-servers 8.8.8.8;
range 204.254.239.10 204.254.239.30;
}

修改/etc/network/interfaces

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
# The loopback network interface (always required)
auto lo
iface lo inet loopback

# Get our IP address from any DHCP server
auto dhcp 
iface dhcp inet static
address 204.254.239.0
netmask 255.255.255.224

获取帮助命令

1
docker run -it --rm networkboot/dhcpd man dhcpd.conf

运行DHCP服务

1
2
3
docker run -it --rm --init --net host -v "/data":/data networkboot/dhcpd <网卡名称>
# 示例
docker run -it --rm --init --net host -v "/data":/data networkboot/dhcpd dhcp