Ubuntu 20.04 上的 ISCP-DHCP 服务器,连接到 RaspberryPi

Ubuntu 20.04 上的 ISCP-DHCP 服务器,连接到 RaspberryPi

我无法使用静态 IP 和现有无线网络连接到 raspberryPi。我的下一个尝试是在我的 Ubuntu 机器上设置 DHCP 服务器。我使用了几个教程 (tut1tut2_german),但无法让服务器运行。我的安装步骤:

安装 isc-dhcp 服务器

sudo apt 安装 isc-dhcp-服务器

立即将有线连接设置为手动

在此处输入图片描述

配置 dhcp 服务器

纳米/etc/dhcp/dhcpd.conf

# a simple /etc/dhcp/dhcpd.conf
default-lease-time 600;
max-lease-time 7200;
authoritative;

subnet 192.168.4.0 netmask 255.255.255.0 {
 range 192.168.4.100 192.168.4.200;
 option routers 192.168.4.1;
 option domain-name-servers 192.168.4.1, 192.168.4.2;
 option domain-name "rpi.example";
}

host archmachine {
hardware ethernet b8:27:eb:4d:6c:1c;
fixed-address 192.168.4.20;
}

添加 dhcp 服务器接口(以太网-USB 加密狗)

nano /etc/default/isc-dhcp-服务器

# 
INTERFACES="enx9cebe82d8042"

启动\重新启动 ics-dhcp 的各种命令

sudo systemctl start isc-dhcp-server.service
sudo systemctl enable isc-dhcp-server.service
sudo systemctl restart isc-dhcp-server.service

结果

sudo systemctl status isc-dhcp-server.service

产生一个我无法解释的错误

● 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-04-24 19:00:27 CEST; 5s ago
       Docs: man:dhcpd(8)
    Process: 114920 ExecStart=/bin/sh -ec      CONFIG_FILE=/etc/dhcp/dhcpd.conf;      if [ -f /etc/ltsp/dhcpd.conf ]; then CONFIG_FILE=/etc/ltsp/dhcpd.conf; >
   Main PID: 114920 (code=exited, status=1/FAILURE)

Apr 24 19:00:27 MEpc dhcpd[114920]: 
Apr 24 19:00:27 MEpc dhcpd[114920]: If you think you have received this message due to a bug rather
Apr 24 19:00:27 MEpc dhcpd[114920]: than a configuration issue please read the section on submitting
Apr 24 19:00:27 MEpc dhcpd[114920]: bugs on either our web page at www.isc.org or in the README file
Apr 24 19:00:27 MEpc dhcpd[114920]: before submitting a bug.  These pages explain the proper
Apr 24 19:00:27 MEpc dhcpd[114920]: process and the information we find helpful for debugging.
Apr 24 19:00:27 MEpc dhcpd[114920]: 
Apr 24 19:00:27 MEpc dhcpd[114920]: exiting.
Apr 24 19:00:27 MEpc systemd[1]: isc-dhcp-server.service: Main process exited, code=exited, status=1/FAILURE
Apr 24 19:00:27 MEpc systemd[1]: isc-dhcp-server.service: Failed with result 'exit-code'.

任务菜单中的有线连接也不断尝试连接。结果也是“有线网络失败”,尝试几次后会自动断开连接。

将“有线设置”更改为“手动”会导致连接状态。但我仍然不确定此 GUI 中的设置是否正确,或者当我在各种文件中更改网络设置时它是否会被忽略

在此处输入图片描述

更新

有些网站建议编辑 /network/interfaces。由于我没有 eth0,我将其更改为

auto enx9cebe82d8042  
iface enx9cebe82d8042 inet dhcp

我将有线设置更改为“手动”,至少现在已连接,而不是反复尝试连接某个东西。我还可以查看我的 /var/syslog

pr 25 07:26:32 stefanpc dhcpd[127702]: Copyright 2004-2018 Internet Systems Consortium.
Apr 25 07:26:32 stefanpc dhcpd[127702]: All rights reserved.
Apr 25 07:26:32 stefanpc dhcpd[127702]: For info, please visit https://www.isc.org/software/dhcp/
Apr 25 07:26:32 stefanpc dhcpd[127702]: Config file: /etc/dhcp/dhcpd.conf
Apr 25 07:26:32 stefanpc sh[127702]: Config file: /etc/dhcp/dhcpd.conf
Apr 25 07:26:32 stefanpc sh[127702]: Database file: /var/lib/dhcp/dhcpd.leases
Apr 25 07:26:32 stefanpc sh[127702]: PID file: /run/dhcp-server/dhcpd.pid
Apr 25 07:26:32 stefanpc dhcpd[127702]: Database file: /var/lib/dhcp/dhcpd.leases
Apr 25 07:26:32 stefanpc sh[127702]: Wrote 0 leases to leases file.
Apr 25 07:26:32 stefanpc dhcpd[127702]: PID file: /run/dhcp-server/dhcpd.pid
Apr 25 07:26:32 stefanpc dhcpd[127702]: Wrote 0 leases to leases file.
Apr 25 07:26:32 stefanpc dhcpd[127702]: 
Apr 25 07:26:32 stefanpc sh[127702]: No subnet declaration for enx9cebe82d8042 (192.168.4.5).
Apr 25 07:26:32 stefanpc sh[127702]: ** Ignoring requests on enx9cebe82d8042.  If this is not what
Apr 25 07:26:32 stefanpc sh[127702]:    you want, please write a subnet declaration
Apr 25 07:26:32 stefanpc sh[127702]:    in your dhcpd.conf file for the network segment
Apr 25 07:26:32 stefanpc sh[127702]:    to which interface enx9cebe82d8042 is attached. **
Apr 25 07:26:32 stefanpc sh[127702]: Not configured to listen on any interfaces!
Apr 25 07:26:32 stefanpc sh[127702]: If you think you have received this message due to a bug rather
Apr 25 07:26:32 stefanpc sh[127702]: than a configuration issue please read the section on submitting
Apr 25 07:26:32 stefanpc sh[127702]: bugs on either our web page at www.isc.org or in the README file
Apr 25 07:26:32 stefanpc sh[127702]: before submitting a bug.  These pages explain the proper
Apr 25 07:26:32 stefanpc sh[127702]: process and the information we find helpful for debugging.
Apr 25 07:26:32 stefanpc sh[127702]: exiting.
Apr 25 07:26:32 stefanpc dhcpd[127702]: No subnet declaration for enx9cebe82d8042 (192.168.4.5).
Apr 25 07:26:32 stefanpc dhcpd[127702]: ** Ignoring requests on enx9cebe82d8042.  If this is not what
Apr 25 07:26:32 stefanpc dhcpd[127702]:    you want, please write a subnet declaration
Apr 25 07:26:32 stefanpc dhcpd[127702]:    in your dhcpd.conf file for the network segment
Apr 25 07:26:32 stefanpc dhcpd[127702]:    to which interface enx9cebe82d8042 is attached. **
Apr 25 07:26:32 stefanpc dhcpd[127702]: 
Apr 25 07:26:32 stefanpc dhcpd[127702]: 
Apr 25 07:26:32 stefanpc dhcpd[127702]: Not configured to listen on any interfaces!
Apr 25 07:26:32 stefanpc dhcpd[127702]: 
Apr 25 07:26:32 stefanpc dhcpd[127702]: If you think you have received this message due to a bug rather
Apr 25 07:26:32 stefanpc dhcpd[127702]: than a configuration issue please read the section on submitting
Apr 25 07:26:32 stefanpc dhcpd[127702]: bugs on either our web page at www.isc.org or in the README file
Apr 25 07:26:32 stefanpc dhcpd[127702]: before submitting a bug.  These pages explain the proper
Apr 25 07:26:32 stefanpc dhcpd[127702]: process and the information we find helpful for debugging.
Apr 25 07:26:32 stefanpc dhcpd[127702]: 
Apr 25 07:26:32 stefanpc dhcpd[127702]: exiting.
Apr 25 07:26:32 stefanpc systemd[1]: isc-dhcp-server.service: Main process exited, code=exited, status=1/FAILURE
Apr 25 07:26:32 stefanpc systemd[1]: isc-dhcp-server.service: Failed with result 'exit-code'.

此处此行十分突出

enx9cebe82d8042 (192.168.4.5) 没有子网声明 ** 忽略 enx9cebe82d8042 上的请求。如果这不是您想要的,请在 dhcpd.conf 文件中为网络段写入子网声明

这表明不允许使用 USB 加密狗。使用知识产权生成以下界面

: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: wlp2s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether 00:21:5c:b6:21:e6 brd ff:ff:ff:ff:ff:ff
    inet 192.168.0.175/24 brd 192.168.0.255 scope global dynamic noprefixroute wlp2s0
       valid_lft 84869sec preferred_lft 84869sec
    inet6 fe80::a6f6:95e5:e050:d8a/64 scope link noprefixroute 
       valid_lft forever preferred_lft forever
14: enx9cebe82d8042: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 9c:eb:e8:2d:80:42 brd ff:ff:ff:ff:ff:ff
    inet 192.168.4.5/24 brd 192.168.4.255 scope global noprefixroute enx9cebe82d8042
       valid_lft forever preferred_lft forever
    inet6 fe80::9eeb:e8ff:fe2d:8042/64 scope link 
       valid_lft forever preferred_lft forever

这里的数字 14 是外部加密狗,推测名称为“enx9cebe82d8042”。

USB 以太网适配器是否不允许托管 DHCP 服务器?我在 dhcpd.conf 中的哪里声明接口?

相关内容