[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

How to communicate between QEMU host and two guests?



===file "/etc/network/interfaces" in host:===
auto lo
iface lo inet loopback
 
iface enp2s0 inet manual
auto br0
iface br0 inet dhcp
bridge_stp off
bridge_maxwait 0
bridge_fd 0
 
pre-up ip tuntap add dev tap1 mode tap user cnliou
pre-up ip link set tap1 up
post-down ip link set tap1 down
post-down ip tuntap del dev tap1 mode tap
 
pre-up ip tuntap add dev tap2 mode tap user cnliou
pre-up ip link set tap2 up
post-down ip link set tap2 down
post-down ip tuntap del dev tap2 mode tap
 
bridge_ports all tap1 tap2

==="ip address" in host:===
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: enp2s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master br0 state UP group default qlen 1000
    link/ether ec:a8:6b:2a:01:20 brd ff:ff:ff:ff:ff:ff
6: tap1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master br0 state UP group default qlen 1000
    link/ether a2:43:f5:1e:2a:55 brd ff:ff:ff:ff:ff:ff
7: tap2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master br0 state UP group default qlen 1000
    link/ether 56:63:da:29:51:02 brd ff:ff:ff:ff:ff:ff
8: br0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether 52:f3:b3:de:05:71 brd ff:ff:ff:ff:ff:ff
    inet 192.168.1.101/24 brd 192.168.1.255 scope global dynamic br0
       valid_lft 85194sec preferred_lft 85194sec
    inet6 2001:b011:2012:3d62:50f3:b3ff:fede:571/64 scope global dynamic mngtmpaddr 
       valid_lft 86324sec preferred_lft 86324sec
    inet6 fe80::50f3:b3ff:fede:571/64 scope link 
       valid_lft forever preferred_lft forever

===Launch guest A in host:===
qemu-system-x86_64 -m 1.5G -cpu max -machine pc,accel=kvm -drive file=debian1.img,if=none,id=drive0 -device virtio-blk,drive=drive0,bootindex=0 -net nic,model=virtio -net tap,ifname=tap1,script=no,downscript=no

===Launch guest B in host:===
qemu-system-x86_64 -m 1.5G -cpu max -machine pc,accel=kvm -drive file=debian2.img,if=none,id=drive0 -device virtio-blk,drive=drive0,bootindex=0 -net nic,model=virtio -net tap,ifname=tap2,script=no,downscript=no

===file "/etc/network/interfaces" in guest A:===
auto lo
iface lo inet loopback
 
auto enp0s3
iface enp0s3 inet static
address 192.168.1.11/32
gateway 192.168.1.1

==="ip address" in guest A:===
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: ens3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 52:54:00:12:34:56 brd ff:ff:ff:ff:ff:ff
    altname enp0s3
    inet 192.168.1.11/32 brd 192.168.1.11 scope global enp0s3
       valid_lft forever preferred_lft forever
    inet6 2001:b011:2012:3d62:5054:ff:fe12:3456/64 scope global dynamic mngtmpaddr 
       valid_lft 86362sec preferred_lft 86362sec
    inet6 fe80::5054:ff:fe12:3456/64 scope link 
       valid_lft forever preferred_lft forever

==="ip route" in guest A:===
default via 192.168.1.1 dev ens3 onlink

===file "/etc/network/interfaces" in guest B:===
auto lo
iface lo inet loopback
 
auto enp0s3
iface enp0s3 inet static
address 192.168.1.12/32
gateway 192.168.1.1

==="ping 192.168.1.11" in host:===
PING 192.168.1.11 (192.168.1.11) 56(84) bytes of data.
64 bytes from 192.168.1.11: icmp_seq=1 ttl=64 time=0.189 ms
64 bytes from 192.168.1.11: icmp_seq=2 ttl=64 time=0.208 ms
 
--- 192.168.1.11 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3051ms
rtt min/avg/max/mdev = 0.189/0.194/0.208/0.007 ms

==="ping 192.168.1.12" in host (test 1):===
PING 192.168.1.12 (192.168.1.12) 56(84) bytes of data.
64 bytes from 192.168.1.12: icmp_seq=1 ttl=63 time=0.756 ms
64 bytes from 192.168.1.12: icmp_seq=2 ttl=64 time=0.194 ms
64 bytes from 192.168.1.12: icmp_seq=7 ttl=64 time=0.182 ms
64 bytes from 192.168.1.12: icmp_seq=8 ttl=64 time=0.178 ms

==="ping 192.168.1.12" in host (test 2):===
PING 192.168.1.12 (192.168.1.12) 56(84) bytes of data.
64 bytes from 192.168.1.12: icmp_seq=10 ttl=63 time=0.773 ms
64 bytes from 192.168.1.12: icmp_seq=11 ttl=64 time=0.209 ms
64 bytes from 192.168.1.12: icmp_seq=12 ttl=64 time=0.208 ms

==="ping 192.168.1.101" in guest A:===
PING 192.168.1.101 (192.168.1.101) 56(84) bytes of data.
64 bytes from 192.168.1.101: icmp_seq=1 ttl=64 time=42.2 ms
64 bytes from 192.168.1.101: icmp_seq=2 ttl=64 time=0.625 ms
From 192.168.1.1: icmp_seq=2 Redirect Host(New nexthop: 192.168.1.101)
64 bytes from 192.168.1.101: icmp_seq=3 ttl=64 time=0.997 ms
64 bytes from 192.168.1.101: icmp_seq=4 ttl=64 time=0.184 ms
 
==="ping 192.168.1.101" in guest B:===
PING 192.168.1.101 (192.168.1.101) 56(84) bytes of data.
64 bytes from 192.168.1.101: icmp_seq=1 ttl=64 time=45.6 ms
64 bytes from 192.168.1.101: icmp_seq=2 ttl=64 time=0.182 ms
 
==="ping 192.168.1.12" in guest A (test 1):===
PING 192.168.1.12 (192.168.1.12) 56(84) bytes of data.
From 192.168.1.1: icmp_seq=33 Redirect Host(New nexthop: 192.168.1.12)
From 192.168.1.11 icmp_seq=43 Destination Host Unreachable
From 192.168.1.11 icmp_seq=44 Destination Host Unreachable

==="ping 192.168.1.12" in guest A (test 2):===
PING 192.168.1.12 (192.168.1.12) 56(84) bytes of data.
From 192.168.1.1: icmp_seq=2 Redirect Host(New nexthop: 192.168.1.12)
From 192.168.1.11 icmp_seq=11 Destination Host Unreachable
From 192.168.1.11 icmp_seq=12 Destination Host Unreachable

==="ping 192.168.1.12" in guest A (test 3):===
PING 192.168.1.12 (192.168.1.12) 56(84) bytes of data.
From 192.168.1.1: icmp_seq=2 Redirect Host(New nexthop: 192.168.1.12)
From 192.168.1.1: icmp_seq=3 Redirect Host(New nexthop: 192.168.1.12)

==="ping 192.168.1.12" in guest A (test 4):===
(no response)
 
 
==="ping 192.168.1.11" in guest B (test 1):===
PING 192.168.1.11 (192.168.1.12) 56(84) bytes of data.
From 192.168.1.1: icmp_seq=33 Redirect Host(New nexthop: 192.168.1.11)

==="ping 192.168.1.11" in guest B (test 2):===
PING 192.168.1.11 (192.168.1.11) 56(84) bytes of data.
From 192.168.1.12 icmp_seq=1 Destination Host Unreachable
From 192.168.1.12 icmp_seq=2 Destination Host Unreachable

==="scp MyFile root@192.168.1.101" in both guest A and guest B: successful====
successful: 

==="ssh 192.168.1.12" from host (test 1):===
"du": successful
"exit": took a long time to logout

==="ssh 192.168.1.12" from host (test 2):===
It took a long time for "password" prompt to show up.
 
==="scp MyFile root@192.168.1.12:/tmp" from host:===
(no response)


It looks to me that the only reliable and fast communications are those commands (ping, scp, ssh) initialiated from within guests A and B to the host.

Best regards,
CN


--- 本郵件來自HiNet WebMail ---

Reply to: