tigerhuang 发表于 2021-10-21 04:30:33

悬赏贴:如何通过dnsmasq实现bios和uefi双网启菜单

本帖最后由 tigerhuang 于 2021-10-21 10:26 编辑

赏金是不少于2年的免费科学上.网或我的800本论坛积分

我的ARM路由器上跑着FreshTomato系统(一种简化版的Linux系统),其内置的Dnsmasq版本号是2.85,Dnsmasq的配置部分可以任意添加内容。目前我已经可以通过更改路由器的Dnsmasq内容分别实现BIOS网启或UEFI网启,并且用FTP下载大的WinPE文件,现在想自动判断BIOS还是UEFI并实现网启。

要求:
1.自动判断pxe客户端是BIOS还是UEFI,
2.无论是BIOS还是UEFI网启,都能出现菜单,方便我以后添加启动项目
3.通过tftp读取配置文件后,然后通过FTP下载WinPE文件,不用HTTP是因为我的HTTP有其他用途,
4.能提供除WinPE外所有的配置模板文件,不需要我再去不同的地方到处找了。配置模板应该不会很大,如果本论坛不允许上载,可以上载到我的个人FTP服务器。

我目前的配置见附件,很简单,


lily9718 发表于 2021-10-21 06:10:15

帮顶

fenly 发表于 2021-10-21 08:59:57

等待赏金猎人

2011slkj 发表于 2021-10-21 09:17:06

顶个人气

2010hook 发表于 2021-10-21 18:39:29

要求增加到99年啊

mrzhonghb 发表于 2021-10-21 18:50:44

顶一下

shys 发表于 2021-10-23 11:09:36

哈哈 99年

未完成的歌 发表于 2022-1-8 12:38:05

我以前的帖子里面有

tigerhuang 发表于 2022-1-9 08:48:17

未完成的歌 发表于 2022-1-8 12:38
我以前的帖子里面有

以前的看过了,没找到.

2011liuyun 发表于 2022-1-9 22:18:59

本帖最后由 2011liuyun 于 2022-1-9 22:22 编辑

# Known working dnsmasq version 2.85 config for iPXE proxydhcp usage
# Debug logging
# log-debug

# Enable DHCP logging
log-dhcp

# Disable DNS server
port=0

# send disable multicast and broadcast discovery, and to download the boot file immediately
# DHCP_PXE_DISCOVERY_CONTROL, should be vendor option? Needs more understanding and source
dhcp-option=vendor:PXEClient,6,2b

# This range(s) is for the public interface, where dnsmasq functions
# as a proxy DHCP server providing boot information but no IP leases.
# Any ip in the subnet will do, so you may just put your server NIC ip here.
dhcp-range=172.16.6.211,proxy

interface=eth0
# bind-dynamic - remove interface and use this instead to listen everywhere?
# Disable re-use of the DHCP servername and filename fields as extra
# option space. That's to avoid confusing some old or broken DHCP clients.
dhcp-no-override

#dhcp-match=set:<tag>,<option number>|option:<option name>|vi-encap:<enterprise>[,<value>]
#dhcp-boot=<filename>,[<servername>[,<server address>|<tftp_servername>]]

# Based on logic in https://gist.github.com/robinsmidsrod/4008017
# iPXE sends a 175 option, checking suboptions
dhcp-match=set:ipxe-http,175,19
dhcp-match=set:ipxe-https,175,20
dhcp-match=set:ipxe-menu,175,39
# pcbios specific
dhcp-match=set:ipxe-pxe,175,33
dhcp-match=set:ipxe-bzimage,175,24
dhcp-match=set:ipxe-iscsi,175,17
# efi specific
dhcp-match=set:ipxe-efi,175,36
# combination
# set ipxe-ok tag if we have correct combination
# http && menu && iscsi ((pxe && bzimage) || efi)
tag-if=set:ipxe-ok,tag:ipxe-http,tag:ipxe-menu,tag:ipxe-iscsi,tag:ipxe-pxe,tag:ipxe-bzimage
tag-if=set:ipxe-ok,tag:ipxe-http,tag:ipxe-menu,tag:ipxe-iscsi,tag:ipxe-efi

#pxe-service=<CSA>,<menu text>[,<basename>|<bootservicetype>][,<server address>|<server_name>]
#pxe-prompt=<prompt>[,<timeout>]
# these create option 43 cruft, which is required in proxy mode
# TFTP IP is required on all dhcp-boot lines (unless dnsmasq itself acts as tftp server?)
pxe-service=tag:!ipxe-ok,X86PC,PXE,Boot/pcbios/ipxe.bios,172.16.6.211
pxe-service=tag:!ipxe-ok,IA32_EFI,PXE,Boot/efi/snponlyx32.efi,172.16.6.211
pxe-service=tag:!ipxe-ok,BC_EFI,PXE,Boot/efi/ipxe.efi,172.16.6.211
pxe-service=tag:!ipxe-ok,X86-64_EFI,PXE,Boot/efi/ipxe.efi,172.16.6.211

# later match overrides previous, keep ipxe script last
# server address must be non zero, but can be anything as long as iPXE script is not fetched over TFTP
# dhcp-boot=tag:ipxe-ok,http://boot.ipxe.org/demo/boot.php,,0.0.0.1
dhcp-boot=tag:ipxe-ok,Boot/init.txt,,172.16.6.211

# To use internal TFTP server enabled these, recommended is otherwise atftp
enable-tftp

我的配置文件 proxydhcp模式

2011liuyun 发表于 2022-1-9 22:23:23

# /etc/dnsmasq.conf

# Disable DNS Server
port=0

# Enable DHCP logging
log-dhcp

# Respond to PXE requests for the specified network;
# run as DHCP proxy
bind-interfaces
interface=eth0
dhcp-range=172.16.6.221,172.16.6.240,24h
dhcp-option=3,172.16.6.254
dhcp-option=6,172.16.1.11,172.16.1.12

dhcp-match=set:x86-32,option:client-arch,0
dhcp-boot=tag:x86-32,Boot/pcbios/ipxe.bios

dhcp-match=set:IA64,option:client-arch,2
dhcp-boot=tag:IA64,efi/ipxe-i386.efi

dhcp-match=set:efi-x86_32,option:client-arch,6
dhcp-boot=tag:efi-x86_32,efi/ipxe-i386.efi

dhcp-match=set:efi-x86_64,option:client-arch,7
dhcp-boot=tag:efi-x86_64,Boot/efi/ipxe.efi

dhcp-match=set:efi-x86_649,option:client-arch,9
dhcp-boot=tag:efi-x86_649,Boot/efi/ipxe.efi

dhcp-match=set:ipxe,175
dhcp-boot=tag:ipxe,Boot/init.txt

enable-tftp
tftp-root=/mnt/data/www

我的配置文件 dhcp模式
页: [1]
查看完整版本: 悬赏贴:如何通过dnsmasq实现bios和uefi双网启菜单