iKuai爱快流控路由

标题: DHCP的功能加强一点点 [打印本页]

作者: xiaohhl    时间: 2023-11-14 20:44
标题: DHCP的功能加强一点点
本帖最后由 xiaohhl 于 2023-11-14 20:53 编辑

最近才了解到DHCP参数如此之多。官方人员也改善到很强大的程度了。现在发现还是有点需求未满足。这些功能主板都带,那说明需求是挺有用的

最好是能像OPENVPN一样,有个附加配置功能,这样可以避免经常修改或增加功能。具体需求(根据请求DHCP的附带参数而提供相应的dhcp-bootoption67】,说明如下
作者: xiaohhl    时间: 2023-11-14 20:46
https://wiki.archlinux.org/title/Dnsmasq
To simply send one file:

dhcp-boot=lpxelinux.0
To send a file depending on client architecture:

pxe-service=x86PC,"PXELINUX (BIOS)",bios/lpxelinux
pxe-service=X86-64_EFI,"PXELINUX (EFI)",efi64/syslinux.efi

In case pxe-service does not work to identify the architecture (especially for UEFI-based clients), combination of dhcp-match and dhcp-boot can be used. See RFC 4578 2.1 for more client-arch numbers for use with dhcp boot protocol.

dhcp-match=set:efi-x86_64,option:client-arch,7
dhcp-match=set:efi-x86_64,option:client-arch,9
dhcp-match=set:efi-x86,option:client-arch,6
dhcp-match=set:bios,option:client-arch,0
dhcp-boot=tag:efi-x86_64,efi64/syslinux.efi
dhcp-boot=tag:efi-x86,efi32/syslinux.efi
dhcp-boot=tag:bios,bios/lpxelinux.0
作者: xiaohhl    时间: 2023-11-14 20:47
(抄过来的)
https://www.jianshu.com/p/f9070d76892a
ipxe启动原理:
网卡在进行pxe启动时会进行第一次dhcp请求,并附带client-arch选项。如果系统使用普通bios模式启动,那么client-arch就是0;如果是x86 uefi启动,就是7或者9;如果是arm64 uefi启动,就是11。
dnsmasq会给为请求打上tag,例如dhcp-match=set:x64-uefi,option:client-arch,7,如果发现请求有这个tag,就推送对应的启动文件,例如dhcp-boot=tag:aarch64-uefi,ipxe-x86_64.efi。此时,主机就会使用tftp协议去下载ipxe,并且执行。
当ipxe开始运行后,ipxe会再次进行dhcp请求,并且带上参数175。dnsmasq收到这个请求后,会推送boot.ipxe,就是下面这两行:
dhcp-match=set:ipxe,175  dhcp-boot=tag:ipxe,boot.ipxe
而boot.ipxe就是ipxe的主配置文件。boot.ipxe里面还会引用其他配置文件,ipxe也将一一加载。
至此,ipxe已经成功加载并且获取到了配置文件。



作者: xiaohhl    时间: 2023-11-14 21:00
openwrt 只要在/etc/dnsmasq.conf下添加

dhcp-match=set:bios,option:client-arch,0
dhcp-match=set:x64-uefi,option:client-arch,7
dhcp-match=set:x64-uefi,option:client-arch,9
dhcp-match=set:aarch64-uefi,option:client-arch,11
dhcp-match=set:ipxe,175

dhcp-boot=tag:x64-uefi,ipxe-x86_64.efi
dhcp-boot=tag:bios,ipxegrldr
dhcp-boot=tag:aarch64-uefi,ipxe-x86_64.efi
dhcp-boot=tag:ipxe,ipxe-boot.ipxe

即可达到需求




欢迎光临 iKuai爱快流控路由 (https://bbs.ikuai8.com/) Powered by Discuz! X3.3