Share the guest's internet connection to the host

Discussions related to using VirtualBox on Linux hosts.

Share the guest's internet connection to the host

Postby knutola » 27. Oct 2009, 13:30

Hi. Thank you so much for a great software. :D
I am using Ubuntu 9.04 as Host and Virtualbox 3.0.8 with USB support. I have Windows Vista as guest with the latest updates from Windows Update.
My computer is a Laptop and I want Internet access through my USB 3G mobile broadband card when I am travelling.
Unfortunately there are no drivers for Ubuntu. :cry: But in the windows guest OS I have managed to get a great connection. :)

I am in need for an internet access to the ubuntu host from the windows guest. Is that possible? :?:
I have tried a lot of different ways that are suggested in the forum with no results.... :|

Any suggestions?
knutola
 
Posts: 5
Joined: 27. Oct 2009, 13:20
Primary OS: Ubuntu other
VBox Version: OSE Debian
Guest OSses: Windows Vista

Re: Share the guest's internet connection to the host

Postby Sasquatch » 27. Oct 2009, 14:55

knutola wrote:I have tried a lot of different ways that are suggested in the forum with no results....

It would help if you noted them here, so we don't give the same suggestions.
Read the Forum Posting Guide before opening a topic.
VirtualBox FAQ: Check this before asking questions.
Online User Manual: A must read if you want to know what we're talking about.
Howto: Install Linux Guest Additions
Howto: Use Shared Folders on Linux Guest
See the Tutorials and FAQ section at the top of the Forum for more guides.
Try searching the forums first with Google and add the site filter for this forum.
E.g. install guest additions site:forums.virtualbox.org

Retired from this Forum since OSSO introduction.
Sasquatch
Volunteer
 
Posts: 17800
Joined: 17. Mar 2008, 13:41
Location: /dev/random
Primary OS: Debian other
VBox Version: PUEL
Guest OSses: Windows XP, Windows 7, Linux

Re: Share the guest's internet connection to the host

Postby knutola » 29. Oct 2009, 04:37

Thanks for your reply. Here is what I have done.
I am not so good working with networks in Ubuntu. So please come with any suggestions. But what I think is important is to point the default router on the HOST to the vboxnet0. So I activated the Host only adapter. Since I want to share the internet from the Guest, I turned off the DHCP in the VirtualBox network settings for the vboxnet0 and started the Internet Sharing on the GUEST's 3G USB Mobile Internet network settings. But it did not give any address to the Host's vboxnet0.

(I tried to share internet with 3 other computers without using VirtualBox and that is working. But since I am an Ubuntu user and there are no drivers for this 3G USB mobile connector , I have to go get the internet connection in a Windows Vista Gust through VirtualBox and share the internet with the host, that is still not working)
knutola
 
Posts: 5
Joined: 27. Oct 2009, 13:20
Primary OS: Ubuntu other
VBox Version: OSE Debian
Guest OSses: Windows Vista

Re: Share the guest's internet connection to the host

Postby Sasquatch » 29. Oct 2009, 11:32

If you share the connection inside the Guest, does that Host-Only interface get the proper IP (192.168.0.1 by default)? If it does, run a dhclient as root on the Host with the vboxnet0 interface name as argument (with none it will run for all available interfaces). Only then will it work, or at least should.
Read the Forum Posting Guide before opening a topic.
VirtualBox FAQ: Check this before asking questions.
Online User Manual: A must read if you want to know what we're talking about.
Howto: Install Linux Guest Additions
Howto: Use Shared Folders on Linux Guest
See the Tutorials and FAQ section at the top of the Forum for more guides.
Try searching the forums first with Google and add the site filter for this forum.
E.g. install guest additions site:forums.virtualbox.org

Retired from this Forum since OSSO introduction.
Sasquatch
Volunteer
 
Posts: 17800
Joined: 17. Mar 2008, 13:41
Location: /dev/random
Primary OS: Debian other
VBox Version: PUEL
Guest OSses: Windows XP, Windows 7, Linux

Re: Share the guest's internet connection to the host

Postby knutola » 29. Oct 2009, 14:22

The Host only adapter in the GUEST shows 192.168.0.1 as you say. So sharing should be set up
But I can't get any address from the DHCP on the HOST side. I had to turn off the DHCP on the host only adapter. Should I reboot the computer? I did no, but tok a GUEST shutdown and restartet VirtualBox.

Here are the results from the dhclient command.

root@ko-laptop:~# dhclient vboxnet0
There is already a pid file /var/run/dhclient.pid with pid 11929
killed old client process, removed PID file
Internet Systems Consortium DHCP Client V3.1.1
Copyright 2004-2008 Internet Systems Consortium.
All rights reserved.
For info, please visit http://www.isc.org/sw/dhcp/

wmaster0: unknown hardware address type 801
wmaster0: unknown hardware address type 801
Listening on LPF/vboxnet0/0a:00:27:00:00:00
Sending on LPF/vboxnet0/0a:00:27:00:00:00
Sending on Socket/fallback
DHCPREQUEST of 192.168.56.3 on vboxnet0 to 255.255.255.255 port 67
DHCPREQUEST of 192.168.56.3 on vboxnet0 to 255.255.255.255 port 67
DHCPDISCOVER on vboxnet0 to 255.255.255.255 port 67 interval 5
DHCPDISCOVER on vboxnet0 to 255.255.255.255 port 67 interval 12
DHCPDISCOVER on vboxnet0 to 255.255.255.255 port 67 interval 13
DHCPDISCOVER on vboxnet0 to 255.255.255.255 port 67 interval 20
DHCPDISCOVER on vboxnet0 to 255.255.255.255 port 67 interval 11
No DHCPOFFERS received.
Trying recorded lease 192.168.56.3
resolvconf: Error: /etc/resolv.conf must be a symlink
bound: renewal in 1193 seconds.
knutola
 
Posts: 5
Joined: 27. Oct 2009, 13:20
Primary OS: Ubuntu other
VBox Version: OSE Debian
Guest OSses: Windows Vista

Re: Share the guest's internet connection to the host

Postby Sasquatch » 29. Oct 2009, 14:48

Then we go to the manual way. Give the vboxnet0 the IP 192.168.0.3, netmask 255.255.255.0, gateway 192.168.0.1 and DNS should be the same as the Guest DNS server. I don't think that Windows ICS also routes DNS, but you can always try it.
Read the Forum Posting Guide before opening a topic.
VirtualBox FAQ: Check this before asking questions.
Online User Manual: A must read if you want to know what we're talking about.
Howto: Install Linux Guest Additions
Howto: Use Shared Folders on Linux Guest
See the Tutorials and FAQ section at the top of the Forum for more guides.
Try searching the forums first with Google and add the site filter for this forum.
E.g. install guest additions site:forums.virtualbox.org

Retired from this Forum since OSSO introduction.
Sasquatch
Volunteer
 
Posts: 17800
Joined: 17. Mar 2008, 13:41
Location: /dev/random
Primary OS: Debian other
VBox Version: PUEL
Guest OSses: Windows XP, Windows 7, Linux

Re: Share the guest's internet connection to the host

Postby knutola » 3. Nov 2009, 14:31

Thanks that worked! :D :D :D I made a script to set the ip, dns and default route. I put the dns addresses in a local resolf.conf file containing nameserver <IPADDRESS>. I should maybe have written that in bash syntax, but I did it the easy way by copying files. When I am hooking up my wlan after beeing using the 3G USB connection, it (Networkmanager applet in gnome) sets automatically back the normal network settings, even my other dns for my wlan internet connectivity.

sudo ifconfig vboxnet0 192.168.0.3 netmask 255.255.255.0
sudo route add default gw 192.168.0.1
sudo cp div/software/resolv.conf /etc/resolv.conf
knutola
 
Posts: 5
Joined: 27. Oct 2009, 13:20
Primary OS: Ubuntu other
VBox Version: OSE Debian
Guest OSses: Windows Vista

Re: Share the guest's internet connection to the host

Postby Sasquatch » 3. Nov 2009, 15:01

If you put it in a script, and run the script with sudo, you can automate everything. Now, in my example I use the OpenDNS DNS servers, feel free to change it to your own liking.

Code: Select all   Expand viewCollapse view
#!/bin/bash
ifconfig vboxnet0 192.168.0.3 255.255.255.0
route add default gw 192.168.0.1
echo "nameserver 208.67.220.220\nnameserver 208.67.222.222" > /etc/resolv.conf
Read the Forum Posting Guide before opening a topic.
VirtualBox FAQ: Check this before asking questions.
Online User Manual: A must read if you want to know what we're talking about.
Howto: Install Linux Guest Additions
Howto: Use Shared Folders on Linux Guest
See the Tutorials and FAQ section at the top of the Forum for more guides.
Try searching the forums first with Google and add the site filter for this forum.
E.g. install guest additions site:forums.virtualbox.org

Retired from this Forum since OSSO introduction.
Sasquatch
Volunteer
 
Posts: 17800
Joined: 17. Mar 2008, 13:41
Location: /dev/random
Primary OS: Debian other
VBox Version: PUEL
Guest OSses: Windows XP, Windows 7, Linux

Re: Share the guest's internet connection to the host

Postby knutola » 3. Nov 2009, 15:26

Yep. I put it in a script. But thank you for this much prettier script than mine! I guess other people also will have use of what we have been finding out.

Knut Ola
knutola
 
Posts: 5
Joined: 27. Oct 2009, 13:20
Primary OS: Ubuntu other
VBox Version: OSE Debian
Guest OSses: Windows Vista

Re: Share the guest's internet connection to the host

Postby Otto321 » 9. Dec 2009, 05:08

Comments for newbies from a newbie... in regards to ubuntu 9.10 virtualbox 3.1.0

***The script must be run after each time VirtualBox is restarted.

My step by step how to set it up:

1. In guest connect to internet.
2. Start button -> Run -> command.
3. ipconfig /all and note the active DNS
4. In gedit revise the original script as advised below in [] and save it. I will call it vbgi here.
#!/bin/bash [I think this is normally in ubuntu #!/bin/sh]
ifconfig vboxnet0 192.168.0.3 255.255.255.0 [sudo ifconfig vboxnet0 192.168.0.3 netmask 255.255.255.0]
route add default gw 192.168.0.1 [ok}
echo "nameserver 208.67.220.220" > /etc/resolv.conf [instead of 208.67.220.220 put your active DNS and pls note your DNS may change at any time u reconnect to internet]

Note: running the script will overwrite your existing resolv.conf u might wanna make a backup.

5. me knowing better I used the file browser to edit permission to be executable and copied it to /bin. But I needed to be root user to do this and u need to be root user to execute the scripts echo command that edits resolv.conf. sudo will not do. 'sudo passwd root', 'su', 'cp vgbi /bin/'. If u later want to disable the root account do a 'sudo passwd -l root'

6. 'vgbi' (as root user)

Troubleshooting..... in guest do a ping www.google.com copy the address and do a ping {address} in host. If it works you have problem with your DNS configuration.

Maybe someone could make scripts and .bat that would take care of this automatically with a initiation from guest Network Connection -> Properties -> Security tab -> Run Script.
Otto321
 
Posts: 1
Joined: 9. Dec 2009, 04:32
Primary OS: Ubuntu other
VBox Version: PUEL
Guest OSses: Windows XP

Re: Share the guest's internet connection to the host

Postby ndedonald » 26. Mar 2010, 10:39

Hello,

This is how I get the internet shared.

I have an HP-550 laptop running Ubuntu 9.10.
I create a shared network on my Wlan. See steps below;

- Right-click network icon at the top beside the date and select Edit Connections
- Select the Wireless tab and add a new connection

Wireless Tab
- SSID name: sharenet
- Mode: Ad-hoc

Now apply so as to create a network with name sharenet in Ad-hoc mode.

Run Virtualbox and edit your Guest OS Network settings.
- Right-click your Guest OS icon and select settings from the menu
- Select network on the left panel from the settings window
- Select Adapter 4
- Check the Enable Network Adapter box
- From Attached to: Select Bridge Adapter
- From Name: select wlan0 (depending on how your wlan card is installed)
- OK

Considering that you are connected to your sharenet from Ubuntu, start your Guest OS (windows xp)

Now share your mobile broadband like you'll normally do in Windows.
Make sure you share it to the NIC created from your bridge.
Normally XP ICS has some DHCP capability that will serve your wlan0 with an IP

Now try browsing from Ubuntu.

This worked for me.
ndedonald
 
Posts: 1
Joined: 26. Mar 2010, 10:00
Primary OS: Ubuntu other
VBox Version: OSE Debian
Guest OSses: Windows XP

Re: Share the guest's internet connection to the host

Postby Bit Hacker » 6. Jun 2010, 11:37

Awesome post, just what I've been looking for. I'm trying to use CLEAR Motorola WiMax USB in Ubuntu as there is no support for linux as yet. I've installed windowsxp as guest in ubuntu and the version I'm using is 3.2.2. USB is connecting fine in
WindowsXP but I can't use internet in Ubuntu. Can you please tell me how to do it. Here is the configuration that could help you guys. Thanks in advance.

I'm using Two Network Adapters.


Code: Select all   Expand viewCollapse view
Network
Adapter 1:
PCnet-FAST III (NAT)
Adapter 2:
PCnet-FAST III (Host-only adapter, 'vboxnet0')



ipconfig [on Guest windowsXP]



Windows IP Configuration

Code: Select all   Expand viewCollapse view
Ethernet adapter Local Area Connection:  PCnet-FAST III (NAT)

        Connection-specific DNS Suffix  . :
        IP Address. . . . . . . . . . . . : 10.0.2.15
        Subnet Mask . . . . . . . . . . . : 255.255.255.0
        Default Gateway . . . . . . . . . : 10.0.2.2

Ethernet adapter Local Area Connection 3: PCnet-FAST III (Host-only adapter, 'vboxnet0')

        Connection-specific DNS Suffix  . :
        IP Address. . . . . . . . . . . . : 192.168.56.101
        Subnet Mask . . . . . . . . . . . : 255.255.255.0
        Default Gateway . . . . . . . . . :

Ethernet adapter Local Area Connection 2:

        Connection-specific DNS Suffix  . : CLEAR Motorola USB
        IP Address. . . . . . . . . . . . : 10.168.242.33
        Subnet Mask . . . . . . . . . . . : 255.255.192.0
        Default Gateway . . . . . . . . . : 10.168.192.2



IFCONFIG [on Host Ubuntu]



Code: Select all   Expand viewCollapse view
(Ethernet) eth0      Link encap:Ethernet  HWaddr 00:14:22:b9:9d:76 
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
          Interrupt:16

eth1    (Wireless) Link encap:Ethernet  HWaddr 00:13:ce:f0:9b:0d 
          inet6 addr: fe80::213:ceff:fef0:9b0d/64 Scope:Link
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1 errors:0 dropped:5 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 B)  TX bytes:84 (84.0 B)
          Interrupt:17 Base address:0xe000 Memory:dfcff000-dfcfffff

lo        Link encap:Local Loopback 
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:2292 errors:0 dropped:0 overruns:0 frame:0
          TX packets:2292 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:171952 (171.9 KB)  TX bytes:171952 (171.9 KB)

vboxnet0  Link encap:Ethernet  HWaddr 0a:00:27:00:00:00 
          inet addr:192.168.56.1  Bcast:192.168.56.255  Mask:255.255.255.0
          inet6 addr: fe80::800:27ff:fe00:0/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:137 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 B)  TX bytes:21174 (21.1 KB)
Bit Hacker
 
Posts: 2
Joined: 5. Jun 2010, 09:46
Primary OS: Ubuntu other
VBox Version: OSE Debian
Guest OSses: Windows XP

Re: Share the guest's internet connection to the host

Postby pyrocloud » 13. Jun 2010, 13:11

Thank you ndedonald! This is exactly what I was looking for. I wasn't sure if you could bridge a wlan interface and be okay.

To Bit Hakcer, you need to run a script at startup to set the IP, netmask, GW and DNS on the Host machine for it to work properly. The best place to make the script would be /etc/rc.local as it runs as root everything the machine starts. See this thread for another example. http://forums.virtualbox.org/viewtopic.php?f=7&t=31970&start=0

If you still need help let us know.
pyrocloud
 
Posts: 4
Joined: 13. Jun 2010, 10:34
Primary OS: Ubuntu other
VBox Version: PUEL
Guest OSses: Windows XP, Windows 7

Re: Share the guest's internet connection to the host

Postby phoenic » 2. Jul 2010, 10:56

Thank you ndedonald for sharing the big picture... C: I got my internet connection shared through ICS and ad-hoc network. This is how I get it done:
Primary OS
- Right-click network icon at the top beside the date and select Edit Connections
- Select the Wireless tab and add a new connection

Wireless Tab
- SSID name: UbuntuAdhoc
- Mode: Ad-hoc

Wireless Security Tab
- Security: WEP 128-bit Passphrase
- Key: <define your key>

IPv4 Settings Tab
- Method: Manual
- Add an address: 192.168.0.x (for Address substitute x with a number that won't conflict), 255.255.255.0 (Netmask), 192.168.0.1 (for Gateway as the ICS will automatically set the ip of the shared connection to 192.168.0.1)
- Apply and connect to UbuntuAdhoc

Run Virtualbox and edit your Guest OS Network settings.
- Right-click your Guest OS icon and select settings from the menu
- Select network on the left panel from the settings window
- Select Adapter 4
- Check the Enable Network Adapter box
- From Attached to: Select Bridge Adapter
- From Name: select eth1 (because my ad-hoc wireless connection is actually eth1)
- OK

Run Guest OS
- Right-click the internet connection that you want to share and select Properties

Sharing Tab
- Activate Allow other network users to connect through this computer's Internet connection and select OK
- Home networking connection: Local Area Connection 2 (This is actually the Adapter 4 connection)
- OK

Try browsing from the Primary OS. I noticed it needs some time before the connection is actually shared so be patient. But this is really working for me... C:
phoenic
 
Posts: 2
Joined: 30. Jun 2010, 11:07
Primary OS: Ubuntu other
VBox Version: PUEL
Guest OSses: Linux & Windows

Re: Share the guest's internet connection to the host

Postby awsum » 5. Dec 2011, 07:29

I managed to get Internet connection on Guest using bridged network adapter but following steps in previous posts only get me to resolving domain names on host
Code: Select all   Expand viewCollapse view
$ping virtualbox dot org
PING virtualbox dot org (208.91.196.175) 56(84) bytes of data.
^C
--- virtualbox dot org ping statistics ---
26 packets transmitted, 0 received, 100% packet loss, time 25200ms

Any help appreciated.
awsum
 
Posts: 1
Joined: 5. Dec 2011, 07:09
Primary OS: Ubuntu other
VBox Version: OSE Debian
Guest OSses: XP


Return to VirtualBox on Linux Hosts

Who is online

Users browsing this forum: No registered users and 18 guests