Not able to access internet from guest inside vm using "NAT Network"

I am not able to connect to the internet from the guest vm, works fine with the host.
Host: openSUSE Leap 42.1 Guest: Centos 7
Installed centos7 as a virtual machine using Oracle virtual box.
Adapter 1: Attached to : NAT Network (NatNetwork)
Adapter 2: Host-only adapter (vboxnet0)
So the idea of the setup is to use the internet using the “NAT Network” adapter in the vm and host-only for interacting with host. Tried without using the host-only adapter, and tried both enabling and disabling ‘supports dhcp’ in the NAT Network preferences. Nothing seems to work and i don’t know what settings to give to make it work.

Check in Network > Advanced that the adapter type is “Paravirtualized Network (virtio-net)”, it works that way here… with a Leap guest on a Leap host (I don’t know if CentOS has special requirements).

First,
Once working, you won’t need a “Host Only” network for Guest <> Host connections.
Just select “NAT-network” for your connection (which assigns different IP addresses) instead of NAT (where all Guests share the same IP address)

As usual,
Have you experience troubleshooting networking in general? Troubleshooting virtual networking starts off not any different than troubleshooting physical networks… ie ip addr (or ifconfig), ip route, ping IP addresses, possibly run a traceroute.

If you have little networking experience or need to have your troubleshooting analyzed, post here.

Regarding specifying virtio, AFAIK it’s only a YMMV performance option and not necessarily critical.
In fact, depending on the virtualization technology virtio is either being deprecated (VMware) or recommended (libvirt).

TSU

I changed to “Paravirtualized Network (virtio-net)” its still not working. Can you tell me your other network settings ? LIke inside File-Preferences-Network- Have you enabled “supports DHCP” option for your “NATNetwork” there ? And what are the network settings for the NATnetwork adapter (inside your vm) ?

Well its not working, don’t know why.

Like everything virtual, if you want a quick way to undo any experimentation, always create a copy of your Guest… Or take snapshots.
I prefer making complete copies of any base “golden” images and take snapshots for lesser modifications.

  1. Before anything else, is this a CentOS Guest that was built on this machine or was it created elsewhere, not on this machine?

  2. Assuming your machine “centgui” is your Guest, I don’t know why you have bridging devices (virbr0 and virbr1) and those could be screwing up your machine. If this is your Guest and there is no good reason to have these devices, remove them with the following command, then reboot and run “ip addr” again

brctl delbr virbr0 virbr0-nic

TSU

Nothing here under File-Preferences-Network, and namely no DHCP: with this setup all protocols are managed by the host system AFAIK.

Under VM settings, Adapter 1
Enable Network Adapter
Attached to NAT
Advanced > Type (virtio-net)
Promiscuous mode : Deny
MAC Address (automatically generated)
Cable connected
No Port Forwarding.

Hope this helps.

Oh yours is Attached to: NAT , my post is about Attached to “NAT Network” and not just NAT.

Sorry for misreading the fine print… maybe you are setting up a server in the VM?
So I leave you to the expert hands of tsu2 :wink:

  1. yes this is centos guest that was built on this machine.

  2. yeah i don’t know what why virbr0 is there,i don’t see virbr1 though . Few weeks back i tried KVM install so there was virtual network device virbr0 running in host, so it would auto connect in my Leap host, i thought it might be that so i disabled that network and set Autostart to ‘never’ in QEMU/KVM connection details. To check if this is interfering i created another network there but that didn’t seem to appear inside the guest vm in virtual box from ‘ip a’ (checked after reboots too both host and guest)

brctl delbr virbr0 virbr0-nic

gives bridge virbr0 is still up; can’t delete it and can’t delete bridge virbr0-nic: Operation not permitted.
So i tried

 ip link set virbr0 down 
brctl delbr virbr0 

 ip link delete virbr0-nic  


Now both disappeared from ‘ip a’ but they appear again after i reboot. :frowning: So back to where i was.
(Tried both “INTEL PRO /1000 MT Desktop(82540EM)” and Paravirtualized Network (Virtio-Net) )

OK,
That was important that your Guest wasn’t copied from somewhere, that introduces other issues.

That was telling that you weren’t able to delete your bridge devices.

Try deleting only after “ifdown”
If that doesn’t work, the stop your networking service with one of the following, then deleting

systemctl stop network
systemctl stop wicked

The bridge devices should not exist in a properly configured Guest unless there is a special reason.
When you install and configure a bridge device, it complicates your configuration unnecessarily and increases possible mistakes.
Bridge devices in general should only be installed in the Host.

As always, weigh the effort and purpose for repairing/fixing vs simply creating new… Typically, if you deploy your install media as a file, building a new Guest should take under an hour require next to no thinking. And, if you do this, create your “golden image” as I described earlier to save time in the future (you’d only need to clone your golden image to create a new working Guest).

TSU

yes will create my “golden image” from next time. Now i have removed virbr0 and virbr0-nic and rebooted, it also doesn’t appear in ‘ip a’ now. But still couldn’t get the internet connectivity in the guest.

Imgur

Ok,
Your network configuration looks correct now.

Next step should be to do normal troubleshooting tests…

From within the Guest,

  • Ping the default gateway by IP address
  • Ping a remote host beyond the default gateway by IP address.
  • Do a traceroute to a remote host by IP address.
  • Repeat your tests using a FQDN if available. Remember that there will generally be no name resolution between the Host and Guest but there should be to remote hosts.

If you have another Guest and have sufficient hardware resources <and> you are configured with “nat-network” and not “nat” you should also be able to test connections between your two Guests.

Just a FYI - Awhile back when you found “Install virtual networking” which installs KVM or Xen (or manage linux containers), that is only for installing on a Host machine… You should not have installed that into a Guest machine.

Although should not be critical, further cleaning up your machine you should uninstall your libvirt packages… do a search for libvirt and uninstall everything that’s returned

zypper se libvirt

Then uninstall

zypper rm *package_list *

TSU

FYI, I tried with “Adapter 1 Attached to: NAT Network
and
NAT Network Details > Network Options: [Y] Supports DHCP ; [N] Supports IPv6 ; No Port Forwarding.
With every other setup left at default or automatic, everything works OK, apparently.

I did notice though that while pinging external servers by IP address always worked, pinging by www name or browsing with Firefox required disconnecting and reconnecting the “Wired connection” in the VM: a DNS configuration glitch?
[BTW I did no explicit DNS config, just used the default DNS of my Internet provider].

HTH

In your case,
I’d suspect a dns resolver cache with stale entries.
I don’t know if you can verify (when the problem is happening) by querying using nslookup.

In any case, the proper solution generally would be to delete/reset the local resolver cache… I don’t know if what you did remaking your “wired connection” might also have accomplished this.

Once fixed, you should not see that problem again.

TSU

Thanks, this is apparently the case.

kde@linux-0uwp:~> nslookup www.google.com                                                                                                                                        
;; connection timed out; no servers could be reached                                                                            

>>>> and after disconnecting and reconnecting "Wired connection 1" in the KDE tray I got

kde@linux-0uwp:~> nslookup www.google.com                                                                                                                                         
Server:         62.13.169.95                                                                                                                                                      
Address:        62.13.169.95#53                                                                                                                                                   
                                                                                                                                                                                  
Non-authoritative answer:                                                                                                                                                         
Name:   www.google.com                                                                                                                                                            
Address: 173.194.112.80                                                                                                                                                           
Name:   www.google.com
Address: 173.194.112.82
Name:   www.google.com
Address: 173.194.112.84
Name:   www.google.com
Address: 173.194.112.83
Name:   www.google.com
Address: 173.194.112.81

kde@linux-0uwp:~>

The problem shows up again sometime when I turn off/turn on again the network connection on the Host, the guest still uses a cached DNS that might or might not be still available through my provider.
Maybe configuring a public DNS solves this, but I’m not willing to steal this thread, unless it is useful to the OP of course.

Restarting the ns cache daemon service should clear the cache.

The long-standing command to do this is

/etc/init.d/nscd restart

I haven’t had occasion to need to do this since openSUSE implemented systemd, the following is likely the preferred command today

systemcl restart nscd.service

TSU

I try to ping from vm(10.0.2.6) to my host ( ping 192.168.1.2)
I get Destination Host unreachable.
And

But i can ping between two VM’s(like between 10.0.2.6 to 10.0.2.8) .

I didn’t install that virutal networking(virbr0,virbr0-nic) in my guest vm (centos installed with “server with gui”) it just came along with this one gui install(don’t even have the internet connectivity to install stuff) , but i don’t see it in my other two centos vms as they are minimal installs. so i don’t think KVM should be giving any problems to virtualbox.

I just checked my virtualbox logs and i am seeing lot of these errors:
http://susepaste.org/38448579

00:12:27.468161 nspr-5   VM 'server1' starts using NAT network 'NatNetwork'
00:12:27.502357 nspr-4   Failed to open "/dev/vboxdrvu", errno=13, rc=VERR_VM_DRIVER_NOT_ACCESSIBLE
00:12:27.511711 nspr-5   Failed to open "/dev/vboxdrvu", errno=13, rc=VERR_VM_DRIVER_NOT_ACCESSIBLE
00:12:29.548046 nspr-4   Failed to open "/dev/vboxdrvu", errno=13, rc=VERR_VM_DRIVER_NOT_ACCESSIBLE
00:15:11.250222 nspr-2   Failed to open "/dev/vboxdrvu", errno=13, rc=VERR_VM_DRIVER_NOT_ACCESSIBLE
00:15:12.128368 nspr-5   Failed to open "/dev/vboxdrvu", errno=13, rc=VERR_VM_DRIVER_NOT_ACCESSIBLE
00:15:12.626254 nspr-2   Failed to open "/dev/vboxdrvu", errno=13, rc=VERR_VM_DRIVER_NOT_ACCESSIBLE

SUSE Paste

06:06:32.137570 nspr-2   VM 'centgui' stops using NAT network 'NatNetwork'
06:06:32.153072 nspr-7   Failed to open "/dev/vboxdrvu", errno=13, rc=VERR_VM_DRIVER_NOT_ACCESSIBLE
06:07:44.642029 nspr-6   Failed to open "/dev/vboxdrvu", errno=13, rc=VERR_VM_DRIVER_NOT_ACCESSIBLE
06:07:47.316054 nspr-4   Failed to open "/dev/vboxdrvu", errno=13, rc=VERR_VM_DRIVER_NOT_ACCESSIBLE

Hello what is the version of virtualbox you’re using on Leap and where did you get(install) it from ?

Tests referred to on this thread were done on VirtualBox 5.0.12 r104815 installed from upstream (www.virtualbox.org).
But I’ve been using VBox from OpenSUSE repos as well from 5.0.6 to 5.0.10 without noticing any real difference to be honest.

BTW, did you try to ping a well known external server like 8.8.8.8 ? Or nslookup as suggested by tsu2?

The virtualbox site(Linux_Downloads – Oracle VM VirtualBox) doesn’t have rpm downloads for openSUSE Leap 42.1, only openSUSE 13.2 and openSUSE 13.1 are available. what did you download from there for using in Leap ?

I tried to ping 8.8.8.8 inside the VM and i get the same thing:
Destination Host unreachable.
nlookup 8.8.8.8 gives:
;; connection timed out; try next origin
;; connection timed out; no servers could be reached