Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[Solved] QEMU guest VM can not see host/internet.
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
Wizumwalt
Guru
Guru


Joined: 20 Aug 2006
Posts: 504

PostPosted: Sun Feb 16, 2020 10:36 pm    Post subject: [Solved] QEMU guest VM can not see host/internet. Reply with quote

Installed is QEMU-4.0.0-rc50 and I use the following in a bash script to start a guest vm. The VM boots and runs the image just fine.

The problem is with the networking, the guest cannot see the host or the internet, nor can the host see the guest. I have a bridge setup on the host. I had this working years ago, but as QEMU evolved, I've tried to update the network settings to this command, to no avail.

What I'm eventually after is running two guest VM's that can talk to each other and the host and the internet. And the host needs to talk to each guest.

Code:
$ qemu-system-x86_64 -device virtio-net-pci,netdev=n0,mac=52:54:00:12:34:60 -netdev tap,id=n0,ifname=tap0,script=no,downscript=no -smp 2 -kernel ./kernel-${KVERS} -append "root=/dev/vda console=ttyS0 video-nofb resolution=1024x768" -initrd ~/tools/gentoo-x86_64-initramfs.cpio.gz -m 1G -drive format=raw,file=./gentoo-x86_64-guest_1.img,if=virtio,cache=none -serial stdio


Host machines /etc/conf.d/net:
Code:
    tuntap_tap0="tap"
    tuntap_tap1="tap"
    config_tap0="null"
    config_tap1="null"
    tunctl_tap0="-u me"
    tunctl_tap1="-u me"

    bridge_br0="eno1 tap0 tap1"
    config_br0="192.168.10.10/24"
    routes_br0="default via 192.168.10.1"
#    rc_net_br0="net.tap0 net.tap1"

    # vpn dns's
    dns_servers_br0="x.x.x.x x.x.x.x"

    bridge_forward_delay_br0=0
    bridge_hello_time_br0=1000
    bridge_stp_state_br0=0


Host interfaces:
Code:
$ ip 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 brd 127.255.255.255 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: eno1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master br0 state UP group default qlen 1000
    link/ether 94:de:80:b4:7c:c6 brd ff:ff:ff:ff:ff:ff
    inet 192.168.10.172/24 brd 192.168.10.255 scope global eno1
       valid_lft forever preferred_lft forever
    inet6 fe80::96de:80ff:feb4:7cc6/64 scope link
       valid_lft forever preferred_lft forever
3: sit0@NONE: <NOARP> mtu 1480 qdisc noop state DOWN group default qlen 1000
    link/sit 0.0.0.0 brd 0.0.0.0
4: tap0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master br0 state UP group default qlen 1000
    link/ether be:dd:70:df:7f:f4 brd ff:ff:ff:ff:ff:ff
    inet6 fe80::bcdd:70ff:fedf:7ff4/64 scope link
       valid_lft forever preferred_lft forever
5: tap1: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast master br0 state DOWN group default qlen 1000
    link/ether 7a:01:d8:a9:59:aa brd ff:ff:ff:ff:ff:ff
6: docker0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default
    link/ether 02:42:c4:84:d5:51 brd ff:ff:ff:ff:ff:ff
    inet 172.17.0.1/16 brd 172.17.255.255 scope global docker0
       valid_lft forever preferred_lft forever
26: br0: <BROADCAST,MULTICAST,PROMISC,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether 7a:01:d8:a9:59:aa brd ff:ff:ff:ff:ff:ff
    inet 192.168.10.10/24 brd 192.168.10.255 scope global br0
       valid_lft forever preferred_lft forever
    inet6 fd81:a47a:1f13:0:7801:d8ff:fea9:59aa/64 scope global dynamic mngtmpaddr
       valid_lft forever preferred_lft forever
    inet6 fe80::7801:d8ff:fea9:59aa/64 scope link
       valid_lft forever preferred_lft forever


Host routing table:
Code:
$ ip r
default via 192.168.10.1 dev br0 metric 7
172.17.0.0/16 dev docker0 proto kernel scope link src 172.17.0.1 linkdown
192.168.10.0/24 dev br0 proto kernel scope link src 192.168.10.10


Update:

Guest interfaces:
Code:
$ ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 brd 127.255.255.255 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 52:54:00:12:34:60 brd ff:ff:ff:ff:ff:ff
    inet 192.168.10.20/24 brd 192.168.10.255 scope global eth0
       valid_lft forever preferred_lft forever
    inet6 fd81:a47a:1f13:0:5054:ff:fe12:3460/64 scope global mngtmpaddr dynamic
       valid_lft forever preferred_lft forever
    inet6 fe80::5054:ff:fe12:3460/64 scope link
       valid_lft forever preferred_lft forever
3: sit0@NONE: <NOARP> mtu 1480 qdisc noop state DOWN group default
    link/sit 0.0.0.0 brd 0.0.0.0


Guest routing table:
Code:
 $ ip r
default via 192.168.10.1 dev eth0  metric 2
127.0.0.0/8 via 127.0.0.1 dev lo
192.168.10.0/24 dev eth0  proto kernel  scope link  src 192.168.10.20


Any help much appreciated.


Last edited by Wizumwalt on Tue Feb 18, 2020 3:40 am; edited 4 times in total
Back to top
View user's profile Send private message
Hu
Moderator
Moderator


Joined: 06 Mar 2007
Posts: 15482

PostPosted: Mon Feb 17, 2020 1:55 am    Post subject: Reply with quote

Please post the output of ip a ; ip r as seen from a guest, too. This will tell us whether the guest detected the virtual NIC, whether it is configured, and whether the guest knows how to route traffic. Please also show an example of a command in the guest that is unable to use the network as intended, including the error messages it prints.
Back to top
View user's profile Send private message
Wizumwalt
Guru
Guru


Joined: 20 Aug 2006
Posts: 504

PostPosted: Mon Feb 17, 2020 2:37 am    Post subject: Reply with quote

Hu wrote:
Please post the output of ip a ; ip r as seen from a guest, too. This will tell us whether the guest detected the virtual NIC, whether it is configured, and whether the guest knows how to route traffic. Please also show an example of a command in the guest that is unable to use the network as intended, including the error messages it prints.


I've appended the guest interfaces after a reboot.

Also, all my attempts really trashed the routing tables and interfaces. The reboot cleaned them up a good bit. As I'm still experimenting, I changed the qemu line to:

Code:
-netdev bridge,id=v0 -device virtio-net-pci,netdev=v0,mac=52:54:00:12:34:60


I may have wasted a lot of time and QEMU lines because I've been trying to test w/ pings. I can ssh from host-to-guest and guest-to-host using the above line. But doing:
Code:
$ sudo emerge --sync

results in ...

Code:
$ sudo emerge --sync

python-exec: Invalid impl in /etc/python-exec/python-exec.conf: python3.1
>>> Syncing repository 'gentoo' into '/usr/portage'...
!!! getaddrinfo failed for 'rsync.gentoo.org': [Errno -3] Temporary failure in name resolution
>>> Starting rsync with rsync://rsync.gentoo.org/gentoo-portage...
>>> Checking server timestamp ...
timed out
rsync error: received SIGINT, SIGTERM, or SIGHUP (code 20) at rsync.c(636) [Receiver=3.1.2]
>>> Retrying...
!!! Exhausted addresses for rsync.gentoo.org


I do have my nameservers for my vpn provider in /etc/resolv.conf.
Back to top
View user's profile Send private message
Wizumwalt
Guru
Guru


Joined: 20 Aug 2006
Posts: 504

PostPosted: Tue Feb 18, 2020 1:55 am    Post subject: Reply with quote

Ugh, nevermind. I turned off iptables and it worked. So it's just the rules I have to work with. Thanks.
Back to top
View user's profile Send private message
Hu
Moderator
Moderator


Joined: 06 Mar 2007
Posts: 15482

PostPosted: Tue Feb 18, 2020 3:04 am    Post subject: Reply with quote

Post your rules, as shown by iptables-save, and someone may be able to help you debug them.
Back to top
View user's profile Send private message
Wizumwalt
Guru
Guru


Joined: 20 Aug 2006
Posts: 504

PostPosted: Tue Feb 18, 2020 3:40 am    Post subject: Reply with quote

Thanks Hu, but I'm sure I can manage from here. And thank you for the help. I will mark it solved.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum