ISC DHCP 伺服器 - Qemu 系統

ISC DHCP 伺服器 - Qemu 系統

我一直在嘗試透過 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;
}

我該如何修復它?任何幫助,將不勝感激。謝謝。

相關內容