![ISC DHCP 服务器 - Qemu 系统](https://linux22.com/image/76693/ISC%20DHCP%20%E6%9C%8D%E5%8A%A1%E5%99%A8%20-%20Qemu%20%E7%B3%BB%E7%BB%9F.png)
我一直在尝试通过 ISC 服务器获取 dhcp 地址。我有一台 DHCP 服务器和一台带有多个图像微型核心的 qemu 服务器。
希望这张 ASCII 绘图能够说明拓扑:
OVS 交换机通过 qemu 服务器连接 Tap 接口。
qemu-system-i386 -m 64 -boot c -hda tinycore1.img -name vm1 -no-acpi -net nic,macaddr=52:66:99:66:42:11,model=pcnet -net tap,ifname=$TAP,script=ovstap -vnc :1 -daemonize
qemu-system-i386 -m 64 -boot c -hda tinycore2.img -name vm2 -no-acpi -net nic,macaddr=52:66:99:66:42:12,model=pcnet -net tap,ifname=$TAP,script=ovstap -vnc :2 -daemonize
tap1: 10.10.10.1 /24
--------------------\ \
\------------\-------qemu server-----------ISC DHCP server
/ 10.10.10.252/ 10.10.10.253 10.10.10.254
--------------------/ OVS / eth1 eth1
tap2: 10.10.10.2 /24
脚本ovstap
#!/bin/sh
#
# Set to the name of your bridge
BRIDGE=OVS
# Network information
NETMASK=255.255.255.0
ADD=172.16.10.199
do_ovs() {
ovs-vsctl "$@"
}
do_ifconfig() {
ifconfig "$@"
}
do_dd() {
dd "$@"
}
check_bridge() {
if do_ovs show | grep "^$1" > /dev/null 2> /dev/null; then
return 1
else
return 0
fi
}
create_bridge() {
do_ovs add-br "$1"
do_ovs set bridge "$1" stp_enable=false
do_ovs set bridge "$1" other_config:stp-forward-delay=0
do_ifconfig "$1" "$ADD" netmask "$NETMASK" up
}
enable_ip_forward() {
echo 1 | do_dd of=/proc/sys/net/ipv4/ip_forward > /dev/null
}
setup_bridge_nat() {
if [ -n "$(ovs-vsctl show | grep $BRIDGE)" ] ; then
enable_ip_forward
else
create_bridge "$1"
enable_ip_forward
fi
}
setup_bridge_nat "$BRIDGE"
if test "$1" ; then
do_ifconfig "$1" 0.0.0.0 up
do_ovs add-port "$BRIDGE" "$1"
fi
这里的问题是,通过 Tap 接口连接的每个虚拟机都没有从 isc dhcp 服务器接收到 ip add。
我的 dhcpd.conf 服务器 dhcp
ddns-update-style none;
default-lease-time 600;
max-lease-time 7200;
log-facility local7;
allow booting;
allow bootp;
# QEMU LAN
subnet 10.10.10.0 netmask 255.255.255.0 {
option broadcast-address 10.10.10.255;
option routers 10.10.10.253;
option domain-name-servers 10.10.10.200;
range 10.10.10.1 10.10.10.10;
}
host VM1 {
hardware ethernet 52:66:99:66:42:11;
fixed-address 10.10.10.1;
}
host TVM2 {
hardware ethernet 52:66:99:66:42:12;
fixed-address 10.10.10.2;
}
我该如何修复它?任何帮助,将不胜感激。谢谢。