Host-only and NAT?

Discussions related to using VirtualBox on Mac OS X hosts.
Post Reply
ibuzzzmx
Posts: 4
Joined: 3. May 2009, 09:54
Primary OS: Mac OS X Leopard
VBox Version: OSE other
Guest OSses: Ubuntu Server

Host-only and NAT?

Post by ibuzzzmx »

Hello,

I'm running Ubuntu Server 9 on Mac OS 10.5.6 to learn more about Linux and the exciting server stuff. Currently it is possible to access the internet via "NAT" or to access the guest via SSH with "Host-only networking". But not both together. This means it is not possible to run apt-get over SSH because there is no internet connection. By using "NAT" I cannot access the guest (server). :?

Is there a possibility to get both working - NAT and Host-only networking? I have tried to set up two network adapters but Ubuntu only recognizes the network adapter 1.

Best regards,
ibuzzzmx
baf
Volunteer
Posts: 829
Joined: 27. Sep 2008, 06:18
Primary OS: Mac OS X Leopard
VBox Version: PUEL
Guest OSses: linux,xp,win7
Location: Luleå or Skellefteå, Sweden

Re: Host-only and NAT?

Post by baf »

Yes its possible.
first check that its really eth1 by:
ifconfig -a|grep Link

Then as root edit file
/etc/network/interfaces

example:
sudo cp /etc/network/interfaces /etc/network/interfaces.bak
sudo nano /etc/network/interfaces

assuming its eth1:
add eth1 to the auto line add add a line:
iface eth1 inet dhcp
save the file reboot
Some say: "You learn as long as you live".
My way: "You live as long as you learn".
ibuzzzmx
Posts: 4
Joined: 3. May 2009, 09:54
Primary OS: Mac OS X Leopard
VBox Version: OSE other
Guest OSses: Ubuntu Server

Re: Host-only and NAT?

Post by ibuzzzmx »

Luky to hear that it is possilbe :D

What do you exactly mean with "first check that its really eth1"?

Network adapter 1 is "Host-only networking" and network adapter 2 is the NAT in the VirtualBox configuration.

The interfaces file contains:

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
iface eth0 inet dhcp
My MacBook connect via Airport to the internet - this should be "en1".
baf
Volunteer
Posts: 829
Joined: 27. Sep 2008, 06:18
Primary OS: Mac OS X Leopard
VBox Version: PUEL
Guest OSses: linux,xp,win7
Location: Luleå or Skellefteå, Sweden

Re: Host-only and NAT?

Post by baf »

In the guest!
look at the output from ifconfig -a |grep Link
there you will see what network interfaces the guest sees.

Then configure interfaces as i said.
Some say: "You learn as long as you live".
My way: "You live as long as you learn".
ibuzzzmx
Posts: 4
Joined: 3. May 2009, 09:54
Primary OS: Mac OS X Leopard
VBox Version: OSE other
Guest OSses: Ubuntu Server

Re: Host-only and NAT?

Post by ibuzzzmx »

This is the guest output.

ifconfig -a |grep Link returns

Code: Select all

eth0      Link encap:Ethernet  Hardware Adresse 08:00:27:eb:7c:f4  
eth1      Link encap:Ethernet  Hardware Adresse 08:00:27:7d:8d:a7  
lo        Link encap:Lokale Schleife 
All outputs here are form the guest. I thought there could be a connection between the guest and host in regard of the actual eth1 in the guest and en1 on the host.
ibuzzzmx
Posts: 4
Joined: 3. May 2009, 09:54
Primary OS: Mac OS X Leopard
VBox Version: OSE other
Guest OSses: Ubuntu Server

Re: Host-only and NAT?

Post by ibuzzzmx »

Ok, I got it working. Thanks a lot!!! :D :D

If anyone will have the same problem - here is how to get it working in a few words:

1. Edit you /etc/network/interfaces file with sudo pico /etc/network/interfaces
2. Normally there is an entry for "eth0" which looks like the one to be added. To get it working with a second network connection simply add

Code: Select all

auto eth1
iface eth1 inet dhcp
at the end of the file. That's it. Don't forget to reboot you guest and make sure that you have activated two network adapters in the VirtualBox configuration.
Post Reply