所以我正在为KVM虚拟机运行一个开发服务器。 我有一个在主机节点上运行的本地DHCP服务器,具有以下configuration:
的/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 /默认/ 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, eg "eth0 eth1". INTERFACES="vmbr0"
作为参考,这是一个debian 7 proxmox服务器。
问题是,服务器通过DHCP分配IP而没有问题。 它得到xxx.xxx.x.5,但是当通过路由-n查看时,网关被设置为0.0.0.0,因此networking不可达。
VMnetworkingconfiguration文件的内容:
DEVICE=eth01 BOOTPROTO=dhcp ONBOOT=yes
另外,从DHCP获取信息时出现无效的参数错误,它们可能是相关的。
错误login客户端:
利用有限的信息进行远程故障排除很困难。 但我想尝试。
首先,只是一个猜测。 通常DEVICE名称是eth0或eth1 ,而不是eth01 。 这可能会解释“无效的参数错误”。 确保您正在通过虚拟机中的ifconfig -a或ip link处理正确的网卡。
另一个嫌疑犯是静态路线。 它的格式是<netmask>, <network-byte1>, <network-byte2>, <network-byte3>, <router-byte1>, <router-byte2>, <router-byte3>... 所以应该看起来像这个24,192,168,1, 192,168,1,1, 0, 192,168,1,1 。 看看这里 。 我想错误的静态路由覆盖默认网关。
如果这不是问题,则需要进行debugging。 从你的DHCPconfiguration中,我认为vmbr0是一个Linux桥,虚拟机是从那里创build的。 您需要通过检查主机/ hyperviser上的virt net-list和virt edit <vm>来确认VMnetworking是否正确创build。 你也可以使用virt-manager 。 确保虚拟机只有一个从vmbr0桥接的vmbr0 。
如果仍然没有解决,进入虚拟机并debuggingDHCP客户端。 首先, killall dhclient ,然后运行dhclient eth0并使用dhcpdump -i eth0或tcpdump udp and port 67 or 68监视stream量。 寻找网关选项。 确保没有其他的DHCP服务器的方式。 (可能是来自libvirt的默认NAT;或者可能是来自外部的另一个DHCP服务器,因为您有一个网桥)。 你也可以在你有DHCP服务器的主机上运行dhcpdump/tcpdump 。
我希望这有帮助。