首先安裝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