Networking

KVM 來賓無法獲取軟體包,因此可以從 ssh 訪問

  • February 27, 2019

我對我的 kvm 設置有點迷茫。

我在hetzner.de租了一個根伺服器,現在想使用 libvirt 和 kvm 設置虛擬化。我創建了一個橋br0,它現在保存靜態伺服器 ip(而不是預設介面enp2s0)。將 /29 子網連結到網橋並為來賓分配靜態 IP 一切正常。現在我可以使用靜態 ip 從外部訪問它,但無法獲取包或 ping 名稱伺服器。所以 ping8.8.8.8工作正常,同時 pinggoogle.com答案:

Temporary failure in name resolution

這是主機的路線(在此處和以下文本中,我將第一個八度音階替換為 255)

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         255.251.246.1   0.0.0.0         UG    0      0        0 br0
255.9.179.64      0.0.0.0         255.255.255.255 UH    0      0        0 br0
255.9.179.65      0.0.0.0         255.255.255.255 UH    0      0        0 br0
255.9.179.66      0.0.0.0         255.255.255.255 UH    0      0        0 br0
255.9.179.67      0.0.0.0         255.255.255.255 UH    0      0        0 br0
255.9.179.68      0.0.0.0         255.255.255.255 UH    0      0        0 br0
255.9.179.69      0.0.0.0         255.255.255.255 UH    0      0        0 br0
255.9.179.70      0.0.0.0         255.255.255.255 UH    0      0        0 br0
255.251.246.0   0.0.0.0         255.255.255.224 U     0      0        0 br0
192.168.122.0   0.0.0.0         255.255.255.0   U     0      0        0 bro0

結果brctl show

bridge name     bridge id               STP enabled     interfaces
br0             8000.448a5b5dd0f1       no              enp2s0
                                                       vnet0
bro0            8000.52540006b883       yes             bro0-nic

ifconfig在主機上:

br0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
       inet 255.251.246.11  netmask 255.255.255.224  broadcast 255.251.246.31
       inet6 255::468a:5bff:fe5d:d0f1  prefixlen 64  scopeid 0x20<link>
       ether 44:8a:5b:5d:d0:f1  txqueuelen 1000  (Ethernet)
       RX packets 51679  bytes 3634682 (3.4 MiB)
       RX errors 0  dropped 0  overruns 0  frame 0
       TX packets 90348  bytes 7395186 (7.0 MiB)
       TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

bro0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
       inet 192.168.122.1  netmask 255.255.255.0  broadcast 192.168.122.255
       ether 52:54:00:06:b8:83  txqueuelen 1000  (Ethernet)
       RX packets 0  bytes 0 (0.0 B)
       RX errors 0  dropped 0  overruns 0  frame 0
       TX packets 0  bytes 0 (0.0 B)
       TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

enp2s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
       ether 44:8a:5b:5d:d0:f1  txqueuelen 1000  (Ethernet)
       RX packets 104449  bytes 7981272 (7.6 MiB)
       RX errors 0  dropped 0  overruns 0  frame 0
       TX packets 89828  bytes 8144371 (7.7 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 1  (Local Loopback)
       RX packets 2  bytes 190 (190.0 B)
       RX errors 0  dropped 0  overruns 0  frame 0
       TX packets 2  bytes 190 (190.0 B)
       TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

vnet0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
       inet6 255::fc54:ff:fe94:8198  prefixlen 64  scopeid 0x20<link>
       ether fe:54:00:94:81:98  txqueuelen 1000  (Ethernet)
       RX packets 1172  bytes 110476 (107.8 KiB)
       RX errors 0  dropped 0  overruns 0  frame 0
       TX packets 5399  bytes 321838 (314.2 KiB)
       TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

ifconfig客人的

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1
   link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
   inet 127.0.0.1/8 scope host lo
      valid_lft forever preferred_lft forever
   inet6 ::1/128 scope host
      valid_lft forever preferred_lft forever
2: ens2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
   link/ether 52:54:00:94:81:98 brd ff:ff:ff:ff:ff:ff
   inet 255.9.179.65 peer 255.251.246.11/32 brd 255.9.179.65 scope global ens2
      valid_lft forever preferred_lft forever
   inet6 255::5054:ff:fe94:8198/64 scope link
      valid_lft forever preferred_lft forever

目前我還沒有設置任何類型的防火牆。我想測試連接等而不受它的干擾。現在我想這可能是問題所在。可能是偽裝的問題。。

幫助表示讚賞!

乾杯,托比

感謝@MichaelHampton,我得到了它的工作。我忘記在來賓下更新名稱伺服器/etc/resolv.conf。插入主機名稱伺服器解決了我的問題。

引用自:https://serverfault.com/questions/955921