LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   VM to connect Internet via Host (https://www.linuxquestions.org/questions/linux-networking-3/vm-to-connect-internet-via-host-4175501500/)

satimis 04-12-2014 11:42 PM

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

Ser Olmy 04-13-2014 01:46 AM

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.

satimis 04-13-2014 02:48 AM

Quote:

Originally Posted by Ser Olmy (Post 5151595)
- 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

berndbausch 04-13-2014 04:03 AM

Quote:

Originally Posted by satimis (Post 5151610)
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.

satimis 04-13-2014 05:28 AM

Quote:

Originally Posted by berndbausch (Post 5151627)
- 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

berndbausch 04-13-2014 05:32 AM

Quote:

Originally Posted by satimis (Post 5151650)
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 :)

Ser Olmy 04-13-2014 12:38 PM

Quote:

Originally Posted by satimis (Post 5151650)
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.

satimis 04-13-2014 08:12 PM

Quote:

Originally Posted by Ser Olmy (Post 5151800)
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

Ser Olmy 04-13-2014 09:22 PM

Why are you creating bridges on the hypervisor and the VM?

satimis 04-13-2014 09:27 PM

Quote:

Originally Posted by Ser Olmy (Post 5152037)
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

Ser Olmy 04-13-2014 09:33 PM

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.

berndbausch 04-13-2014 10:45 PM

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.

satimis 04-14-2014 10:56 AM

Quote:

Originally Posted by Ser Olmy (Post 5152044)
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

satimis 04-20-2014 06:39 AM

Quote:

Originally Posted by berndbausch (Post 5152065)
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


All times are GMT -5. The time now is 10:00 PM.