Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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:192.168.1.2  Bcast:.192.168.1.255  Mask:255.255.255.0
      UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
      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:127.0.0.1  Mask:255.0.0.0
      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)
share|improve this question
add comment

3 Answers

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.

share|improve this answer
    
I updated the Question. No I don't have any default IPs from Virtualbox. –  LanceBaynes 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
add comment
up vote 0 down vote accepted

THANK YOU it's working!

forwards all TCP traffic arriving on the localhost interface (127.0.0.1) via port 33890 to port 3389 in the guest

VBoxManage modifyvm "xp" --natpf1 "guestrdp,tcp,127.0.0.1,33890,,3389"
share|improve this answer
    
Please add this as a comment to my answer, not as a separate answer. –  Caleb May 9 '11 at 15:16
    
I initially converted this to a comment, but it seems like it actually adds an important part of the answer –  Michael Mrozek 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
add comment

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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