所以我正在為 KVM 虛擬機器運行一個開發伺服器。我有一個在主機節點上本地運行的 DHCP 伺服器,配置如下:
/etc/dhcp/dhcpd.conf
ddns-update-style none;
default-lease-time 600;
max-lease-time 7200;
log-facility local7;
option rfc3442-classless-static-routes code 121 = array of integer 8;
option ms-classless-static-routes code 249 = array of integer 8;
subnet xxx.xxx.x.0 netmask 255.255.255.0 {
range xxx.xxx.x.2 xxx.xxx.x.127;
option routers xxx.xxx.x.1;
option broadcast-address xxx.xxx.x.255;
option domain-name-servers 8.8.8.8;
option netbios-name-servers 8.8.8.8;
default-lease-time 86400;
max-lease-time 86400;
option rfc3442-classless-static-routes 24, xxx, xxx, x, 0, 0, 0, 0, 0, 0, xxx, xxx, x, 1;
option ms-classless-static-routes 24, xxx, xxx, x, 0, 0, 0, 0, 0, 0, xxx, xxx, x, 1;
host 102 {hardware ethernet 4A:19:BD:DF:B0:07;fixed-address xxx.xxx.x.5;}
}
/etc/default/isc-dhcp-伺服器
# Defaults for isc-dhcp-server initscript
# sourced by /etc/init.d/isc-dhcp-server
# installed at /etc/default/isc-dhcp-server by the maintainer scripts
#
# This is a POSIX shell fragment
#
# Path to dhcpd's config file (default: /etc/dhcp/dhcpd.conf).
#DHCPD_CONF=/etc/dhcp/dhcpd.conf
# Path to dhcpd's PID file (default: /var/run/dhcpd.pid).
#DHCPD_PID=/var/run/dhcpd.pid
# Additional options to start dhcpd with.
# Don't use options -cf or -pf here; use DHCPD_CONF/ DHCPD_PID instead
#OPTIONS=""
# On what interfaces should the DHCP server (dhcpd) serve DHCP requests?
# Separate multiple interfaces with spaces, e.g. "eth0 eth1".
INTERFACES="vmbr0"
作為參考,這是一個 debian 7 proxmox 伺服器。
問題是,伺服器透過 DHCP 分配 IP 沒有問題。它取得 xxx.xxx.x.5,但是透過路由 -n 查看時網關設定為 0.0.0.0,因此網路無法存取。
VM網路設定檔的內容:
DEVICE=eth01
BOOTPROTO=dhcp
ONBOOT=yes
另外,當從 DHCP 獲取資訊時出現無效參數錯誤,它們可能是相關的。
客戶端登入錯誤:
答案1
由於資訊有限,很難遠端排除故障。但我想嘗試一下。
首先,只是一個猜測。通常設備名稱是eth0
or eth1
, not eth01
。這可以解釋“無效參數錯誤”。確保您在虛擬機器中ifconfig -a
或在虛擬機器中處理正確的網路卡ip link
。
另一個嫌疑點是靜態路由。數組中應該<netmask>, <network-byte1>, <network-byte2>, <network-byte3>, <router-byte1>, <router-byte2>, <router-byte3>...
有13 個項目,而不是您的 14 個。所以它應該看起來像這樣24,192,168,1, 192,168,1,1, 0, 192,168,1,1
。看一看這裡。我猜錯誤的靜態路由會覆蓋預設網關。
如果這不是問題,那麼您需要一個過程來調試。根據您的 DHCP 配置,我假設vmbr0
是一個 Linux 橋,並且虛擬機器是從那裡創建的。您需要透過檢查主機/虛擬機器管理程式上的virt net-list
和來確認虛擬機器網路是否已正確建立。virt edit <vm>
您也可以使用virt-manager
.確保虛擬機只有一個網卡,該網卡是從vmbr0
.
如果仍未解決,請進入虛擬機器並調試 DHCP 用戶端。首先,killall dhclient
,然後使用或運行dhclient eth0
並監控流量。尋找網關選項。確保沒有其他 DHCP 伺服器阻礙。 (可能是來自 libvirt 的預設 NAT;或者可能是來自外部的另一個 DHCP 伺服器,因為您有一個網橋)。您也可以在擁有 DHCP 伺服器的主機上運作。dhcpdump -i eth0
tcpdump udp and port 67 or 68
dhcpdump/tcpdump
我希望這有幫助。