[+]Jak skonfigurować KVM do połączenia guest - host

Masz problemy z siecią bądź internetem? Zapytaj tu
Awatar użytkownika
korbielow
Beginner
Posty: 345
Rejestracja: 29 marca 2014, 20:37

[+]Jak skonfigurować KVM do połączenia guest - host

Post autor: korbielow »

Witam!
Proszę o pomoc w konfiguracji KVM. Używam Debiana 9 buster. Chce dostać się z hosta DEBIAN na goscia WIN XP.

Skonfigurowałem na debianie /etc/network/interfaces w ten sposob

Kod: Zaznacz cały

modprobe dummy
ip link add dummy0 type dummy
ip link add link dummy0 macvlan0 type macvlan mode bridge
ifconfig dummy0 up
ifconfig macvlan0 192.168.1.2 broadcast 192.168.1.255 netmask 255.255.255.0 up
Prosze o pomoc czy w dobrym kierunku idę.
Ostatnio zmieniony 27 lutego 2018, 05:00 przez korbielow, łącznie zmieniany 1 raz.
Awatar użytkownika
LordRuthwen
Moderator
Posty: 2302
Rejestracja: 18 września 2009, 21:45
Lokalizacja: klikash?

Re: Jak skonfigurować KVM do połączenia guest - host

Post autor: LordRuthwen »

Co chcesz osiągnąć i jaką masz topologię?
Awatar użytkownika
korbielow
Beginner
Posty: 345
Rejestracja: 29 marca 2014, 20:37

Re: Jak skonfigurować KVM do połączenia guest - host

Post autor: korbielow »

Chce móc wejść z guest /winxp/ na hosta /debian/ . Chciałbym mieć jakis katlog dzieki któremy będzie możliwa komunikacja - tak jak to jest w vmplayer (shared folders).
W domu mam 2 routery
192.168.1.1
i druga siec 192.168.2. i tu podpiety jest laptop.
Ostatnio zmieniony 15 lutego 2018, 12:57 przez korbielow, łącznie zmieniany 1 raz.
Awatar użytkownika
LordRuthwen
Moderator
Posty: 2302
Rejestracja: 18 września 2009, 21:45
Lokalizacja: klikash?

Re: Jak skonfigurować KVM do połączenia guest - host

Post autor: LordRuthwen »

A KVM masz jak skonfigurowanego?
Stwórz na fizycznej maszynie mostek z dodaj mu kartę sieciową (np br0), w konfiguracji libvirta ustaw br0 jako interfejs sieciowy i wyłącz nata, hosty zarządzane z libvirta powinny być wtedy widoczne w sieci lokalnej.
macvlan też by mógł być, ale tylko po kablu, jeśli korzystasz z wifi to ipvlan.
Awatar użytkownika
korbielow
Beginner
Posty: 345
Rejestracja: 29 marca 2014, 20:37

Re: Jak skonfigurować KVM do połączenia guest - host

Post autor: korbielow »

Do tej pory stworzyłem coś takiego:

Kod: Zaznacz cały

root@debian:/home/rafal# ip addr show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    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: eno1: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast master br0 state DOWN group default qlen 1000
    link/ether 5c:26:0a:43:bd:7f brd ff:ff:ff:ff:ff:ff
3: wlp2s0b1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
    link/ether 68:a3:c4:40:0c:02 brd ff:ff:ff:ff:ff:ff
    inet 192.168.2.3/24 brd 192.168.2.255 scope global dynamic noprefixroute wlp2s0b1
       valid_lft 82537sec preferred_lft 82537sec
    inet6 fe80::6aa3:c4ff:fe40:c02/64 scope link noprefixroute 
       valid_lft forever preferred_lft forever
4: br0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default qlen 1000
    link/ether 5c:26:0a:43:bd:7f brd ff:ff:ff:ff:ff:ff


root@debian:/home/rafal# ifconfig
br0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet6 fe80::ecc5:cfff:fe19:1ab6  prefixlen 64  scopeid 0x20<link>
        ether 5c:26:0a:43:bd:7f  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 103  bytes 17824 (17.4 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

br0:avahi: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet 169.254.7.165  netmask 255.255.0.0  broadcast 169.254.255.255
        ether 5c:26:0a:43:bd:7f  txqueuelen 1000  (Ethernet)

eno1: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        ether 5c:26:0a:43:bd:7f  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
        device interrupt 20  memory 0xf6900000-f6920000  

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 408  bytes 31454 (30.7 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 408  bytes 31454 (30.7 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

wlp2s0b1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.2.3  netmask 255.255.255.0  broadcast 192.168.2.255
        inet6 fe80::6aa3:c4ff:fe40:c02  prefixlen 64  scopeid 0x20<link>
        ether 68:a3:c4:40:0c:02  txqueuelen 1000  (Ethernet)
        RX packets 110782  bytes 124105367 (118.3 MiB)
        RX errors 0  dropped 6  overruns 0  frame 0
        TX packets 71900  bytes 11050140 (10.5 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

root@debian:/home/rafal# brctl addif br0 eno1
device eno1 is already a member of a bridge; can't enslave it to bridge br0.


root@debian:/home/rafal# nano /etc/network/interfaces
 # This file describes the network interfaces available on your system
 # and how to activate them. For more information, see interfaces(5).

 # The loopback network interface
 auto lo
 iface lo inet loopback

 # Set up interfaces manually, avoiding conflicts with, e.g., network manager
 iface eno1 inet manual

# iface eth1 inet manual

 # Bridge setup
 iface br0 inet dhcp
    bridge_ports eno1 eth1


root@debian:/home/rafal# ifup br0
ifup: interface br0 already configured

Obrazek



Obrazek



Obrazek



Obrazek
Awatar użytkownika
LordRuthwen
Moderator
Posty: 2302
Rejestracja: 18 września 2009, 21:45
Lokalizacja: klikash?

Re: Jak skonfigurować KVM do połączenia guest - host

Post autor: LordRuthwen »

Jeszcze pokaż

Kod: Zaznacz cały

brctl show
Awatar użytkownika
korbielow
Beginner
Posty: 345
Rejestracja: 29 marca 2014, 20:37

Re: Jak skonfigurować KVM do połączenia guest - host

Post autor: korbielow »

Kod: Zaznacz cały

root@debian:/home/rafal# brctl show
bridge name	bridge id		STP enabled	interfaces
br0		8000.5c260a43bd7f	no		eno1
Awatar użytkownika
LordRuthwen
Moderator
Posty: 2302
Rejestracja: 18 września 2009, 21:45
Lokalizacja: klikash?

Re: Jak skonfigurować KVM do połączenia guest - host

Post autor: LordRuthwen »

Dodan nową wirtualną sieć, wyłącz jej dhcp i limity i ustaw przekierowanie do sieci wizycznej wybierając br0 i tryb różny od nat.
Awatar użytkownika
korbielow
Beginner
Posty: 345
Rejestracja: 29 marca 2014, 20:37

Re: Jak skonfigurować KVM do połączenia guest - host

Post autor: korbielow »

Spróbwałem czegoś takiego:
Dodałem (auto eth0:1
allow-hotplug eth0:1
iface eth0:1 inet static
address 192.168.3.248
netmask 255.255.255.0
gateway 192.168.3.254) do /etc/network/interfaces

Kod: Zaznacz cały

 #
  This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

source /etc/network/interfaces.d/*

# The loopback network interface
#auto lo
#iface lo inet loopback
#iface br1 inet dhcp
#   bridge_ports eno1
#   bridge_stp on
#   bridge_fd 0.0

 # This file describes the network interfaces available on your system
 # and how to activate them. For more information, see interfaces(5).

 # The loopback network interface
 auto lo
 iface lo inet loopback



  Set up interfaces manually, avoiding conflicts with, e.g., network manager
 iface eno1 inet manual

# iface eth1 inet manual

 # Bridge setup
 iface br0 inet dhcp
    bridge_ports eno1 eth1

# Add the following
auto eth0:1
allow-hotplug eth0:1
iface eth0:1 inet static
  address 192.168.3.248
  netmask 255.255.255.0
  gateway 192.168.3.254
otrzymuje taki błąd

Kod: Zaznacz cały

root@debian:/home/rafal# service networking restart
Job for networking.service failed because the control process exited with error code.
See "systemctl status networking.service" and "journalctl -xe" for details.

Kod: Zaznacz cały

root@debian:/home/rafal# systemctl status networking.service
● networking.service - Raise network interfaces
   Loaded: loaded (/lib/systemd/system/networking.service; enabled; vendor prese
   Active: failed (Result: exit-code) since Thu 2018-02-15 15:54:04 CET; 16min a
     Docs: man:interfaces(5)
  Process: 7864 ExecStop=/sbin/ifdown -a --read-environment --exclude=lo (code=k
  Process: 7992 ExecStart=/sbin/ifup -a --read-environment (code=exited, status=
  Process: 7989 ExecStartPre=/bin/sh -c [ "$CONFIGURE_INTERFACES" != "no" ] && [
 Main PID: 7992 (code=exited, status=1/FAILURE)

lut 15 15:54:04 debian systemd[1]: Starting Raise network interfaces...
lut 15 15:54:04 debian ifup[7992]: Cannot find device "eth0:1"
lut 15 15:54:04 debian ifup[7992]: ifup: failed to bring up eth0:1
lut 15 15:54:04 debian systemd[1]: networking.service: Main process exited, code
lut 15 15:54:04 debian systemd[1]: networking.service: Failed with result 'exit-
lut 15 15:54:04 debian systemd[1]: Failed to start Raise network interfaces.
lines 1-15/15 (END)

Kod: Zaznacz cały

root@debian:/home/rafal# journalctl -xe
lut 15 15:54:04 debian ifup[7992]: ifup: failed to bring up eth0:1
lut 15 15:54:04 debian systemd[1]: networking.service: Main process exited, code
lut 15 15:54:04 debian systemd[1]: networking.service: Failed with result 'exit-
lut 15 15:54:04 debian systemd[1]: Failed to start Raise network interfaces.
-- Subject: Jednostka networking.service się nie powiodła
-- Defined-By: systemd
-- Support: https://www.debian.org/support
-- 
-- Jednostka networking.service się nie powiodła.
-- 
-- Wynik: RESULT.
lut 15 16:00:24 debian systemd[1]: Started Run anacron jobs.
-- Subject: Ukończono uruchamianie jednostki anacron.service
-- Defined-By: systemd
-- Support: https://www.debian.org/support
-- 
-- Jednostka anacron.service ukończyła uruchamianie.
-- 
-- Wynik uruchamiania: RESULT.
lut 15 16:00:24 debian anacron[8126]: Anacron 2.3 started on 2018-02-15
lut 15 16:00:24 debian anacron[8126]: Normal exit (0 jobs run)
lut 15 16:04:40 debian su[7975]: pam_unix(su:session): session closed for user r
lut 15 16:05:04 debian systemd-timesyncd[515]: Synchronized to time server 94.15
lines 2132-2154/2154 (END)
Awatar użytkownika
LordRuthwen
Moderator
Posty: 2302
Rejestracja: 18 września 2009, 21:45
Lokalizacja: klikash?

Re: Jak skonfigurować KVM do połączenia guest - host

Post autor: LordRuthwen »

Zablokowany