安装 isc-dhcp-server
apt install isc-dhcp-server
使用 ens38 网卡做为dhcp server的服务接口,先配置一个IP地址192.168.1.1
修改 /etc/dhcp/dhcpd.conf 配置子网
# dhcpd.conf # # Sample configuration file for ISC dhcpd # # Attention: If /etc/ltsp/dhcpd.conf exists, that will be used as # configuration file instead of this file. # subnet 192.168.1.0 netmask 255.255.255.0 { range 192.168.1.100 192.168.1.200; default-lease-time 600; max-lease-time 7200; option subnet-mask 255.255.255.0; option domain-name-servers ns1.internal.example.org; option domain-name "internal.example.org"; option broadcast-address 192.168.1.255; option routers 192.168.1.1; option domain-name-servers 114.114.114.114, 8.8.8.8; option domain-name "isc.org"; }
修改 /etc/default/isc-dhcp-server 中的 接口变量
INTERFACESv4="ens38"
此时启动 isc-dhcp-server
systemctl restart isc-dhcp-server
我这启动失败了,是 /lib/systemd/system/isc-dhcp-server.service 启动命令有错误,修改完的如下
[Unit] Description=ISC DHCP IPv4 server Documentation=man:dhcpd(8) Wants=network-online.target After=network-online.target After=time-sync.target ConditionPathExists=/etc/default/isc-dhcp-server ConditionPathExists=|/etc/ltsp/dhcpd.conf ConditionPathExists=|/etc/dhcp/dhcpd.conf [Service] EnvironmentFile=/etc/default/isc-dhcp-server RuntimeDirectory=dhcp-server # The leases files need to be root:dhcpd even when dropping privileges ExecStart=/bin/sh -ec '\ CONFIG_FILE=/etc/dhcp/dhcpd.conf; \ rm /var/lib/dhcp/dhcpd.leases && touch /var/lib/dhcp/dhcpd.leases; \ chown root:dhcpd /var/lib/dhcp /var/lib/dhcp/dhcpd.leases; \ chmod 775 /var/lib/dhcp ; chmod 664 /var/lib/dhcp/dhcpd.leases; \ if test -n "$INTERFACES" -a -z "$INTERFACESv4"; then INTERFACESv4="$INTERFACES"; fi; \ exec dhcpd -user dhcpd -group dhcpd -f -4 -pf /run/dhcp-server/dhcpd.pid -cf $CONFIG_FILE $INTERFACESv4' [Install] WantedBy=multi-user.target
修改完之后,执行 systemctl daemon-reload 重新加载文件,在执行 systemctl restart isc-dhcp-server
在windows虚拟机中获取ip地址
原文链接:https://blog.csdn.net/wjmasd/article/details/130756920
© 版权声明
声明📢本站内容均来自互联网,归原创作者所有,如有侵权必删除。
本站文章皆由CC-4.0协议发布,如无来源则为原创,转载请注明出处。
THE END