LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   How to forward port to listening apps inside VirtualBox? (https://www.linuxquestions.org/questions/linux-networking-3/how-to-forward-port-to-listening-apps-inside-virtualbox-671400/)

matruschka 09-21-2008 12:07 PM

How to forward port to listening apps inside VirtualBox?
 
Hi!

I'm running VirtualBox 2.0.2 on my Slackware 12.1 system and it's working just fine,BUT:

When I'm trying to access TightVNC server running on a virtual XP pro sp3 machine I just don't get it to work.

The box I'm using TightVNC viewer on (eg. is trying to connect from) is on my main LAN (ip address: 192.168.0.129) and the virtual XP machine is on VirtualBox's default subnet (ip address 10.0.2.15. The Slackware host has ip address 192.168.0.100).

This is what I've done so far:

Successfully creating a temporary network bridge with:

modprobe tun
chmod 666 /dev/net/tun
brctl addbr br0
ifconfig eth0 0.0.0.0 promisc
brctl addif br0 eth0
dhcpcd -t 30 -h slackware-host br0 &
VBoxAddIF vbox0 root br0

Yada yada yada...

Then I did

/usr/sbin/iptables -t nat -A PREROUTING -p tcp -i br0 -d 192.168.0.100 --dport 5901 -j DNAT --to 10.0.2.15:5900
/usr/sbin/iptables -A FORWARD -p tcp -i eth0 -d 10.0.2.15 --dport 5900 -j ACCEPT

And it's probably here I screw up? Using ifconfig after creating the bridge lists all interfaces except the bridge itself with their IPv6 addresses and the iptables port forwarding stunt above didn't work at all when I tried to use the one for the vbox interface.

Sharing a folder on the virtual XP machine made the Microsoft Windows Network the virtual XP machine is on to appear in "My Network Places" on the XP client with the TightVNC viewer,but the shared folder never appeared (did in "My network places" on the virtual XP machine though).
So there is something alive in there... :)

Any genius with some ideas? I'm all out right now. :D

*Edit*

I got it to work!

I created a network bridge like before,not using the iptables commands this time.
And then,in VirtualBox,I selected the virtual XP pro sp3 machine in the virtual machines list and:

Network > Settings > Adapter 1 >
In the "Attatched to"-menu,I changed from NAT to Host interface.
In the "Interface Name"-field, I typed the name of the VirtualBox interface (vbox0).

aus9 09-24-2008 07:44 AM

Thats very nice of you to show others how to fix.

Maybe when you get a chance, consider a wiki entry or asking mods to move this to success stories?

cheerio


All times are GMT -5. The time now is 08:22 PM.