NAT and port redirection

Discussions related to using the OSE version of VirtualBox.
Post Reply
guy
Posts: 4
Joined: 20. Mar 2009, 12:32

NAT and port redirection

Post by guy »

Hi all

I have set up a host (Ubunti 8.10 Server) and a guest webserver (Ubuntu 8.10 LAMP) in a virtual machine and cloned the vdi so that I can create a second web server without going through all the hoops again. So far so good.

I have created another virtual machine and used the cloned vdi so I now have two webservers that I can load simultaneously. They both load with no errors.

I have set up port redirection so that port 2222 redirect to 22 on one guest and port 2288 to port 22 on the other, I have also done the same with 8080 to 80 and 8888 to 80. I restarted the virtual machines and checked the config (getextrasdata virtualmachine enumerate or whatever the exact command is showed the three entries for each port redirection, host, guest and TCP)

The original guest seems to work perfectly. I can ssh and browse to it using the hosts ip address and the 2222 and 8080 ports. The cloned guest does not respond to either ssh on 2288 or http on 8888.

Is this setup possible or am I trying to do something that Virtualbox OSE wont allow?
Is it something to do with the cloning process?
Have I missed a step?
vbox4me2
Volunteer
Posts: 5218
Joined: 21. Nov 2008, 20:27
Location: Rotterdam
Contact:

Re: NAT and port redirection

Post by vbox4me2 »

A cloned linux will be looking for a ethx linked to the old MAC, see also:
http://forums.virtualbox.org/viewtopic.php?t=12060
guy
Posts: 4
Joined: 20. Mar 2009, 12:32

Re: NAT and port redirection

Post by guy »

Thanks for the quick reply, and the link and the fix.

My problem has been sorted by auto generating a new MAC address for the guest and then clearing out all the lines in /etc/udev/rules.d/70-persistent-net.rules (also on the guest) except for the comments at the beginning.

Once I have rebooted the guest I can ssh and http to my heart content.
guy
Posts: 4
Joined: 20. Mar 2009, 12:32

Re: NAT and port redirection

Post by guy »

Damn.....
I thought I had this one cracked.

I have made a further copy of my virtual machine and come up with a sensible scheme for port usage on each VM. This involved changing the setextradata settings for one of the existing VMs and creating a new set for the new clone.

I cloned the VDI, created a new VM and used the cloned VDI, fired it up and deleted the lines from the /etc/udev/rules.d/70-persistent-net-rules file, shut down the VM, generated a new MAC address, ran the vboxmanage setextradata commands, making sure that I have a unique name for each triplet, started up the VM and .....

Cannot ssh or http to the clone

I changed the setextradata settings for one of the VM's that worked above and ~I cannot ssh or http to that now either.

I have checked, using getextradata, that the port redirection settings seem OK, I am using 2281 and 8081 for one machine and 2282 and 8082 for the other.

I have checked that the MAC address in /etc/udev/rules.d/70-persistent-net-rules file is the same as that set on the VM network interface.

I am lost again :(

It appears to be the redirection is a problem
If I ssh -luser -p2281 localhost I get an immediate "connection refused" error
if I ssh from the host, ssh -luser -p2281 dnshostname I get a timeout, it appears that packets are going out the host eth0 and back in again

My third VM that I haven't changed since the previous post still works perfectly, I am using more "normal" ports for this one though i.e. 2222 and 8080

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

Re: NAT and port redirection

Post by vbox4me2 »

Print out the xml from your working VM and compare it with the others, its bound to be something daft like ending up at 23 and not 22 at the Guest.
guy
Posts: 4
Joined: 20. Mar 2009, 12:32

Re: NAT and port redirection

Post by guy »

Hi

I had a look at the two .xml files and the only apparent differences were the vm id, disk id and MAC address plus, obviously the redirection lines had a different machinename and port for the hostport setting. Oddly they were also in a slightly different order.

So I took my life in my hands and edited the newclone.xml file by copying the workingvm.xml and pasting the obvious differences in and bu***r me it is now working. I will do a detailed trawl through the modified VM to see if there are any weird typo's or something but it all looks OK.

I am using the OSE version because I like the concept of OSE, are these problems "normal"? Would I be better off with the PUEL version?

Thanks once again for a quick and effective reply.

FYI i did a netstat -napee | egrep V to see what if any ports Virtualbox was listening on.

When the redirection wasn't working there was no line
0.0.0.0:2282 etc
which is now there with the working clone

Guy
Post Reply