I deleted an old KVM guest and now have a spare IP address. I now assigned this (previously working!) IP address to another KVM guest, like so:
virsh # attach-interface my-guest bridge br0 vnet1 00:50:56:00:57:05 --model virtio --persistent
The guest XML file now looks like this:
virsh # dumpxml my-guest
<domain type='kvm' id='3'>
<name>my-guest</name>
...
<devices>
<emulator>/usr/bin/kvm-spice</emulator>
...
<interface type='bridge'>
<mac address='00:50:56:00:57:04'/>
<source bridge='br0'/>
<target dev='vnet0'/>
<model type='virtio'/>
<alias name='net0'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
</interface>
<interface type='bridge'>
<mac address='00:50:56:00:57:05'/>
<source bridge='br0'/>
<target dev='vnet1'/>
<model type='virtio'/>
<alias name='net1'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
</interface>
...
</devices>
...
</domain>
Because of the kind of randomly assigned PCI slot, the new IP address is now eth0
and the old one is eth1
.
I changed the guest's /etc/network/interfaces
appropriately:
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
# 148.251.73.28 <- new IP address
auto eth0
iface eth0 inet dhcp
# 148.251.73.27 <- old IP address
auto eth1
iface eth1 inet dhcp
Upon login, I'm even greeted with this friendly message, indicating that both interfaces should be configured correctly, as they automatically got assigned the correct IP addresses (based on the MAC addresses):
System load: 1.54 Users logged in: 0
Usage of /: 22.6% of 448.72GB IP address for eth0: 148.251.73.28
Memory usage: 12% IP address for eth1: 148.251.73.27
Swap usage: 0% IP address for docker0: 172.17.42.1
Processes: 207
And now the problem: Only eth0
, the new IP address, works. I can't reach the server over eth1
.
Note: I have an nginx server listening on 0.0.0.0
.
All these tests fail:
$ curl --interface eth1 ifconfig.co
$ curl --interface eth1 148.251.73.28 (eth1 -> eth0)
$ curl --interface eth0 148.251.73.27 (eth0 -> eth1)
And strangely enough, this works:
$ curl --interface eth1 148.251.73.27 (eth1 -> eth1)
What the heck? Does anyone have any clues on what could cause this?
Last but not least, the host's /etc/network/interfaces
:
# Loopback device:
auto lo
iface lo inet loopback
# device: eth0
auto br0
iface br0 inet static
address 148.251.52.150
broadcast 148.251.52.159
netmask 255.255.255.224
gateway 148.251.52.129
pointopoint 148.251.52.129
bridge_ports eth0
bridge_stp off
bridge_fd 1
bridge_hello 2
bridge_maxage 12
# default route to access subnet
up route add -net 148.251.52.128 netmask 255.255.255.224 gw 148.251.52.129 br0