首先安装isc-dhcp-server
apt-get install isc-dhcp-server
然后编辑配置文件,选择需要开启dhcp服务器的网卡
vi /etc/default/isc-dhcp-server
INTERFACES="eth0"
配置DHCP
vi /etc/dhcp/dhcpd.conf
subnet 192.168.1.0 netmask 255.255.255.0 {
option routers 192.168.1.1;
option subnet-mask 255.255.255.0;
range dynamic-bootp 192.168.1.2 192.168.1.254;
}
设置该网卡为静态ip
vi /etc/dhcpcd.conf
iface eth0 inet static
address 192.168.1.1
netmask 255.255.255.0
gateway 192.168.1.1
重启
reboot