Help answer threads with 0 replies.
Go Back > Forums > Linux Forums > Linux - Networking
User Name
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.


  Search this Thread
Old 09-21-2008, 12:07 PM   #1
LQ Newbie
Registered: Jul 2002
Posts: 22

Rep: Reputation: 15
How to forward port to listening apps inside VirtualBox?


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: and the virtual XP machine is on VirtualBox's default subnet (ip address The Slackware host has ip address

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 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 --dport 5901 -j DNAT --to
/usr/sbin/iptables -A FORWARD -p tcp -i eth0 -d --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.


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

Last edited by matruschka; 09-22-2008 at 12:03 AM. Reason: Problem solved
Old 09-24-2008, 07:44 AM   #2
LQ Addict
Registered: Oct 2003
Location: Australia
Distribution: MX 16
Posts: 5,291

Rep: Reputation: Disabled
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?



Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Port not listening shadetree Linux - Networking 2 08-27-2008 03:07 PM
Howto do Secured ssh from port https or port80(standard) to ssh d listening port 22 ? Xeratul Linux - General 4 11-23-2006 06:09 AM
Outside FTP Port 21 redirect to different port inside LAN??? hendrixx Linux - Security 5 06-05-2004 06:42 PM
Forward port port 80 to lan web server dulaus Linux - Networking 9 10-04-2002 03:45 AM
how do i forward a port to and inside IP parabit Linux - Networking 3 01-09-2002 10:17 AM > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 03:16 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration