Tell me more ×
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

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
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

You need to add an IP to the vboxnet0 [ It should get an IP at boot-up time only, anyway ], and then assign the IP from same subnet to the eth0 of the guest operating system. In that case you will have the connectivity between your host and guest OS. { I tried this in VMWare and it works fine }

share|improve this answer
1  
VMWare works rather differently than VirtualBox and you cannot just substitute methodology like that. I just tried this for VirtualBox and it does not work. – Caleb May 9 '11 at 14:33
In that case, you are doing the WRONG thing. You need to follow the procedure very carefully. You will get the desired result. – SHW May 9 '11 at 14:39
@SHW I think I did. I started a VM using NAT and assigned IP addresses from the same subnet to the vboxnet0 interface on the host and eth0 on the guest. The guest is able to route to the internet just fine but the host cannot talk to the guest directly. – Caleb May 9 '11 at 14:45
1  
@SHW, My use of the phrase "I think" was an attempt to be nice and not make it sound like I couldn't have made a mistake. Your instructions are a little bit hard to follow exactly because both the order and what applies to the host and what to the guest isn't clear. I have checked my setup twice and it seems fine, but it's a no go. – Caleb May 9 '11 at 15:10
1  
@SHW, This question is not about VMWare, it is about VirtualBox! I tried to tell you in my first comment that you can't just substitute your administrative techniques between platforms like that and that since it is for the wrong platform, this doesn't answer the question. Don't say I did it wrong and need to read more carefully when you are not even using the software in question here. – Caleb May 9 '11 at 15:21
show 3 more comments

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.