Ubuntu 安装 dhcp-server
- 安装 sudo apt-get install isc-dhcp-server
- nano /etc/default/isc-dhcp-server
NTERFACES="DHCP用的网卡"
添加网段 /etc/dhcp/dhcpd.conf
#subnet 10.152.187.0 netmask 255.255.255.0 {
# 172.16.x.x
subnet 172.16.0.0 netmask 255.255.0.0 {
range 172.16.1.1 172.16.9.253;
option domain-name-servers 114.114.114.114 , 8.8.8.8;
option domain-name "my.com";
option subnet-mask 255.255.0.0;
option routers 172.16.0.100;
option broadcast-address 172.16.0.255;
default-lease-time 3600;
max-lease-time 7200;
log-facility local7;
}
- 启动服务
sudo systemctl enable isc-dhcp-server
sudo systemctl restart isc-dhcp-server
- DHCP list
cat /var/lib/dhcp/dhcpd.leases
dhcp-lease-list --lease /var/lib/dhcp/dhcpd.leases