好物优选点击查看详情 京东购买

暂无内容

Ubuntu 配置DHCP server

Ubuntu 配置DHCP server插图

安装 isc-dhcp-server

apt install isc-dhcp-server

Ubuntu 配置DHCP server插图1

使用 ens38 网卡做为dhcp server的服务接口,先配置一个IP地址192.168.1.1

Ubuntu 配置DHCP server插图2

修改 /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

Ubuntu 配置DHCP server插图3

在windows虚拟机中获取ip地址

Ubuntu 配置DHCP server插图4

原文链接:https://blog.csdn.net/wjmasd/article/details/130756920

© 版权声明
THE END
喜欢就支持一下吧
点赞0 分享