Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back > Forums > Linux Forums > Linux - Networking
User Name
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.


  Search this Thread
Old 05-10-2011, 01:48 AM   #1
Registered: Oct 2006
Posts: 295

Rep: Reputation: 31
How can I do NAT in VirtualBox


I'm using VirtualBox 4 on OpenSuse 11.3.

I've 6 vm with different OS.

My company uses a net in 10.x.x.x. But I can't use IP of that range (only one for the host). I use IP for my vm in the range 192.168.x.x.

I need my vm to communicate each other, to the host and outside. From outside (10.x.x.x), don't need to access 192.x.x.x.

How do I have to configure Virtualbox?

- Tried with host-only. VM can see each other, but not the outside.
- Tried with NAT. Then VM can't see each other.
- Tried with bridge. Then can't see outside.

An suggestion?

Old 05-10-2011, 02:40 AM   #2
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,134
Blog Entries: 2

Rep: Reputation: 4839Reputation: 4839Reputation: 4839Reputation: 4839Reputation: 4839Reputation: 4839Reputation: 4839Reputation: 4839Reputation: 4839Reputation: 4839Reputation: 4839
Set your VMs to NAT, so that they can see the outside. Then add a second network card to the VMs and set them up to be on their own virtual net. This way the VMs can communicate.
1 members found this post helpful.
Old 05-11-2011, 07:13 PM   #3
Registered: May 2011
Distribution: Gentoo
Posts: 98

Rep: Reputation: 16
I suggest using a host-only interface, and then giving access to the outside network the usual way (forwarding and NAT with iptables). When you make a host-only interface, it does in fact show up in your host (vboxnet0 probably).

Assuming there is no firewall, this should work:
- assign IP to vboxnet0 - this is usually done by VirtualBox
- echo 1 > /proc/sys/net/ipv4/ip_forward
- iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
(where eth0 is the interface with the default gateway)
- in guests, set default gateway to assigned IP of vboxnet0
1 members found this post helpful.
Old 05-12-2011, 07:50 AM   #4
Registered: Oct 2006
Posts: 295

Original Poster
Rep: Reputation: 31
Thank your for your reply.

I've decided to change to VMWare (after two year using VirtualBox). With VMWare Player NAT is easy and it allows the creation of VM (not allowed with previous releases).

Probably the routing solution had solved my problem, but I have already migrated my machines.

Thank you


nat, virtual box

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
Can I use NAT and some local hosts without NAT on linux box? tkmbe Linux - Networking 1 08-12-2010 02:38 PM
VirtualBox Networking (NAT) not working on XP host with Mandriva guest FreeRadical2600 Linux - Newbie 9 10-29-2008 08:12 AM
I configure NAT and use "services ..." to save it but when I reboot there is no nat bruack Linux - Software 4 09-01-2004 02:38 AM
Susefirewall2 Nat Problem / nat 1:1 trubi Linux - Distributions 0 07-20-2004 05:50 AM
What's the difference between Linux-NAT and Sygate-NAT? yuzuohong Linux - Networking 0 08-07-2002 04:07 AM > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 01:00 AM.

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