internet connection issue

This is for discussing general topics about how to use VirtualBox.
noteirak
Site Moderator
Posts: 5231
Joined: 13. Jan 2012, 11:14
Primary OS: Debian other
VBox Version: OSE Debian
Guest OSses: Debian, Win 2k8, Win 7
Contact:

Re: internet connection issue

Post by noteirak »

On your DEV VM

Code: Select all

eth0      Link encap:Ethernet  HWaddr 08:00:27:ee:4f:c0  
          inet addr:10.0.2.15  Bcast:10.0.2.255  Mask:255.255.255.0
On your Example VM

Code: Select all

eth0      Link encap:Ethernet  HWaddr 08:00:27:46:ef:9e  
          inet addr:10.0.2.15  Bcast:10.0.2.255  Mask:255.255.255.0
On your Sandbox VM

Code: Select all

eth0      Link encap:Ethernet  HWaddr 08:00:27:44:f9:7f  
          inet addr:10.0.2.15  Bcast:10.0.2.255  Mask:255.255.255.0
All 3 VM has the same IP on your network that gives you internet - that won't work.
Perryg wrote:All three are using the same 10.0.2.15 address
Perryg already pointed you to the problem, but you failed to see his message or you didn't configure things properly.
Unless each VM as a unique IP on each adapter, this simply won't work.
Hyperbox - Virtual Infrastructure Manager - https://apps.kamax.lu/hyperbox/
Manage your VirtualBox infrastructure the free way!
automatix1311
Posts: 34
Joined: 6. Jan 2013, 22:53
Primary OS: MS Windows 7
VBox Version: OSE self-compiled
Guest OSses: Debian 7, Ubuntu 14.04

Re: internet connection issue

Post by automatix1311 »

OK, that sounds logical. But the other two VMs are working and can connect the internet at the same time. Can you explain it?
noteirak
Site Moderator
Posts: 5231
Joined: 13. Jan 2012, 11:14
Primary OS: Debian other
VBox Version: OSE Debian
Guest OSses: Debian, Win 2k8, Win 7
Contact:

Re: internet connection issue

Post by noteirak »

The fact you have 3 times the same IP won't stop the network transfert to work, it will just cause packet drop depending on who's currently seen as the owner of the IP.
Hyperbox - Virtual Infrastructure Manager - https://apps.kamax.lu/hyperbox/
Manage your VirtualBox infrastructure the free way!
Perryg
Site Moderator
Posts: 34369
Joined: 6. Sep 2008, 22:55
Primary OS: Linux other
VBox Version: OSE self-compiled
Guest OSses: *NIX

Re: internet connection issue

Post by Perryg »

Actually I misquoted. It is when you have more than 1 NAT Nic on a machine that you get the 10.0.2.* 10.0.3.* & so on.

It is actually possible to have 10.0.2.15 on multiple guests as long as they do not have more than one NAT Nic per machine.

This does not hold true to host only as these must have unique IPs, but this adapter is not used for the Internet.
You can set the host only up to use static as long as you remember that you do not use a gateway on host only. Since host only resembles a loopback and not a gateway connection, setting a gateway will stop the network from working.
automatix1311
Posts: 34
Joined: 6. Jan 2013, 22:53
Primary OS: MS Windows 7
VBox Version: OSE self-compiled
Guest OSses: Debian 7, Ubuntu 14.04

Re: internet connection issue

Post by automatix1311 »

First of all: Thanks at you both!
Perryg wrote:Actually I misquoted. It is when you have more than 1 NAT Nic on a machine that you get the 10.0.2.* 10.0.3.* & so on.

It is actually possible to have 10.0.2.15 on multiple guests as long as they do not have more than one NAT Nic per machine.

This does not hold true to host only as these must have unique IPs, but this adapter is not used for the Internet.
You can set the host only up to use static as long as you remember that you do not use a gateway on host only. Since host only resembles a loopback and not a gateway connection, setting a gateway will stop the network from working.
Thank you for the detailed explanation! Now I have deactivated the gateway in the /etc/network/interfaces:

Code: Select all

# 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

# The primary network interface
auto eth0
#NetworkManager
iface eth0 inet dhcp

# The secondary network interface
auto eth1
iface eth1 inet static
        address 192.168.56.102
        netmask 255.255.255.0
#       gateway 192.168.56.1
and voilà -- after restarting the network

Code: Select all

# service networking restart
I can conntect to the internet!

Some last questions...

@noteirak: You mean, those problems, as I had, should not appear by using one Host-Only adapter per VM, right? So, if I want to use three VMs with static IPs, the easies way would be to use three adapters ([VB menu] → File → Preferences… → Network) like "VirtualBox Host-Only Ethernet Adapter". Is it correctly?

@Perryg: You said "You can set the host only up to use static as long as you remember that you do not use a gateway on host only." I've taken a look into the network settings of my other two VMs (Dev and Example). They use a gateway:
Network-Settings-Eth1.png
Network-Settings-Eth1.png (33.79 KiB) Viewed 1667 times
Do you an idea, why they nevertheless work?
Perryg
Site Moderator
Posts: 34369
Joined: 6. Sep 2008, 22:55
Primary OS: Linux other
VBox Version: OSE self-compiled
Guest OSses: *NIX

Re: internet connection issue

Post by Perryg »

The VBox host-only adapter was developed to allow the host and guest to communicate even when no real network was present. It works much like a loopback and as such does not have the necessary logic to allow Internet access. VBox NAT ( the default ) is so you can access the Internet when there is no router, or when you can not actually use an IP address due to network policy.

Most common uses are the host-only and NAT so the guest can access the Internet and the host + guest can communicate. With that said it is possible to make the host-only communicate with the Internet but this is not supported as it is not the intended use and can actually cause issues especially if it is not done properly.

You should deactivate the host-only on all the guests and test. You should be able to get to the Internet with just the VBox NAT. Then enable the host-only and disable the VBox NAT and you should be able to communicate with the host and guest/s but no Internet access. If this holds true then you can turn the VBox NAT back on and all should work properly. If you can actually access the Internet with just the host-only then I would think you have set up a route in the host to handle this and is not something I would want to address due to the previous statement above where I say it should not be done unless you know exactly what you are doing.
automatix1311
Posts: 34
Joined: 6. Jan 2013, 22:53
Primary OS: MS Windows 7
VBox Version: OSE self-compiled
Guest OSses: Debian 7, Ubuntu 14.04

Re: internet connection issue

Post by automatix1311 »

Perryg wrote:The VBox host-only adapter was developed to allow the host and guest to communicate even when no real network was present. It works much like a loopback and as such does not have the necessary logic to allow Internet access. VBox NAT ( the default ) is so you can access the Internet when there is no router, or when you can not actually use an IP address due to network policy.

Most common uses are the host-only and NAT so the guest can access the Internet and the host + guest can communicate. With that said it is possible to make the host-only communicate with the Internet but this is not supported as it is not the intended use and can actually cause issues especially if it is not done properly.
Thank you for the explanation!
Perryg wrote:You should deactivate the host-only on all the guests and test. You should be able to get to the Internet with just the VBox NAT. Then enable the host-only and disable the VBox NAT and you should be able to communicate with the host and guest/s but no Internet access. If this holds true then you can turn the VBox NAT back on and all should work properly.
Exactly, I did so and first I could access the internet from the guest, then I could access the guest from the host, but without internet connection on the guest.
Perryg wrote:If you can actually access the Internet with just the host-only then I would think you have set up a route in the host to handle this and is not something I would want to address due to the previous statement above where I say it should not be done unless you know exactly what you are doing.
No-no-no, you have misunderstood me. On all the three VMs both NAT and Host-Only are still activated. The only thing I've changed was the gateway setting in the /etc/network/interfaces of the Sandbox. But on the other two VMs the gateway is still activated and set to 192.168.56.1 -- and the are working fine (internet and access from host) and don't trouble each other.

Anyway, it works finally.

Thanks a lot for you help!
Post Reply