Loading

折腾PXE网络启动 pxe 双引导bios&uefi模式 OPENWRT

简介:

前两篇已经折腾了pxe引导bios和uefi,甭管启动的是啥,已经可以网络引导了。

但是同时面对这两种系统的时候怎么办?需要通过dhcp的参数来控制谁启动什么。

核心内容

RFC 4578: Dynamic Host Configuration Protocol (DHCP) Options for the Intel Preboot eXecution Environment (PXE) (rfc-editor.org)

RFC4578定义了architecture types,

Type  Architecture Name
----   -----------------
0    Intel x86PC
1    NEC/PC98
2    EFI Itanium
3    DEC Alpha
4    Arc x86
5    Intel Lean Client
6    EFI IA32
7    EFI BC
8    EFI Xscale
9    EFI x86-64

DHCP服务器可以根据这个来决定返回哪些信息给客户端。

 

TFTP ROOT

创建TFTP主目录,同时包含了bios,uefi的启动文件。

 发布TFTP主目录

 

 分别测试启动正常

 

BIOS & UEFI

tftpd就算了,它的DHCP太简单了。

现在的实验环境是openwrt的主路由,就打它的主意。

[OpenWrt Wiki] OpenWRT Multi-Arch TFTP boot  

它的示例文件是用别的引导的,我们先不考虑那么多,先引导我们的maxdos,grub4dos uefi。

一行一行敲肯定不舒服,写成shell脚本吧。 

修改参数:

tftp_root,TFTP发布主目录
filename='tag:bios,grldr'  bios启动文件
filename='tag:efi32,BOOTX64.EFI' uefi32启动文件,可以删除
filename='tag:efi64,BOOTX64.EFI' uefi64启动文件。
#!/bin/sh
uci set dhcp.@dnsmasq[0].logdhcp='1'
uci set dhcp.@dnsmasq[0].enable_tftp='1'
uci set dhcp.@dnsmasq[0].tftp_root='/etc/luci-uploads/tftp-root'
uci add dhcp match
uci set dhcp.@match[-1].networkid='bios'
uci set dhcp.@match[-1].match='60,PXEClient:Arch:00000'
uci add dhcp match
uci set dhcp.@match[-1].networkid='efi32'
uci set dhcp.@match[-1].match='60,PXEClient:Arch:00006'
uci add dhcp match
uci set dhcp.@match[-1].networkid='efi64'
uci set dhcp.@match[-1].match='60,PXEClient:Arch:00007'
uci add dhcp match
uci set dhcp.@match[-1].networkid='efi64'
uci set dhcp.@match[-1].match='60,PXEClient:Arch:00009'
uci add dhcp boot
uci set dhcp.@boot[-1].filename='tag:bios,grldr'
uci set dhcp.@boot[-1].serveraddress="$(uci get network.lan.ipaddr)"
uci set dhcp.@boot[-1].servername="$(uci get system.@system[0].hostname)"
uci add dhcp boot
uci set dhcp.@boot[-1].filename='tag:efi32,BOOTX64.EFI'
uci set dhcp.@boot[-1].serveraddress="$(uci get network.lan.ipaddr)"
uci set dhcp.@boot[-1].servername="$(uci get system.@system[0].hostname)"
uci add dhcp boot
uci set dhcp.@boot[-1].filename='tag:efi64,BOOTX64.EFI'
uci set dhcp.@boot[-1].serveraddress="$(uci get network.lan.ipaddr)"
uci set dhcp.@boot[-1].servername="$(uci get system.@system[0].hostname)"
uci commit dhcp
service dnsmasq reload

执行批处理,openwrt就可以根据客户端的类型,来分配不同的启动文件了。

 

BIOS抓包验证

MAC地址:08::::::B3

发现

包含93参数:0

提供

含参数66,67。

但是66写入了Next server IP address,67没有写入Boot file name。

请求

验证2.194是否被占用

接受

含参数66,67。

但是66写入了Next server IP address,67没有写入Boot file name。

UEFI

MAC地址:08::::::35

发现

包含93参数:7

 

提供

含参数66,67。

但是66写入了Next server IP address,67没有写入Boot file name。

请求

验证2.180是否被占用

接受

 总结

抓包没找到需要的东西,就要多解开几层,TFTP实验时,总是显示在第二层,下图的Next server ip address,Boot file name。

Openwrt Dnsmasq,又写在Option。虽然客户端都能解析,但是我看的时候还以为有什么错误,排查了两天。

 

 

主要参考资料

pxe 如何应对复杂的服务器硬件环境 | lvbibir's Blog

posted @ 2024-04-06 19:29  上官飞鸿  阅读(1970)  评论(0)    收藏  举报