KVM은 다른 컴퓨터가 아닌 호스트에서 SSH를 통해 연결할 수 있습니다.

KVM은 다른 컴퓨터가 아닌 호스트에서 SSH를 통해 연결할 수 있습니다.

서버에 kvm/quemu를 설정했습니다. 나는 가이드를 따랐고 한 가지 예외를 제외하고는 작동했습니다. kvm이 실행 중인 서버를 통해서만 vm에 SSH로 연결할 수 있습니다. 노트북을 사용하면 할 수 없습니다. 먼저 서버에 SSH를 연결한 다음 VM에 연결해야 합니다.

서버 우분투 18.04 서버

다음은 서버의 /etc/network/interfaces입니다.

소스 /etc/network/interfaces.d/*

# The loopback network interface
auto lo
iface lo inet loopback

# primary network interface
#auto eth0
#iface eth0 inet manual
#       address 192.168.1.100
#       netmask 255.255.255.0
#       dns-nameservers 8.8.8.8


#bridge
auto br0
iface br0 inet static
        address 192.168.1.100
        netmask 255.255.224.0
        gateway 192.168.1.1
        dns-nameserver 192.168.100.1 8.8.8.8
        bridge_ports eth0
        bridge_stp n
        bridge_fd 0
        bridge_maxwait 0



br0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500                                                            
        inet 192.168.1.100  netmask 255.255.224.0  broadcast 192.168.31.255                                          
        ether 0e:37:a0:d5:da:e5  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                                                   

docker0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500                                                                
        inet 172.17.0.1  netmask 255.255.0.0  broadcast 172.17.255.255                                               
        ether 02:42:ac:48:67:60  txqueuelen 0  (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                                                   

eno1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500                                                           
        inet 192.168.1.7  netmask 255.255.255.0  broadcast 192.168.1.255                                             
        ether 78:2b:cb:03:27:5c  txqueuelen 1000  (Ethernet)                                                         
        RX packets 209192  bytes 21456278 (21.4 MB)                                                                  
        RX errors 0  dropped 1400  overruns 0  frame 0                                                               
        TX packets 1220945  bytes 1689016362 (1.6 GB)                                                                
        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                                                                            
        loop  txqueuelen 1000  (Local Loopback)                                                                      
        RX packets 350787  bytes 5953177436 (5.9 GB)                                                                 
        RX errors 0  dropped 0  overruns 0  frame 0                                                                  
        TX packets 350787  bytes 5953177436 (5.9 GB)                                                                 
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0                                                   

virbr0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500                                                         
        inet 192.168.100.1  netmask 255.255.255.0  broadcast 192.168.100.255                                         
        ether 52:54:00:81:56:35  txqueuelen 1000  (Ethernet)                                                         
        RX packets 4662  bytes 313603 (313.6 KB)                                                                     
        RX errors 0  dropped 41  overruns 0  frame 0                                                                 
        TX packets 2177  bytes 228116 (228.1 KB)                                                                     
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0                                                   

vnet0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500                                                          
        ether fe:54:00:de:c7:b6  txqueuelen 1000  (Ethernet)                                                         
        RX packets 4223  bytes 336843 (336.8 KB)                                                                     
        RX errors 0  dropped 0  overruns 0  frame 0                                                                  
        TX packets 24991  bytes 1402572 (1.4 MB)                                                                     
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0                                                   

Virsh 편집 16

<domain type='qemu'>
  <name>ubuntu18.04</name>
  <uuid>bf380e27-73bf-4633-b69a-4b04cae4d0ab</uuid>
  <memory unit='KiB'>2097152</memory>
  <currentMemory unit='KiB'>2097152</currentMemory>
  <vcpu placement='static'>1</vcpu>
  <os>
    <type arch='x86_64' machine='pc-i440fx-bionic'>hvm</type>
    <boot dev='hd'/>
  </os>
  <features>
    <acpi/>
    <apic/>
    <vmport state='off'/>
  </features>
  <clock offset='utc'>
    <timer name='rtc' tickpolicy='catchup'/>
    <timer name='pit' tickpolicy='delay'/>
    <timer name='hpet' present='no'/>
  </clock>
  <on_poweroff>destroy</on_poweroff>
  <on_reboot>restart</on_reboot>
  <on_crash>destroy</on_crash>
  <pm>
    <suspend-to-mem enabled='no'/>
    <suspend-to-disk enabled='no'/>
  </pm>
  <devices>
    <emulator>/usr/bin/qemu-system-x86_64</emulator>
    <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source file='/mnt/md1/vm/images/ubuntu18.04.qcow2'/>
      <target dev='vda' bus='virtio'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/>
    </disk>
    <disk type='file' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <target dev='hda' bus='ide'/>
      <readonly/>
      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
    </disk>
    <controller type='usb' index='0' model='ich9-ehci1'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x7'/>
    </controller>
    <controller type='usb' index='0' model='ich9-uhci1'>
      <master startport='0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0' multifunction='on'/>
    </controller>
    <controller type='usb' index='0' model='ich9-uhci2'>
      <master startport='2'/>
          <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x1'/>
        </controller>
        <controller type='usb' index='0' model='ich9-uhci3'>
          <master startport='4'/>
          <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x2'/>
        </controller>
        <controller type='pci' index='0' model='pci-root'/>
        <controller type='ide' index='0'>
          <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
        </controller>
        <controller type='virtio-serial' index='0'>
          <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
        </controller>
        <interface type='bridge'>
          <mac address='52:54:00:de:c7:b6'/>
          <source bridge='br0'/>
          <model type='virtio'/>
          <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
        </interface>
        <serial type='pty'>
          <target type='isa-serial' port='0'>
            <model name='isa-serial'/>
          </target>
        </serial>
        <console type='pty'>
          <target type='serial' port='0'/>
        </console>
        <channel type='spicevmc'>
          <target type='virtio' name='com.redhat.spice.0'/>
          <address type='virtio-serial' controller='0' bus='0' port='1'/>
        </channel>
        <input type='tablet' bus='usb'>
          <address type='usb' bus='0' port='1'/>
        </input>
        <input type='mouse' bus='ps2'/>
        <input type='keyboard' bus='ps2'/>
        <graphics type='spice' autoport='yes'>
          <listen type='address'/>
        </graphics>
        <sound model='ich6'>
          <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
        </sound>
        <video>
          <model type='qxl' ram='65536' vram='65536' vgamem='16384' heads='1' primary='yes'/>
          <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
        </video>
    <redirdev bus='usb' type='spicevmc'>
      <address type='usb' bus='0' port='2'/>
    </redirdev>
    <redirdev bus='usb' type='spicevmc'>
      <address type='usb' bus='0' port='3'/>
    </redirdev>
    <memballoon model='virtio'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x08' function='0x0'/>
    </memballoon>
  </devices>
</domain>

eno1 이후 ..ssh 액세스가 손실됩니다. eno1 이외의 문자열을 사용해 보았지만 결과는 동일했습니다. 예: "bridge_ports mycatisbadass6969". 나는 bridge_ports 영역이 범인이라고 추측합니다. 어떤 제안이 있으십니까?

노트북 우분투 18.04 데스크탑

노트북의 Ifconfig

eno1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.1.2  netmask 255.255.255.0  broadcast 192.168.1.255
        inet6 fe80::eb74:44f9:ec1e:5c64  prefixlen 64  scopeid 0x20<link>
        ether ac:22:0b:50:ae:ea  txqueuelen 1000  (Ethernet)
        RX packets 1350919  bytes 1948697230 (1.9 GB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 328633  bytes 28035898 (28.0 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device interrupt 20  memory 0xf7b00000-f7b20000  

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 1000  (Local Loopback)
        RX packets 6029  bytes 566246 (566.2 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 6029  bytes 566246 (566.2 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

virbr0: 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:a3:f6:29  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

/etc/네트워크/인터페이스

auto lo
iface lo inet loopback

VM Ubuntu18.04 서버

ens3: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.100.147  netmask 255.255.255.0  broadcast 192.168.100.255
        inet6 fe80::5054:ff:fede:c7b6  prefixlen 64  scopeid 0x20<link>
        ether 52:54:00:de:c7:b6  txqueuelen 1000  (Ethernet)
        RX packets 278  bytes 24506 (24.5 KB)
        RX errors 0  dropped 119  overruns 0  frame 0
        TX packets 169  bytes 17083 (17.0 KB)
        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 1000  (Local Loopback)
        RX packets 284  bytes 21556 (21.5 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 284  bytes 21556 (21.5 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

나는 변했다

<interface type='network'>
  <source network='default'/>
</interface>

에게

 <interface type='bridge'>
  <source bridge='br0'/>
</interface>

어댑터 lo..ens3 어댑터 있음

또한 sudo /etc/inint.d/network restart를 수정하면서 네트워크 인터페이스를 수천 번 다시 시작했습니다.

편집...아래에서 이것을 실행하면 어댑터를 사용할 수 있습니다. 여전히 VM에 직접 SSH를 연결할 수 없습니다.

sudo ip addr flush dev br0 
sudo ip addr flush dev eno1

관련 정보