I setup a macvtap interface like this:
ip link add link eth0 vlan type macvlan mode bridge
ip address add 10.0.0.17 dev vlan
ip link set dev vlan up
ip route flush dev eth0
ip route flush dev vlan
ip route add 10.0.0.0/24 dev vlan metric 0
ip route add default via 10.0.0.1
ip link add link eth0 name vtap address xx:xx:xx:xx:xx:xx type macvtap mode bridge
ip link set vtap up
ip address flush eth0
ip address flush vtap
dhclient -v vtap
ip address flush vtap
And it works fine for a couple of hours. But after that, any connections to the DHCP (macvtap) IP will start going to the host machine instead. So if I connect to the IP at port 80 for example, I will see a page served by the host instead of the VM.
I am trying to understand why it stops working. At first I thought maybe the DHCP lease expired, and dhclient
is not renewing it. But the leasetime is 24 hours, and this problem starts earlier than that, sometimes in less than 10 hours.
So what can be causing the macvtap
interface to stop working?