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 / 问题 / 456763
Accepted
grorel
grorel
Asked: 2018-07-18 05:23:54 +0800 CST2018-07-18 05:23:54 +0800 CST 2018-07-18 05:23:54 +0800 CST

新的 IP 地址,而 DHCP 租用时间未到

  • 772

我的嵌入式系统使用 systemd 并通过 DHCP 获取其 IP 地址。如果遵守租用时间,DHCP 服务器使用租用时间为网络上的每台计算机提供相同的 IP 唯一地址。

我的嵌入式系统的网络配置如下:

/etc/systemd/network/dhcp.network

[Match]
Name=eth*

[Network]
DHCP=yes

问题是每次启动时,我都会在系统上获得一个新的 IP 地址。我缺少一些配置吗?

更多信息:

$ cat /proc/version
Linux version 4.16.0 ([email protected]) (gcc version 7.3.0 (Buildroot 2018.05-g0164235-dirty)) #18 SMP PREEMPT Tue Jul 17 14:28:37 CEST 2018  

[编辑] 添加 DHCP 发现包

Frame 13299: 327 bytes on wire (2616 bits), 327 bytes captured (2616 bits) on interface 0  
    Interface id: 0 (\\.\pipe\Shamrock_Wireshark_TAP__30815)  
    Encapsulation type: Ethernet (1)  
    Arrival Time: Jul 16, 2018 10:39:49.166800000 Paris, Madrid (heure d??t?)  
    [Time shift for this packet: 0.000000000 seconds]  
    Epoch Time: 1531730389.166800000 seconds  
    [Time delta from previous captured frame: 20.554641000 seconds]  
    [Time delta from previous displayed frame: 43.658782000 seconds]  
    [Time since reference or first frame: 43.770160000 seconds]  
    Frame Number: 13299  
    Frame Length: 327 bytes (2616 bits)  
    Capture Length: 327 bytes (2616 bits)  
    [Frame is marked: False]  
    [Frame is ignored: False]  
    [Protocols in frame: eth:ethertype:ip:udp:bootp]  
    [Coloring Rule Name: UDP]  
    [Coloring Rule String: udp]  
Ethernet II, Src: AlstomGr_20:00:6f (80:b3:2a:20:00:6f), Dst: Broadcast (ff:ff:ff:ff:ff:ff)  
    Destination: Broadcast (ff:ff:ff:ff:ff:ff)  
        Address: Broadcast (ff:ff:ff:ff:ff:ff)  
        .... ..1. .... .... .... .... = LG bit: Locally administered address (this is NOT the factory default)  
        .... ...1 .... .... .... .... = IG bit: Group address (multicast/broadcast)  
    Source: AlstomGr_20:00:6f (80:b3:2a:20:00:6f)  
        Address: AlstomGr_20:00:6f (80:b3:2a:20:00:6f)  
        .... ..0. .... .... .... .... = LG bit: Globally unique address (factory default)  
        .... ...0 .... .... .... .... = IG bit: Individual address (unicast)  
    Type: IPv4 (0x0800)
Internet Protocol Version 4, Src: 0.0.0.0, Dst: 255.255.255.255  
    0100 .... = Version: 4  
    .... 0101 = Header Length: 20 bytes  
    Differentiated Services Field: 0xc0 (DSCP: CS6, ECN: Not-ECT)  
        1100 00.. = Differentiated Services Codepoint: Class Selector 6 (48)  
        .... ..00 = Explicit Congestion Notification: Not ECN-Capable Transport (0)  
    Total Length: 313  
    Identification: 0x0000 (0)  
    Flags: 0x00  
        0... .... = Reserved bit: Not set  
        .0.. .... = Don't fragment: Not set  
        ..0. .... = More fragments: Not set  
    Fragment offset: 0  
    Time to live: 64  
    Protocol: UDP (17)  
    Header checksum: 0x78f5 [validation disabled]  
        [Good: False]  
        [Bad: False]  
    Source: 0.0.0.0  
    Destination: 255.255.255.255  
    [Source GeoIP: Unknown]  
    [Destination GeoIP: Unknown]  
User Datagram Protocol, Src Port: 68 (68), Dst Port: 67 (67)  
    Source Port: 68  
    Destination Port: 67  
    Length: 293  
    Checksum: 0xca77 [validation disabled]  
        [Good Checksum: False]  
        [Bad Checksum: False]  
    [Stream index: 0]   
Bootstrap Protocol (Discover)  
    Message type: Boot Request (1)  
    Hardware type: Ethernet (0x01)  
    Hardware address length: 6  
    Hops: 0  
    Transaction ID: 0x240b826b  
    Seconds elapsed: 1  
    Bootp flags: 0x0000 (Unicast)  
        0... .... .... .... = Broadcast flag: Unicast  
        .000 0000 0000 0000 = Reserved flags: 0x0000  
    Client IP address: 0.0.0.0  
    Your (client) IP address: 0.0.0.0  
    Next server IP address: 0.0.0.0  
    Relay agent IP address: 0.0.0.0  
    Client MAC address: AlstomGr_20:00:6f (80:b3:2a:20:00:6f)  
    Client hardware address padding: 00000000000000000000  
    Server host name not given  
    Boot file name not given  
    Magic cookie: DHCP  
    Option: (53) DHCP Message Type (Discover)  
        Length: 1  
        DHCP: Discover (1)  
    Option: (61) Client identifier  
        Length: 19  
        IAID: cd4578d2  
        DUID Type: assigned by vendor based on Enterprise number (2)  
        Enterprise-number: Tom Gundersen (systemd) (43793)  
        Identifier: 871468cb35ae1ddc  
    Option: (55) Parameter Request List  
        Length: 8  
        Parameter Request List Item: (1) Subnet Mask  
        Parameter Request List Item: (3) Router  
        Parameter Request List Item: (12) Host Name  
        Parameter Request List Item: (15) Domain Name  
        Parameter Request List Item: (6) Domain Name Server  
        Parameter Request List Item: (33) Static Route  
        Parameter Request List Item: (121) Classless Static Route  
        Parameter Request List Item: (42) Network Time Protocol Servers  
    Option: (57) Maximum DHCP Message Size  
        Length: 2  
        Maximum DHCP Message Size: 576  
    Option: (12) Host Name  
        Length: 4  
        Host Name: RPH4  
    Option: (255) End  
        Option End: 255
systemd dhcp
  • 1 1 个回答
  • 1075 Views

1 个回答

  • Voted
  1. Best Answer
    telcoM
    2018-07-18T07:42:25+08:002018-07-18T07:42:25+08:00

    DHCP Discover 数据包包含一个 RFC 4361 样式的客户端标识符(选项 61,也称为 DUID)和systemd企业号 (43793)。这是因为您的/etc/systemd/network/dhcp.network文件不包含ClientIdentifiernorDUIDType设置;默认值为ClientIdentifier=duid和 DUIDType=vendor。

    DUIDType=vendor默认设置会导致使用上述systemd-networkd企业编号和/etc/machine-id. 应该在系统首次启动时生成,然后machine-id在系统的生命周期(或至少在操作系统安装的生命周期)内保持不变。

    如果您的嵌入式系统未配置为machine-id持久存储它,它将在每次启动时随机生成......这将导致您看到的行为。

    如果您不需要您的系统使用符合 IPv6 的 DUID 标识符,最简单的解决方法是指定该系统应使用其 MAC 地址作为 DHCP 客户端标识符。这可以通过将其添加到您的dhcp.network文件来实现:

    [DHCP]
    ClientIdentifier=mac
    

    如果您也在使用 DHCPv6,和/或您需要使用特定于系统而不是特定 NIC 的标识符来识别您的 DHCP 客户端,那么您应该阅读网络配置文件的文档systemd并找到设置的组合适合您的需求。

    • 5

相关问题

  • 将默认编辑器更改为 vim for _ sudo systemctl edit [unit-file] _

  • systemd:如何在服务启动时运行脚本,而不编辑服务定义

  • 使用 systemd 看门狗支持重新启动应用程序

  • 为什么我的交换机没有从指定的池中获取地址

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

Sidebar

Stats

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

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

    • 4 个回答
  • Marko Smith

    ssh 无法协商:“找不到匹配的密码”,正在拒绝 cbc

    • 4 个回答
  • Marko Smith

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

    • 5 个回答
  • Marko Smith

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

    • 3 个回答
  • Marko Smith

    如何卸载内核模块“nvidia-drm”?

    • 13 个回答
  • 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
    rocky 如何将 GPG 私钥和公钥导出到文件 2018-11-16 05:36:15 +0800 CST
  • Martin Hope
    Wong Jia Hau ssh-add 返回:“连接代理时出错:没有这样的文件或目录” 2018-08-24 23:28:13 +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
  • Martin Hope
    Bagas Sanjaya 为什么 Linux 使用 LF 作为换行符? 2017-12-20 05:48:21 +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