KVM 虚拟机和宿主机无法通信?

发布于 2022-09-12 23:10:36 字数 4202 浏览 26 评论 0

问题描述

我将KVM的虚拟机从centos6升级到centos7,忘记备份原来虚拟机网络配置了,通过一顿操作虚拟机升级完成,可以访问内网除宿主机以外的其他机器,可以访问外网。就是和宿主机之间不通。

相关代码

宿主机相关配置
虚拟机采用的 direct vepa模式

    <interface type='direct'>
      <mac address='52:54:00:88:9d:87'/>
      <source dev='eth1' mode='vepa'/>
      <model type='rtl8139'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
    </interface>

宿主机路由信息

Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
172.16.1.0      *               255.255.255.0   U     0      0        0 eth1
192.168.122.0   *               255.255.255.0   U     0      0        0 virbr0
link-local      *               255.255.0.0     U     1003   0        0 eth1

宿主机网桥

bridge name    bridge id        STP enabled    interfaces
virbr0        8000.52540029c97e    yes        virbr0-nic

宿主机网卡信息

eth1      Link encap:Ethernet  HWaddr 4C:D9:8F:5A:8C:89  
          inet addr:172.16.1.145  Bcast:172.16.1.255  Mask:255.255.255.0
          inet6 addr: fe80::4ed9:8fff:fe5a:8c89/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:232212114 errors:0 dropped:0 overruns:0 frame:0
          TX packets:172480199 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:27038833159 (25.1 GiB)  TX bytes:14113201403 (13.1 GiB)
          Interrupt:18 

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:10262338 errors:0 dropped:0 overruns:0 frame:0
          TX packets:10262338 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:672132647 (640.9 MiB)  TX bytes:672132647 (640.9 MiB)

macvtap1  Link encap:Ethernet  HWaddr 52:54:00:88:9D:87  
          inet6 addr: fe80::5054:ff:fe88:9d87/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1025989 errors:0 dropped:0 overruns:0 frame:0
          TX packets:41519 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:500 
          RX bytes:35392803 (33.7 MiB)  TX bytes:13748985 (13.1 MiB)

virbr0    Link encap:Ethernet  HWaddr 52:54:00:29:C9:7E  
          inet addr:192.168.122.1  Bcast:192.168.122.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:3 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:216 (216.0 b)  TX bytes:0 (0.0 b)

虚拟机路由信息,eth2是配置的外网Ip 配置我没列出来

Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         gateway         0.0.0.0         UG    0      0        0 eth2
link-local      0.0.0.0         255.255.0.0     U     1002   0        0 eth1
172.16.1.0      0.0.0.0         255.255.255.0   U     0      0        0 eth1

虚拟机网卡信息

eth1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 172.16.1.146  netmask 255.255.255.0  broadcast 172.16.1.255
        inet6 fe80::5054:ff:fe88:9d87  prefixlen 64  scopeid 0x20<link>
        ether 52:54:00:88:9d:87  txqueuelen 1000  (Ethernet)
        RX packets 151806  bytes 8350650 (7.9 MiB)
        RX errors 0  dropped 12163  overruns 0  frame 0
        TX packets 41542  bytes 13751835 (13.1 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 0  (Local Loopback)
        RX packets 352  bytes 58554 (57.1 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 352  bytes 58554 (57.1 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

虚拟机网桥没有

你期待的结果是什么?实际看到的错误信息又是什么?

网上 direct vepa模式资料比较少,是缺少网桥还是虚拟机配置不对吗?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文