Using Fedora or Ubuntu for the host with firewalls turned off on each side (vbox guest&host), what do I have to do to reach the guest machine using a NAT interface just like it would be with a bridged interface? (Only from the vbox host!)

Update: ifconfig on the host machine:

# ifconfig -a
eth0      Link encap:Ethernet  HWaddr 00:41:56:6B:78:4E  
      inet addr:  Bcast:.  Mask:
      RX packets:271850 errors:0 dropped:0 overruns:0 frame:0
      TX packets:144494 errors:0 dropped:0 overruns:0 carrier:0
      collisions:0 txqueuelen:1000 
      RX bytes:256776500 (244.8 MiB)  TX bytes:10670238 (10.1 MiB)
      Interrupt:16 Memory:fc500000-fc520000 

lo        Link encap:Local Loopback  
      inet addr:  Mask:
      UP LOOPBACK RUNNING  MTU:16436  Metric:1
      RX packets:77698 errors:0 dropped:0 overruns:0 frame:0
      TX packets:77698 errors:0 dropped:0 overruns:0 carrier:0
      collisions:0 txqueuelen:0 
      RX bytes:104227086 (99.3 MiB)  TX bytes:104227086 (99.3 MiB)

vboxnet0  Link encap:Ethernet  HWaddr 0A:00:27:00:00:00  
      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)

According to this documentation, current versions of VirtualBox do not expose the internal NAT interfaces to the host machine. You may configure special port forwarding rules to reach the boxes, but even the host is not able to reach the whole interface. You should used bridged networking for that.

  • I updated the Question. No I don't have any default IPs from Virtualbox. May 9 '11 at 14:08
  • See updated answer. Sorry it's been a while since I used NAT in VirtualBox and the machine I have that uses it has sub-interfaces made by me, apparently not VB.
    – Caleb
    May 9 '11 at 14:17

This command will forward all TCP traffic arriving on the localhost interface ( via port 33890 to port 3389 in the guest

$ VBoxManage modifyvm "xp" --natpf1 "guestrdp,tcp,,33890,,3389"
  • Please add this as a comment to my answer, not as a separate answer.
    – Caleb
    May 9 '11 at 15:16
  • 1
    I initially converted this to a comment, but it seems like it actually adds an important part of the answer May 9 '11 at 15:38
  • @Michael: It's not that important either way, but the solution isn't actually what his question asks for. Port forwarding is different than exposing a network interface in the same way that the bridging does, so I didn't include exact syntax in my answer. The command he shows is just from the documentation that I suggested and linked to in case port forwarding was an acceptable alternate.
    – Caleb
    May 9 '11 at 15:47

I have not tested this on a linux host.

It sounds like you want to use NAT so your guest can get out onto the network, but also want to access the guest directly from the host without using port forwarding.

If you create two networks on the guest - one as a NAT or NAT Network, and the second as a host-only adapter - you can achieve this.

The NAT configuration allows your guest to get out, the host-only adapter lets your host get in.

I usually use NAT Networks, so my vms can talk to each other. In the Windows gui, both settings are managed under File->Preferences->Network

NAT Networks tab - add NAT Network. Edit it and give it a name or custom ip range if you want.

Host-Only Network tab - edit the default interface and make sure the ipv4 address is in the same network (but not in the dhcp range!) as the dhcp server tab is configured. mine didn't match out of the box so networking didnt work.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.