How to reach a Vbox guest from host when using NAT networking

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)

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

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.

Method 2

This command will forward 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"

Method 3

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.


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x