在我的 Ubuntu 20 台式机上,我使用 Wifi 上网,因此我的 LAN 接口是免费的。所以我想将它用作 DHCP 服务器接口。
eno1: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
ether b4:2e:19:c6:73:57 txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 449 bytes 37227 (37.2 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 449 bytes 37227 (37.2 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
wlp5s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.1.99 netmask 255.255.255.255 broadcast 0.0.0.0
inet6 fe80::c148:f87a:baf:8027 prefixlen 64 scopeid 0x20<link>
ether 90:cc:df:93:d7:08 txqueuelen 1000 (Ethernet)
RX packets 2324 bytes 222866 (222.8 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 1903 bytes 348600 (348.6 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
以下是我的/etc/default/isc-dhcp-server
:
INTERFACESv4="eno1"
INTERFACESv6=""
以下是我的/etc/dhcp/dhcpd.conf
:
ddns-update-style none;
default-lease-time 600;
allow bootp;
allow booting;
subnet 10.0.0.0 netmask 255.255.255.0 {
range 10.0.0.100 10.0.0.200;
option subnet-mask 255.255.255.0;
option routers 10.0.0.1;
default-lease-time 600;
max-lease-time 7200;
#option root-path "/home/naveen/rootfs-arm64/“; #provided by boot.scr.img
}
host hikey {
hardware ethernet 34:29:8f:70:06:d0;
fixed-address 10.0.0.225;
#option root-path "/home/naveen/rootfs-arm64/“; #provided by boot.scr.img
}
以下是我的/etc/network/interfaces
:
auto lo
iface lo inet loopback
auto eno1
iface eno1 inet static
address 10.0.0.1
netmask 255.255.255.0
但我仍然收到错误:
● isc-dhcp-server.service - ISC DHCP IPv4 server
Loaded: loaded (/lib/systemd/system/isc-dhcp-server.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Sun 2022-01-30 23:28:03 IST; 13s ago
Docs: man:dhcpd(8)
Process: 1606 ExecStart=/bin/sh -ec CONFIG_FILE=/etc/dhcp/dhcpd.conf; if [ -f /etc/ltsp/dhcpd.conf ]; then CONFIG_FILE=/etc/ltsp/dhcpd.conf; fi; [ -e /var/lib/dhcp/dhcpd.leases ] || touc>
Main PID: 1606 (code=exited, status=1/FAILURE)
Jan 30 23:28:03 lab dhcpd[1606]:
Jan 30 23:28:03 lab dhcpd[1606]: Not configured to listen on any interfaces!
Jan 30 23:28:03 lab dhcpd[1606]:
Jan 30 23:28:03 lab dhcpd[1606]: If you think you have received this message due to a bug rather
Jan 30 23:28:03 lab dhcpd[1606]: than a configuration issue please read the section on submitting
Jan 30 23:28:03 lab dhcpd[1606]: bugs on either our web page at www.isc.org or in the README file
Jan 30 23:28:03 lab dhcpd[1606]: before submitting a bug. These pages explain the proper
Jan 30 23:28:03 lab dhcpd[1606]: process and the information we find helpful for debugging.
Jan 30 23:28:03 lab dhcpd[1606]:
Jan 30 23:28:03 lab dhcpd[1606]: exiting.
答案1
您需要配置 eno1 接口。由于 Ubuntu 20 使用 netplan,您可以在 /etc/netplan 中找到您的配置。您应该在那里添加类似以下内容:
eno1:
addresses:
- 10.0.0.1/24
dhcp4: false