Keine DHCP-Antwort auf Bridge mit QEMU- und TAP-Schnittstelle

530
Christian Ehrig

Ich habe eine Hostmaschine, auf der eine virtuelle Maschine mit QEMU ausgeführt wird, und ich möchte, dass der DHCP-Server auf dem Host eine IP-Adresse bereitstellt.

Ich verwende statische Ethernet-Adressen für die Gäste, daher starte ich sie so:

qemu-system-x86_64 -hda debian.img -netdev tap,id=n1,ifname=tap0001,script=/root/qemu/net-up.sh,downscript=/root/qemu/net-down.sh -device virtio-net-pci,netdev=n1,mac=02:00:00:01:01:01 -enable-kvm -cdrom /root/qemu/install-amd64-minimal-20180802T214502Z.iso -boot d -enable-kvm -qmp tcp:localhost:4444,server,nowait -smp 2,cores=16,threads=1,sockets=2,maxcpus=32 -m size=1G -vnc :1 

Da ich Host-Reservierungen über eine Datenbank verwalten möchte, verwende ich Kea-DHCP-Server mit MySQL Backend.

Nach dem Start der VM habe ich folgendes Netzwerk-Setup:

Host: eno1: 10.0.0.1 (listening for dhcp requests) tap0001: no IP (TAP interface for the VM) br00001: no IP (bridges tap0001 and eno1)  Guest: eth0: hw ether 02:00:00:01:01:01 

Wenn ich nun eine IP vom Host anfordert, kann ich sehen, wie Kea die konfigurierte IP anbietet:

2018-08-15 23:13:46.536 INFO [kea-dhcp4.leases/6548] DHCP4_LEASE_ADVERT [hwtype=1 02:00:00:01:01:01], cid=[ff:00:01:01:01:00:01:00:01:23:07:53:2b:02:00:00:01:01:01], tid=0xf069f396: lease 10.0.0.10 will be advertised 2018-08-15 23:14:51.444 INFO [kea-dhcp4.leases/6548] DHCP4_LEASE_ADVERT [hwtype=1 02:00:00:01:01:01], cid=[ff:00:01:01:01:00:01:00:01:23:07:53:2b:02:00:00:01:01:01], tid=0xf069f396: lease 10.0.0.10 will be advertised 

Ich kann auch das DHCP entdecken und auf eno1 antworten:

tcpdump port 67 or port 68 -i eno1 -nN dropped privs to tcpdump tcpdump: verbose output suppressed, use -v or -vv for full protocol decode listening on eno1, link-type EN10MB (Ethernet), capture size 262144 bytes 23:11:41.326945 IP 0.0.0.0.68 > 255.255.255.255.67: BOOTP/DHCP, Request from 02:00:00:01:01:01, length 356 23:11:41.329444 IP 10.0.0.1.67 > 10.0.0.10.68: BOOTP/DHCP, Reply, length 307 

Die DHCP-Antwort ist auf br0001 jedoch auch nicht auf tap0001 zu sehen:

tcpdump port 67 or port 68 -i br0001 -nN dropped privs to tcpdump tcpdump: verbose output suppressed, use -v or -vv for full protocol decode listening on br0001, link-type EN10MB (Ethernet), capture size 262144 bytes  23:26:33.308296 IP 0.0.0.0.68 > 255.255.255.255.67: BOOTP/DHCP, Request from 02:00:00:01:01:01, length 356 23:26:37.336875 IP 0.0.0.0.68 > 255.255.255.255.67: BOOTP/DHCP, Request from 02:00:00:01:01:01, length 356 

Könnte mir jemand in die richtige Richtung weisen, so dass DHCP-Antworten an die VM gesendet werden. Vielen Dank.

2

0 Antworten auf die Frage