LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 04-12-2014, 11:42 PM   #1
satimis
Senior Member
 
Registered: Apr 2003
Posts: 3,695

Rep: Reputation: 56
VM to connect Internet via Host


Hi all

Host Debian 7.3
VM Ubuntu 12.04
Oracle VirtualBox

Cable connection of Host
ISP -> PC
Static IP address
2 NICs

Host can access Internet

/etc/network/interfaces
Code:
# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet static
     address xxx.xxx.xxx.xxx
     netmask xxx.xxx.xxx.xxx
     broadcast xxx.xxx.xxx.xxx
     gateway xxx.xxx.xxx.xxx
/etc/resolv.conf
Code:
nameserver  xxx.xxx.xxx.xxx
nameserver  xxx.xxx.xxx.xxx

Please advice how to make VM connect Intenet via Host?

Would following document relevant?
VirtualBox: Make your virtual machine accessible from your host system but not from the local network
http://slopjong.de/2013/05/14/virtua...local-network/

Thanks

Rgds
satimis
 
Old 04-13-2014, 01:46 AM   #2
Ser Olmy
Senior Member
 
Registered: Jan 2012
Distribution: Slackware
Posts: 3,348

Rep: Reputation: Disabled
VirtualBox allows 6 different kinds of VM NICs:
  1. NAT: The adapter is placed in a special IP subnet served by a virtual router. The router has a built-in DHCP server and DNS proxy, and will NAT outgoing traffic behind the IP address of the hypervisor host.
  2. NAT Network: The VM NIC is connected to a specific "NAT Network". Multiple networks may be created from the VirtualBox GUI, and port forwarding configured.
  3. Bridged Adapter: The VM NIC is bridged to a specific NIC on the hypervisor host. VirtualBox will suggest a MAC address for this NIC.
  4. Host-only Adapter: The VM NIC will appear in a virtual network shared with one of the host hypervisor's virtual adapters (and any number of other VMs). VirtualBox creates one such adapter on the hypervisor by default.
  5. Internal Network: The VM NIC is connected to a virtual, closed network. Any number of VM may share the same internal network, but this network is not accessible from the hypervisor host. One such network ("intnet") is created by default. Any number of internal networks can be created, simply by typing a name in the "Name:" box.
  6. Generic Driver: The VM NIC is connected to a specific driver on the hypervisor host (such as a "Virtual Distributed Ethernet" switch or a UDP Tunnel).
If you just want to access the Internet using the Internet connection of the host computer, try the NAT mode and configure the VM to use DHCP, not "static".

See the VirtualBox documentation/help file for more information.
 
Old 04-13-2014, 02:48 AM   #3
satimis
Senior Member
 
Registered: Apr 2003
Posts: 3,695

Original Poster
Rep: Reputation: 56
Quote:
Originally Posted by Ser Olmy View Post
- snip -
If you just want to access the Internet using the Internet connection of the host computer, try the NAT mode and configure the VM to use DHCP, not "static"
Thanks for your advice.

What I expect to achieve is without router would it be possible to assign static IP to the VM? So that the VM can be browsed on Internet

satimis
 
Old 04-13-2014, 04:03 AM   #4
berndbausch
LQ Addict
 
Registered: Nov 2013
Location: Tokyo
Distribution: Mostly Ubuntu and Centos
Posts: 6,316

Rep: Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002
Quote:
Originally Posted by satimis View Post
Thanks for your advice.

What I expect to achieve is without router would it be possible to assign static IP to the VM? So that the VM can be browsed on Internet

satimis
You don't need a static IP address to browse the internet. A DHCP one is exactly as useful as a static one.

If you choose NAT, your guest will get an address from Virtualbox via DHCP. This is why you have to set eth0 to DHCP in /etc/interfaces on the guest (assuming eth0 is the device connected to the NAT network).

If you need the same address each time you boot the guest, you should be able to configure VirtualBox and/or dnsmasq, the program that implements the DHCP server. I can't help with that, but VirtualBox documentation is pretty good.
 
Old 04-13-2014, 05:28 AM   #5
satimis
Senior Member
 
Registered: Apr 2003
Posts: 3,695

Original Poster
Rep: Reputation: 56
Quote:
Originally Posted by berndbausch View Post
- snip -
If you need the same address each time you boot the guest, you should be able to configure VirtualBox and/or dnsmasq, the program that implements the DHCP server. I can't help with that, but VirtualBox documentation is pretty good.
That what I expect to do. I'll run webserve on VM. I need static IP so that the domain DNS will point to it allowing visitor browsing the website.

I'll make some search on VirtualBox document. Do you have any idea under which heading? Thanks

satimis
 
Old 04-13-2014, 05:32 AM   #6
berndbausch
LQ Addict
 
Registered: Nov 2013
Location: Tokyo
Distribution: Mostly Ubuntu and Centos
Posts: 6,316

Rep: Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002
Quote:
Originally Posted by satimis View Post
That what I expect to do. I'll run webserve on VM. I need static IP so that the domain DNS will point to it allowing visitor browsing the website.

I'll make some search on VirtualBox document. Do you have any idea under which heading? Thanks

satimis
Not offhand, sorry. Try google as well
 
Old 04-13-2014, 12:38 PM   #7
Ser Olmy
Senior Member
 
Registered: Jan 2012
Distribution: Slackware
Posts: 3,348

Rep: Reputation: Disabled
Quote:
Originally Posted by satimis View Post
That what I expect to do. I'll run webserve on VM. I need static IP so that the domain DNS will point to it allowing visitor browsing the website.
Then configure the VM NIC as a bridged adapter, and give the VM a static IP address in the same network as the hypervisor host.
 
Old 04-13-2014, 08:12 PM   #8
satimis
Senior Member
 
Registered: Apr 2003
Posts: 3,695

Original Poster
Rep: Reputation: 56
Quote:
Originally Posted by Ser Olmy View Post
Then configure the VM NIC as a bridged adapter, and give the VM a static IP address in the same network as the hypervisor host.
Hi,

Thanks for your advice.

I did that before behind a router. But now there is no router I could not figure out how set Br0 on both Host and VM (a webserver). I want VM assigned a static IP so that it can be browsed on Internet.

Here below is my suggestion:

Host
Code:
# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet static
     address xxx.xxx.xxx.xxx
     netmask xxx.xxx.xxx.xxx
     broadcast xxx.xxx.xxx.xxx
     gateway xxx.xxx.xxx.xxx

auto br0
iface br0 inet static
	address		192.168.0.100 ?
	network		192.168.0.0    ?
	netmask		255.255.255.0  ?
	broadcast	192.168.0.255  ?
	gateway		192.168.0.1 ?
	bridge_ports	eth1 ?
	bridge_fd	9
	bridge_hello	2
	bridge_maxage	12
	bridge_stop	off
On VM
Code:
# The loopback network interface
auto lo
iface lo inet loopback

auto br0
iface br0 inet static
	address		192.168.0.101  ?
	network		192.168.0.0	?
	netmask		255.255.255.0  ?
	broadcast	192.168.0.255  ?
	gateway		192.168.0.1  ?
	bridge_ports	eth1   ?
	bridge_fd	9 
	bridge_hello	2  
	bridge_maxage	12
	bridge_stop	off
Please advise. Thanks

Rgds
satimis
 
Old 04-13-2014, 09:22 PM   #9
Ser Olmy
Senior Member
 
Registered: Jan 2012
Distribution: Slackware
Posts: 3,348

Rep: Reputation: Disabled
Why are you creating bridges on the hypervisor and the VM?
 
Old 04-13-2014, 09:27 PM   #10
satimis
Senior Member
 
Registered: Apr 2003
Posts: 3,695

Original Poster
Rep: Reputation: 56
Quote:
Originally Posted by Ser Olmy View Post
Why are you creating bridges on the hypervisor and the VM?
Please advise what shall enter on /etc/network/interface of VM ?

Any mistake made on /etc/network/interface of Host ?

Thanks

satimis
 
Old 04-13-2014, 09:33 PM   #11
Ser Olmy
Senior Member
 
Registered: Jan 2012
Distribution: Slackware
Posts: 3,348

Rep: Reputation: Disabled
I think there may have been a slight misunderstanding here. When I recommended using a "bridged interface", I was refering to the NIC setup for the VM in VirtualBox, not the configuration of the hypervisor or the VM OS.

If you're using the Oracle GUI to manage your virtual machines, you'll find the relevant setting under "Network". For each NIC on that tab, in the pulldown menu next to the text "Attached to:" you'll find the various operatin modes I mentioned earlier. That's where you'll need to select "Bridged adapter" for the VM NIC to appear on the same network as one of the physical adapters on the hypervisor.

Once you've done this, configure eth0 on the VM with a static IP address as you would any other host on that network.
 
Old 04-13-2014, 10:45 PM   #12
berndbausch
LQ Addict
 
Registered: Nov 2013
Location: Tokyo
Distribution: Mostly Ubuntu and Centos
Posts: 6,316

Rep: Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002
In case you still want to use NAT, set the IP address according to instructions "9.11. Fine-tuning the VirtualBox NAT engine" in the VirtualBox help file.
 
Old 04-14-2014, 10:56 AM   #13
satimis
Senior Member
 
Registered: Apr 2003
Posts: 3,695

Original Poster
Rep: Reputation: 56
Quote:
Originally Posted by Ser Olmy View Post
I think there may have been a slight misunderstanding here. When I recommended using a "bridged interface", I was refering to the NIC setup for the VM in VirtualBox, not the configuration of the hypervisor or the VM OS.

If you're using the Oracle GUI to manage your virtual machines, you'll find the relevant setting under "Network". For each NIC on that tab, in the pulldown menu next to the text "Attached to:" you'll find the various operatin modes I mentioned earlier. That's where you'll need to select "Bridged adapter" for the VM NIC to appear on the same network as one of the physical adapters on the hypervisor.

Once you've done this, configure eth0 on the VM with a static IP address as you would any other host on that network.
Hi,

Performed following steps

Host
/etc/network/interfaces
Code:
# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet static
     address xx.xx.xx.xx
     netmask 255.255.255.252
     broadcast xx.xx.xx.xx
     gateway xx.xx.xx.xx

auto br0
iface br0 inet static
        address         192.168.0.100
        network         192.168.0.0
        netmask         255.255.255.0
        broadcast       192.168.0.255
        gateway         192.168.0.1
        bridge_ports    eth1  (if select eth0, unable to connect broadband)
        bridge_fd       9
        bridge_hello    2
        bridge_maxage   12
        bridge_stop     off
VM
-> network
Adapter 1
Attached to: Bridged Adapter
Name eth0/br0/eth1

None of them can work, unable to access Internet.

B.R.
satimis
 
Old 04-20-2014, 06:39 AM   #14
satimis
Senior Member
 
Registered: Apr 2003
Posts: 3,695

Original Poster
Rep: Reputation: 56
Quote:
Originally Posted by berndbausch View Post
In case you still want to use NAT, set the IP address according to instructions "9.11. Fine-tuning the VirtualBox NAT engine" in the VirtualBox help file.
Hi,

Thanks for your advice.

I have to face 2 problems on using NAT

1)
Can I do port forwarding?

2)
On running FileZilla download folders/files the VM aborted automatically
log
Code:
....
GL_NV_texture_barrier GL_ARB_robustness GL_ARB_texture_storage 
00:05:02.186305 NAT: ti is null. can't do any reseting connection actions
00:05:22.193662 NAT: ti is null. can't do any reseting connection actions
00:06:11.770888 NAT: ti is null. can't do any reseting connection actions
Having tried hours without a solution.

Rgds
satimis

Last edited by satimis; 04-20-2014 at 06:41 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
telnet: Unable to connect to remote host: No route to host grob115 Linux - Networking 3 07-30-2010 10:18 AM
Virtualbox CentOS Guest can not connect to Internet from XP Host sokha Linux - Virtualization and Cloud 2 03-30-2010 11:28 PM
[SOLVED] Problem Connect to Internet...Ping :Unkown host www.yahoo.com manthena Linux - Newbie 7 01-13-2010 05:17 PM
trying to connect to internet error host not found firedancer Linux - Networking 3 08-22-2007 10:01 PM
Host name lookup failure when trying to connect to the internet jabka Linux - General 1 10-25-2005 12:15 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 04:36 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration