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 / 问题 / 776343
Accepted
user212827
user212827
Asked: 2024-05-13 05:06:02 +0800 CST2024-05-13 05:06:02 +0800 CST 2024-05-13 05:06:02 +0800 CST

systemd networkd 可以配置为网络启动、PXE 启动吗?如果可以,如何配置?

  • 772

如果我理解这个“问题” (systemd-networkd DHCP 服务器忽略 SendOptions #15780),则可以配置 SystemD 来处理网络启动。但是,我无法找到有关该功能的更多信息。

我目前使用的是配置最少的 DHCPD 服务器,如果可以将其移动到 DHCPD 服务器就好了systemd-networkd,它可以处理我的环境中的所有其他网络功能。

# /etc/dhcpd.conf
allow booting; # How is this defined in systemd-networkd?
allow bootp;   # How is this defined in systemd-networkd?

# If this DHCP server is the official DHCP server for the local
# network, the authoritative directive should be uncommented.
authoritative; # How is this defined in systemd-networkd?

option architecture code 93 = unsigned integer 16; # I think this corresponds to SendOption=93:uint16:architecture

host client_computer {
  hardware ethernet a1:b2:c3:d4:e5:f6; # This should be captured with [Match] MACAddress=a1:b2:c3:d4:e5:f6

  fixed-address 192.168.1.101; # I think this corresponds to something like SendOption=???:ipv4address:192.168.1.101
  next-server 192.168.1.100; # This should be defines as [Network] Address?

  option host-name "clientname"; # I think this corresponds to something like SendOption=12:string:clientname
  option root-path "/srv/tftp";  # I think this corresponds to something like SendOption=17:string:/srv/tftp

  if option architecture = 00:07 {
    filename "grub/x86_64-efi/core.efi"; # I think this corresponds to SendOption=67:string:grub/x86_64-efi/core.efi
  }
  else {
    filename "grub/i396-pc/core.0"; # I think this corresponds to SendOption=67:string:grub/i396-pc/core.0
  }
}

看来我需要“选项”代码,但是在哪里可以找到它们?有规格吗? - 找到他们 :)

  • 动态主机配置协议 (DHCP) 和引导协议 (BOOTP) 参数

SystemD NetworkD文档。

到目前为止我所拥有的:

#allow booting; = ? # Not necessary?
#allow bootp;   = ? # Not necessary?
#authoritative; = ? # Not necessary?

[Match]
MACAddress=a1:b2:c3:d4:e5:f6

[Network]
DHCP=no
DHCPServer=true

Address=192.168.1.100/24 # DHCP server IP

[DHCPv4]
ClientIdentifier=mac

[DHCPServer]
PoolOffset=3
PoolSize=7

BootServerAddress=192.168.1.100/24

#SendOption=93:uint16:architecture # Failed to parse DHCP uint16 data, ignoring assignment: architecture # Not necessary?

#SendOption=???:ipv4address:192.168.1.101

SendOption=12:string:clientname # 12 "Hostname"

SendOption=17:string:/srv/tftp  # 17 "Root Path"

# BootFilename=grub/i396-pc/core.0 # Sane as code 67
# SendOption=67:string:grub/x86_64-efi/core.efi
SendOption=67:string:grub/i396-pc/core.0

[DHCPServerStaticLease]
MACAddress=a1:b2:c3:d4:e5:f6
Address=192.168.1.101


更新#1

使用tcpdump -i <INTERFACE> -nn -s0 -v -A udp port 67我可以看到 SystemD NetworkD DCHP 服务器正在与客户端交互!

但是,系统无法启动,问题似乎是未将预期的静态 IP 地址分配给客户端。

该[DHCPServerStaticLease]部分似乎没有效果。我在 <= 253 中发现了一些有关错误的信息systemctl --version,并添加了解决方法ClientIdentifier=mac。不过,这应该不是必需的,因为我运行的是 255 版本。

  • DHCP 服务器未将静态 IP 地址分配给 systemd-networkd 网桥的某个接口上的主机

哦,我添加了Pool*参数,但 DHCP 服务器仍然分配相同的 IP (192.168.1.242)。

linux
  • 1 1 个回答
  • 26 Views

1 个回答

  • Voted
  1. Best Answer
    user212827
    2024-05-13T22:52:43+08:002024-05-13T22:52:43+08:00

    答案是肯定的!以下配置对我有用。

    [Match]
    Name=<NETWORKD DEVICE NAME>
    
    [Network]
    DHCP=yes                        # Required
    DHCPServer=true                 # Required
    
    IPForward=yes                   # Required if to pass traffic from client
    IPMasquerade=both               # Required if to pass traffic from client
    
    Address=192.168.1.100/24        # Required
    
    #[DHCPv4]                       # Was not necessary
    #ClientIdentifier=mac           # Was not necessary
    
    [DHCPServer]
    
    #PoolOffset=100                 # Not necessaary
    #PoolSize=1                     # Not necessaary
    
    BootServerAddress=192.168.1.100 # Required
    
    # Hostname=                     # Forgot to test but should be same as code 12
    SendOption=12:string:clientname # optional
    
    # 17 "Root Path"
    SendOption=17:string:/srv/tftp  # Required
    
    # I do not know how to select between EFI and i386 depending on the client.
    # Comment out the one required. EFI worked for me.
    
    # EFI
    BootFilename=/srv/tftp/grub/x86_64-efi/core.efi # Required; providing full path but relative path should work? Forgot to test.
    #SendOption=67:string:grub/x86_64-efi/core.efi   # Should be the same as BootFilename  
    
    # i386
    #SendOption=67:string:grub/i396-pc/core.0
    #BootFilename=grub/i396-pc/core.0
    
    [DHCPServerStaticLease]
    MACAddress=a1:b2:c3:d4:e5:f6
    Address=192.168.1.101
    

    陷阱

    • 累的时候不要这样做:)
    • networkctl reload更改配置后
    • 禁用任何其他非 SystemD DHCP 服务器
    • NetworkD conf 文件:例如,不要在与指定值相同的行上进行注释Address=192.168.1.100/24 # My Server
    • 0

相关问题

  • 有没有办法让 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