Ubuntu

Hetzner Cloud 上的 Ubuntu 全盤加密在 initramfs 中添加靜態路由

  • January 31, 2021

我嘗試在 Hetzner Cloud 之上設置具有全盤加密的 Ubuntu。除了 initramfs 中的網路連接之外,我得到了一切工作。感謝 UI 控制台,它可以解鎖,但我需要在 init 中使用 SSH (dropbear)。我在他們的根伺服器上成功地使用了相同的配置,沒有任何問題。

如果我設置 dropbear 以通過 dhcp 獲取 IP 總是導致NETWORK IS UNREACHABLE. 但它從 dhcp 伺服器獲取正確的參數。我問了 Hetzner 支持。他們告訴我他們認為 dhcp 客戶端不支持 RFC 3442 無類靜態路由選項,並建議使用ip r a 172.31.1.1 dev ens3. 就像在這個問題上一樣,我添加了路線,但總是遇到同樣的錯誤:NETWORK IS UNREACHABLE。我測試了在不同的腳本中設置路由,但沒有任何改變。我測試了 Ubuntu 16.04 和 18.04。

我很高興有任何關於此的建議。謝謝!

對於那些遇到此執行緒的人:

至少在 Debian Stretch 中,更通用的配置(不會因包更新而中斷)有效。我們只是在 init-premount 中使用腳本靜態配置網路:

vi /etc/initramfs-tools/scripts/init-premount/static-routes

#!/bin/sh 
# /etc/initramfs-tools/scripts/init-premount/static-routes

# to avoid race condition
# we have to wait until the automatic network configuration via dhcp
# is finished
sleep 15

ip a add 192.168.0.18/32 dev eth0
ip route add 192.168.178.1 dev eth0
ip route add default via 192.168.178.1 dev eth0

exit 0

chmod 755 /etc/initramfs-tools/scripts/init-premount/static-routes

引用自:https://serverfault.com/questions/915118