AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / unix / 问题 / 781803
Accepted
PhilBot
PhilBot
Asked: 2024-08-13 00:42:48 +0800 CST2024-08-13 00:42:48 +0800 CST 2024-08-13 00:42:48 +0800 CST

systemd-networkd DHCP 服务器无法为 DHCPv4 服务器实例配置地址池:数值结果超出范围

  • 772

我使用的是 systemd 网络版本 253.1。我的 Linux 5.15 机器上有 2 个以太网端口,我想在第二个端口上设置一个 DHCP 服务器。我已成功完成此操作,并为 eth1 进行了以下配置。

工作 DHCP 服务器配置:

[Match]
Name=eth1
Type=ether

[DHCPV4]
DUIDType=link-layer
ClientIdentifier=mac

[Network]
Address=172.1.17.1/24
DHCPServer=yes
#IPMasquerade=ipv4

[DHCPServer]
PoolOffset=1
PoolSize=8

现在,我想要将范围更改为以下内容:

[Match]
Name=eth1
Type=ether

[DHCPV4]
DUIDType=link-layer
ClientIdentifier=mac

[Network]
#
# 10.1.193.24/29
#
#  Network Address: 10.1.193.24
#  Usable IP Range: 10.1.193.25 - 10.1.193.30
#  Broadcast Address: 10.1.193.31
#
Address= 10.1.193.24/29
DHCPServer=yes
#IPMasquerade=ipv4

[DHCPServer]
PoolOffset=2
PoolSize=5

但是,我收到如下所示的错误:

[root@machine ~]$  networkctl status eth1 -l
* 3: eth1
                     Link File: n/a
                  Network File: /etc/systemd/network/eth1.network
                         State: routable (failed)
                  Online state: online
                          Type: ether
                          Path: platform-30bf0000.ethernet
              Hardware Address: 00:01:c0:37:6d:56 (Company, Ltd.)
                           MTU: 1500 (min: 46, max: 9000)
                         QDisc: mq
  IPv6 Address Generation Mode: eui64
      Number of Queues (Tx/Rx): 8/8
              Auto negotiation: yes
                         Speed: 1Gbps
                        Duplex: full
                          Port: tp
                       Address: 10.1.193.24
                                fe80::201:c0ff:fe37:6d56
             Activation Policy: up
           Required For Online: yes
             DHCP6 Client DUID: DUID-EN/Vendor:0000ab1180dd9f24e9435b570000
           Offered DHCP leases: none

Aug 12 14:33:07 machine systemd-networkd[654]: eth1: Received new foreign route (configured): dst: 10.1.193.24/29, src: n/a, gw: n/a, prefsrc: 10.1.193.24, scope: link, table: main(254), proto: kernel, type: unicast, nexthop: 0, priority: 0, flags: n/a
Aug 12 14:33:07 machine systemd-networkd[654]: eth1: Addresses set
Aug 12 14:33:07 machine systemd-networkd[654]: eth1: link_check_ready(): dynamic addresses or routes are not configured.
Aug 12 14:33:07 machine systemd-networkd[654]: eth1: Configuring DHCP Server.
Aug 12 14:33:07 machine systemd-networkd[654]: eth1: Failed to configure address pool for DHCPv4 server instance: Numerical result out of range
Aug 12 14:33:07 machine systemd-networkd[654]: eth1: Failed to configure DHCP server: Numerical result out of range
Aug 12 14:33:07 machine systemd-networkd[654]: eth1: Failed
Aug 12 14:33:07 machine systemd-networkd[654]: eth1: State changed: configuring -> failed
Aug 12 14:33:07 machine systemd-networkd[654]: eth1: LLDP Rx: Stopping LLDP client
Aug 12 14:33:07 machine systemd-networkd[654]: eth1: NDISC: Stopping IPv6 Router Solicitation client

我检查了各种 CIDR 计算器,我相信我的配置文件参数是有效的。

在此处输入图片描述

为什么 networkd 不接受我的配置文件?

linux
  • 1 1 个回答
  • 20 Views

1 个回答

  • Voted
  1. Best Answer
    larsks
    2024-08-13T05:35:55+08:002024-08-13T05:35:55+08:00

    我认为这里的问题是,这10.1.193.24是.0此 CIDR 范围的地址;这就像将地址分配192.168.1.0给网络上的主机一样192.168.1.0/24。许多系统将其视为广播地址。它似乎systemd-networkd不允许您将此地址分配给接口。

    以下配置对我来说很好用:

    [Match]
    Name=eth1
    Type=ether
    
    [DHCPV4]
    DUIDType=link-layer
    ClientIdentifier=mac
    
    [Network]
    Address=10.1.193.25/29
    DHCPServer=yes
    
    [DHCPServer]
    PoolOffset=2
    PoolSize=4
    

    请注意减少的池大小,因为服务器地址为 10.1.193.25 且偏移量为2,我们有以下可用地址:

    10.1.193.27
    10.1.193.28
    10.1.193.29
    10.1.193.30
    

    10.1.193.31是广播地址。

    提起这件事,我在日志中看到:

    Aug 12 21:35:26 localhost systemd-networkd[699]: eth1: Link UP
    Aug 12 21:35:26 localhost systemd-networkd[699]: eth1: Gained carrier
    Aug 12 21:35:26 localhost systemd-networkd[699]: eth1: found matching network '/etc/systemd/network/internal.network', based on potentially unpredictable interface name.
    Aug 12 21:35:27 localhost systemd-networkd[699]: eth1: Gained IPv6LL
    

    界面如下:

    3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
        link/ether 52:54:00:a6:d6:f9 brd ff:ff:ff:ff:ff:ff
        altname enp2s0
        inet 10.1.193.25/29 brd 10.1.193.31 scope global eth1
           valid_lft forever preferred_lft forever
        inet6 fe80::5054:ff:fea6:d6f9/64 scope link proto kernel_ll
           valid_lft forever preferred_lft forever
    

    正如预期的那样,如果我在这个网络上启动五台机器,其中四台能够成功获取 DHCP 租约:

    # tcpdump -i eth1 -nn port bootps or port bootpc
    21:51:12.762858 IP 0.0.0.0.68 > 255.255.255.255.67: BOOTP/DHCP, Request from 52:54:00:66:78:aa, length 282
    21:51:12.762990 IP 10.1.193.25.67 > 10.1.193.27.68: BOOTP/DHCP, Reply, length 279
    21:51:12.879438 IP 0.0.0.0.68 > 255.255.255.255.67: BOOTP/DHCP, Request from 52:54:00:9e:d6:aa, length 282
    21:51:12.879518 IP 10.1.193.25.67 > 10.1.193.26.68: BOOTP/DHCP, Reply, length 279
    21:51:13.334272 IP 0.0.0.0.68 > 255.255.255.255.67: BOOTP/DHCP, Request from 52:54:00:09:97:9b, length 276
    21:51:14.014954 IP 0.0.0.0.68 > 255.255.255.255.67: BOOTP/DHCP, Request from 52:54:00:44:0f:e6, length 282
    21:51:14.015032 IP 10.1.193.25.67 > 10.1.193.29.68: BOOTP/DHCP, Reply, length 279
    21:51:14.065205 IP 0.0.0.0.68 > 255.255.255.255.67: BOOTP/DHCP, Request from 52:54:00:c1:4f:c8, length 282
    21:51:14.065322 IP 10.1.193.25.67 > 10.1.193.28.68: BOOTP/DHCP, Reply, length 279
    21:51:15.568213 IP 0.0.0.0.68 > 255.255.255.255.67: BOOTP/DHCP, Request from 52:54:00:09:97:9b, length 276
    21:51:19.808546 IP 0.0.0.0.68 > 255.255.255.255.67: BOOTP/DHCP, Request from 52:54:00:09:97:9b, length 276
    21:51:28.489925 IP 0.0.0.0.68 > 255.255.255.255.67: BOOTP/DHCP, Request from 52:54:00:09:97:9b, length 276
    

    在上面的输出中,您可以看到Reply消息。地址处的主机52:54:00:09:97:9b无法获取租约,因为所有可用地址都已分配给其他主机。

    • 1

相关问题

  • 有没有办法让 ls 只显示某些目录的隐藏文件?

  • 使用键盘快捷键启动/停止 systemd 服务 [关闭]

  • 需要一些系统调用

  • astyle 不会更改源文件格式

  • 通过标签将根文件系统传递给linux内核

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    模块 i915 可能缺少固件 /lib/firmware/i915/*

    • 3 个回答
  • Marko Smith

    无法获取 jessie backports 存储库

    • 4 个回答
  • Marko Smith

    如何将 GPG 私钥和公钥导出到文件

    • 4 个回答
  • Marko Smith

    我们如何运行存储在变量中的命令?

    • 5 个回答
  • Marko Smith

    如何配置 systemd-resolved 和 systemd-networkd 以使用本地 DNS 服务器来解析本地域和远程 DNS 服务器来解析远程域?

    • 3 个回答
  • Marko Smith

    dist-upgrade 后 Kali Linux 中的 apt-get update 错误 [重复]

    • 2 个回答
  • Marko Smith

    如何从 systemctl 服务日志中查看最新的 x 行

    • 5 个回答
  • Marko Smith

    Nano - 跳转到文件末尾

    • 8 个回答
  • Marko Smith

    grub 错误:你需要先加载内核

    • 4 个回答
  • Marko Smith

    如何下载软件包而不是使用 apt-get 命令安装它?

    • 7 个回答
  • Martin Hope
    user12345 无法获取 jessie backports 存储库 2019-03-27 04:39:28 +0800 CST
  • Martin Hope
    Carl 为什么大多数 systemd 示例都包含 WantedBy=multi-user.target? 2019-03-15 11:49:25 +0800 CST
  • Martin Hope
    rocky 如何将 GPG 私钥和公钥导出到文件 2018-11-16 05:36:15 +0800 CST
  • Martin Hope
    Evan Carroll systemctl 状态显示:“状态:降级” 2018-06-03 18:48:17 +0800 CST
  • Martin Hope
    Tim 我们如何运行存储在变量中的命令? 2018-05-21 04:46:29 +0800 CST
  • Martin Hope
    Ankur S 为什么 /dev/null 是一个文件?为什么它的功能不作为一个简单的程序来实现? 2018-04-17 07:28:04 +0800 CST
  • Martin Hope
    user3191334 如何从 systemctl 服务日志中查看最新的 x 行 2018-02-07 00:14:16 +0800 CST
  • Martin Hope
    Marko Pacak Nano - 跳转到文件末尾 2018-02-01 01:53:03 +0800 CST
  • Martin Hope
    Kidburla 为什么真假这么大? 2018-01-26 12:14:47 +0800 CST
  • Martin Hope
    Christos Baziotis 在一个巨大的(70GB)、一行、文本文件中替换字符串 2017-12-30 06:58:33 +0800 CST

热门标签

linux bash debian shell-script text-processing ubuntu centos shell awk ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve