两个 NIC 用于一个 KVM 客户机

两个 NIC 用于一个 KVM 客户机

我删除了旧的 KVM 客户机,现在有一个备用 IP 地址。我现在分配了这个(以前工作过!)IP 地址分配给另一个 KVM 客户机,如下所示:

virsh # attach-interface my-guest bridge br0 vnet1 00:50:56:00:57:05 --model virtio --persistent

访客 XML 文件现在如下所示:

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>

由于 PCI 插槽是随机分配的,新的IP 地址现在是eth0,旧地址是eth1

我适当地改变了客人的/etc/network/interfaces

# 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

登录后,我甚至收到了这条友好的消息,表明两个接口都应该正确配置,因为它们自动分配了正确的 IP 地址(基于 MAC 地址):

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

现在的问题是:只有eth0新 IP 地址有效。我无法通过 访问服务器eth1

注意:我有一个正在监听的 nginx 服务器0.0.0.0

所有这些测试都失败了:

$ curl --interface eth1 ifconfig.co
$ curl --interface eth1 148.251.73.28   (eth1 -> eth0)
$ curl --interface eth0 148.251.73.27   (eth0 -> eth1)

奇怪的是,这作品

$ curl --interface eth1 148.251.73.27   (eth1 -> eth1)

这到底是怎么回事?有人知道这是什么原因造成的吗?

最后但同样重要的是,主持人的/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

相关内容