PXE 伺服器 - 啟動客戶端需求的廣播連接埠限制

PXE 伺服器 - 啟動客戶端需求的廣播連接埠限制

我想將我的 PXE 伺服器設定為正確的 IP 位址,僅適用於請求網路啟動的用戶端。

因此,我在不同範圍內使用 2 個 IP 位址配置了我的網路介面卡。 192.168.1.19是在/24上廣播的通用網絡

對於 PXE 伺服器啟動,我嘗試使用另一組 IP 將其與網路配置的其餘部分分開。因此,伺服器在 /24 上有第二個 IP 192.168.0.19 廣播,僅適用於 2 個 IP 範圍。 (最多 2 台電腦一起使用 PXE 啟動)

# cat /etc/network/interfaces
iface enp5s0 inet static
address 192.168.1.19
netmask 255.255.255.0
gateway 192.168.1.1

iface enp5s0:1 inet static
address 192.168.0.19
netmask 255.255.255.0

重點是,只有請求啟動的電腦才應該擁有這 2 個 IP 之一。儘管如此,它租用它並且不會釋放它,即使在重新啟動後也是如此。我必須在客戶端上手動重置網路。即使這樣,有時它也會得到相同的 IP。它很窄,因為我的路由器設定在192.168.1.1。我認為它應該優先考慮相同的範圍。

如果用戶端上停用網路啟動,它應該從通用網路範圍取得 IP 以取得檔案共用和其他 LAN 服務。如果它已打開,則應該只獲取一個用於 PXE 引導配置的信息,並在完成後釋放。

第二次測試使其正常工作:

我一直在測試使此配置適用於網域解析反而。在這裡你會發現我目前的網路設定以及其他細節:

root@lubuton:~# service dnsmasq restart
root@lubuton:~# service dnsmasq status
● dnsmasq.service - dnsmasq - A lightweight DHCP and caching DNS server
     Loaded: loaded (/lib/systemd/system/dnsmasq.service; enabled; vendor preset: enabled)
     Active: active (running) since Sun 2022-06-19 09:30:18 CEST; 8s ago
    Process: 75253 ExecStartPre=/etc/init.d/dnsmasq checkconfig (code=exited, status=0/SUCCESS)
    Process: 75261 ExecStart=/etc/init.d/dnsmasq systemd-exec (code=exited, status=0/SUCCESS)
    Process: 75270 ExecStartPost=/etc/init.d/dnsmasq systemd-start-resolvconf (code=exited, status=0/SUCCESS)
   Main PID: 75269 (dnsmasq)
      Tasks: 1 (limit: 18871)
     Memory: 652.0K
        CPU: 38ms
     CGroup: /system.slice/dnsmasq.service
             └─75269 /usr/sbin/dnsmasq -x /run/dnsmasq/dnsmasq.pid -u dnsmasq -7 /etc/dnsmasq.d,.dpkg-dist,.dpkg-old,.dpkg-new --local-service --trust-anchor=.,20326,8,2,e06d44b80b8f1d39a95c0b0d7c65d08458e88040>

Jun 19 09:30:18 lubuton dnsmasq-dhcp[75269]: DHCP, IP range 192.168.2.31 -- 192.168.2.40, lease time 1h
Jun 19 09:30:18 lubuton dnsmasq-dhcp[75269]: DHCP, IP range 192.168.2.21 -- 192.168.2.30, lease time 1h
Jun 19 09:30:18 lubuton dnsmasq-dhcp[75269]: DHCP, IP range 192.168.2.11 -- 192.168.2.20, lease time 1h
Jun 19 09:30:18 lubuton dnsmasq-dhcp[75269]: DHCP, IP range 192.168.2.2 -- 192.168.2.10, lease time 1h
Jun 19 09:30:18 lubuton dnsmasq-dhcp[75269]: DHCP, sockets bound exclusively to interface enp5s0
Jun 19 09:30:18 lubuton dnsmasq-tftp[75269]: TFTP root is /srv/tftp
Jun 19 09:30:18 lubuton dnsmasq[75269]: reading /etc/resolv.conf
Jun 19 09:30:18 lubuton dnsmasq[75269]: using nameserver 127.0.0.53#53
Jun 19 09:30:18 lubuton dnsmasq[75269]: read /etc/hosts - 7 addresses
Jun 19 09:30:18 lubuton systemd[1]: Started dnsmasq - A lightweight DHCP and caching DNS server.
lines 1-23/23 (END)
root@lubuton:~# service tftpd-hpa status
● tftpd-hpa.service - LSB: HPA's tftp server
     Loaded: loaded (/etc/init.d/tftpd-hpa; generated)
     Active: active (running) since Sun 2022-06-19 03:27:58 CEST; 6h ago
       Docs: man:systemd-sysv-generator(8)
      Tasks: 1 (limit: 18871)
     Memory: 392.0K
        CPU: 6ms
     CGroup: /system.slice/tftpd-hpa.service
             └─17162 /usr/sbin/in.tftpd --listen --user tftp --address 192.168.2.1:69 --secure --create /srv/tftp

Jun 19 03:27:58 lubuton systemd[1]: Starting LSB: HPA's tftp server...
Jun 19 03:27:58 lubuton tftpd-hpa[17154]:  * Starting HPA's tftpd in.tftpd
Jun 19 03:27:58 lubuton tftpd-hpa[17154]:    ...done.
Jun 19 03:27:58 lubuton systemd[1]: Started LSB: HPA's tftp server.

客戶端:PXE-E53: No bootfilename recieved

您可以在這裡找到我的預設網路配置。這是/etc/dnsmasq.d/pxe.conf我用來設定 PXE 伺服器的:

interface=enp5s0,lo
bind-interfaces
log-dhcp
dhcp-host=pxe.home.lan,192.168.2.1
dhcp-range=enp7s4f0,192.168.2.2,192.168.2.10
dhcp-range=enp7s4f1,192.168.2.11,192.168.2.20
dhcp-range=enp8s6f0,192.168.2.21,192.168.2.30
dhcp-range=enp8s6f1,192.168.2.31,192.168.2.40
dhcp-match=set:efi-x86_64,option:client-arch,7
dhcp-boot=tag:efi-x86_64,bootx64.efi,pxelinux.0
enable-tftp
tftp-root=/srv/tftp

我認為我不了解 PXE 網路對 IP 範圍和子網路的需求。

重點是我會使用這個 PXE 來幫助人們恢復/修復/安裝/重新安裝他們的作業系統。

我的家庭網路 192.168.1.0/24 應保持私有。我的 PXE 網路應該共用最後一個網路中的互聯網,並允許連接到連接到 ISP 路由器的 enp5s0 之外的所有其他介面上的用戶端;到 PXE bootp 服務。

如果我理解正確的話,PXE 只能在 WAN IP 範圍內運作?

我忘了提及:

  • 我希望我的網路中的所有電腦都保留在 LAN IP 上,以使 samba 安全性不是基於用戶,而是基於 LAN 限制。

  • 我可以自動提供與 enp5s0 相同範圍內的 IP,因為這與路由器 IP 租約衝突。所以我嘗試把它放在192.168.2.0/24上。

有可能嗎?

我在 pxe.conf 中的最後一個配置共享互聯網,在啟動時向客戶端提供 IP,但沒有發送文件。

interface=enp5s0,lo
bind-interfaces
log-dhcp
dhcp-host=pxe.home.lan,192.168.2.1
dhcp-range=192.168.2.2,192.168.2.40
dhcp-match=set:efi-x86_64,option:client-arch,7
dhcp-boot=tag:efi-x86_64,bootx64.efi,pxelinux.0
enable-tftp
tftp-root=/srv/tftp

答案1

我不認為你的計劃會按照你想要的方式進行。由 PXE 啟動的作業系統通常會進行自己的 DHCP 網路設定。來自第二個網路設定的 DHCP 用戶端資料包可能不包含 PXE 選項。

但是,當然可以使用 PXE 選項來偵測 DHCP 用戶端封包。這是一種常見方法,因此可以動態提供 PXE 回應選項。可以執行的操作取決於所使用的 DHCP 服務。

isc-dhcp-server這是DHCP 服務的範例設定。它將為 PXE 客戶端提供不同的池。它不提供您想要的單獨子網,但它可能會進行調整。

class "pxeclient" {
    match if substring (option vendor-class-identifier, 0, 9) = "PXEClient";
    filename "pxelinux.0";
}

subnet 192.168.1.0 netmask 255.255.255.0
{
    option routers 192.168.1.1;
    next-server 192.168.1.1;
    max-lease-time 3600;

    pool {
        range 192.168.1.100 192.168.1.109;
        allow members of "pxeclient";
        }

    pool {
        range 192.168.1.110 192.168.1.119;
        allow unknown-clients;
        }
}

另一種常見的 DHCP 服務是dnsmasq.這是一個範例配置,其作用與上面相同。

log-dhcp
dhcp-option=3,192.168.1.1
dhcp-match=set:pxe,60,PXEClient
dhcp-boot=tag:pxe,pxelinux.0,server,192.168.1.1
dhcp-range=tag:pxe,192.168.1.100,192.168.1.109,255.255.255.0,1h
dhcp-range=tag:!pxe,192.168.1.110,192.168.1.119,255.255.255.0,1h

其他有趣的主題包括

  • 基於 PXE 用戶端架構的 PXE 回應選項(例如 BIOS 與 UEFI)
  • proxyDHCP服務(dnsmasq支援此功能)

有用的網址

相關內容