NAT / Static IP / Port Forwarding

This is for discussing general topics about how to use VirtualBox.
Post Reply
daimon
Posts: 4
Joined: 21. Apr 2009, 13:49
Primary OS: Ubuntu 8.10
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Debian Lenny

NAT / Static IP / Port Forwarding

Post by daimon »

Hi!

I'm using Virtualbox 2.2.0 with a Debian Lenny guest on an Ubuntu 8.10 Host.
The Network is set to NAT (I cannot use Host interface due to internal networking difficulties).
I've setup Port Forwarding via the commands

Code: Select all

VBoxManage setextradata "virtual core" "VBoxInternal/Devices/pcnet/0/LUN#0/Config/guesthttp/Protocol" TCP
VBoxManage setextradata "virtual core" "VBoxInternal/Devices/pcnet/0/LUN#0/Config/guesthttp/GuestPort" 80
VBoxManage setextradata "virtual core" "VBoxInternal/Devices/pcnet/0/LUN#0/Config/guesthttp/HostPort" 4280

VBoxManage setextradata "virtual core" "VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestssh/Protocol" TCP
VBoxManage setextradata "virtual core" "VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestssh/GuestPort" 22
VBoxManage setextradata "virtual core" "VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestssh/HostPort" 4222
This Stuff runs fine, as long as i keep the guest network card set to DHCP. As soon as i give it a static IP, Port Forwarding ceases to function.
Outgoing traffic from the guest works just fine.

Can anybody push me in the right direction to solve this problem?
Perhaps it is possible to reconfigure the VirtualBox DHCP Server to only serve a specific IP?

Thanks in advance,

Stefan
vbox4me2
Volunteer
Posts: 5218
Joined: 21. Nov 2008, 20:27
Location: Rotterdam
Contact:

Re: NAT / Static IP / Port Forwarding

Post by vbox4me2 »

I think port forwarding is based on all Guest having the same IP settings allowing to use VM names on the Host, once you change this the Host VBox Core can't connect to the Guest this way.
Sasquatch
Volunteer
Posts: 17798
Joined: 17. Mar 2008, 13:41
Primary OS: Debian other
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Windows XP, Windows 7, Linux
Location: /dev/random

Re: NAT / Static IP / Port Forwarding

Post by Sasquatch »

This Stuff runs fine, as long as i keep the guest network card set to DHCP. As soon as i give it a static IP, Port Forwarding ceases to function.
Outgoing traffic from the guest works just fine.
Duh, NAT is designed to be used with DHCP. Setting a static IP other than the one supplied by the DHCP will give errors. Why do you want to change it's IP address? If your host network doesn't use the 10.x.y.z range, it won't conflict with anything. If it does, read the manual.
Read the Forum Posting Guide before opening a topic.
VirtualBox FAQ: Check this before asking questions.
Online User Manual: A must read if you want to know what we're talking about.
Howto: Install Linux Guest Additions
Howto: Use Shared Folders on Linux Guest
See the Tutorials and FAQ section at the top of the Forum for more guides.
Try searching the forums first with Google and add the site filter for this forum.
E.g. install guest additions site:forums.virtualbox.org

Retired from this Forum since OSSO introduction.
daimon
Posts: 4
Joined: 21. Apr 2009, 13:49
Primary OS: Ubuntu 8.10
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Debian Lenny

Re: NAT / Static IP / Port Forwarding

Post by daimon »

Duh, NAT is designed to be used with DHCP. Setting a static IP other than the one supplied by the DHCP will give errors. Why do you want to change it's IP address? If your host network doesn't use the 10.x.y.z range, it won't conflict with anything. If it does, read the manual.
NAT and DHCP, while often used together, are completely independent networking technologies (I don't know about the virtualbox implementation of NAT, though).

I am using an IP of the 10.0.2.4-254 range, and everything works fine - except for the port forwarding.
The reason I need a static IP: One of our application demands that the IP is not changing. If it does, it stops working (#%!§$ licensing issues...)

So If I have to use the VBox DHCP Server, I can only use it if i am able to restrict the issued leases to a single IP Adress.

Thanks

Stefan
Sasquatch
Volunteer
Posts: 17798
Joined: 17. Mar 2008, 13:41
Primary OS: Debian other
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Windows XP, Windows 7, Linux
Location: /dev/random

Re: NAT / Static IP / Port Forwarding

Post by Sasquatch »

That's so great about a search function, and a manual. Even though you would request a new IP every single time, you still get the same one with NAT in VB. You confuse VB NAT with the regular NAT that your home router provides.
Read the Forum Posting Guide before opening a topic.
VirtualBox FAQ: Check this before asking questions.
Online User Manual: A must read if you want to know what we're talking about.
Howto: Install Linux Guest Additions
Howto: Use Shared Folders on Linux Guest
See the Tutorials and FAQ section at the top of the Forum for more guides.
Try searching the forums first with Google and add the site filter for this forum.
E.g. install guest additions site:forums.virtualbox.org

Retired from this Forum since OSSO introduction.
daimon
Posts: 4
Joined: 21. Apr 2009, 13:49
Primary OS: Ubuntu 8.10
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Debian Lenny

Re: NAT / Static IP / Port Forwarding

Post by daimon »

When I set the static IP to 10.0.2.15 (the last one i got through DHCP), port forwarding works.

Does the DHCP Server only issue this address? Then everything would be fine...
daimon
Posts: 4
Joined: 21. Apr 2009, 13:49
Primary OS: Ubuntu 8.10
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Debian Lenny

Re: NAT / Static IP / Port Forwarding

Post by daimon »

Sasquatch wrote:That's so great about a search function, and a manual. Even though you would request a new IP every single time, you still get the same one with NAT in VB. You confuse VB NAT with the regular NAT that your home router provides.
Ah great. First of all, thanks for helping me. The issue is resolved, if the DHCP server only issues the .15 address.

Second: Kindly show me the passage in the manual where this is described before patronizing me. Or in the forum. Anywhere on the net (in connection with port forwarding, of course, cause you see, that was my issue).

No hard feelings

Stefan
z0n
Posts: 1
Joined: 29. Jun 2009, 12:12
Primary OS: Ubuntu 8.10
VBox Version: OSE self-compiled
Guest OSses: Gentoo

Re: NAT / Static IP / Port Forwarding

Post by z0n »

..for anyone still following this, the help topic is "9.12. Configuring the address of a NAT network interface". It is hidden right at the end of the manual in the "Advanced topics" section (conveniently close to the "Troubleshooting" section)

Judging by the amount of questions I've seen floating around the Net (while out hunting this same answer) regarding VB's built-in DHCP server and the IP addresses it assigns, I'd say Sasquatch can stick ModEdit: contents removed, there is no need for faul launguage..
Post Reply