clone not getting ip from vbox dhcp [SOLVED]

This is for discussing general topics about how to use VirtualBox.
Post Reply
BeafZachland
Posts: 18
Joined: 29. May 2013, 05:17
Primary OS: Ubuntu other
VBox Version: OSE Debian
Guest OSses: ubuntu server12.04

clone not getting ip from vbox dhcp [SOLVED]

Post by BeafZachland »

here is the situation:
I am using an Ubuntu 12.04 host and guest vm headless set up. there is no DHCP on my router so the host is a static ip. I have vbox 4.2.12 and extensions installed as well as one vm called student working. I cloned this vm and named the new one student1 using "VBoxManage clonevm student --name student2 --register". when I start the clone student1 I can use it via vrdp but there is no network access. I ran ifconfig and there is no ip assigned. I looked at /etc/network/interfaces and eth0 is set to use DHCP and looks the same as the original I cloned it from. could someone please tell me when i clone a vm with this setup i'm using what needs to be changed on the clone for it to get an ip from vbox's DHCP and allow me to set unique forwarding rules for it.

more details:
i started the clone without the original running in case there was a conflict with ip being assigned but i get the same results. i have ssh forwarding rule set up for this clone using "VBoxManage modifyvm "student1" --natpf1 "guestssh,tcp,,60001,,22"" and the port is open on my router to forward this request to host. the host has student1 started and vrde is listening on custom port 40001. i can connect via rdp fine but the ssh forwarding rule is not connecting. i assume because vbox DHCP has not assigned an ip as previously stated so it can't forward the ssh request. i need NAT and DHCP on the vm's nic so i can set forwarding rules and get unique ip's for each clone i make. where am i going wrong?
xtra question:
does the clonevm command i gave above create it's own copy of the originals .vdi or does it just use the same .vdi because i need each machine to use it's own hard drive?
Last edited by BeafZachland on 6. Jun 2013, 03:41, edited 1 time in total.
noteirak
Site Moderator
Posts: 5231
Joined: 13. Jan 2012, 11:14
Primary OS: Debian other
VBox Version: OSE Debian
Guest OSses: Debian, Win 2k8, Win 7
Contact:

Re: clone not getting ip from vbox dhcp

Post by noteirak »

Remember that when you clone, by default, the MAC address is reseted. I've seen this causing issues in the past, but because of the guest OS.
What happen if, after you've started your guest, you set the cable to disconnected then connected again, do you get an IP then?
Hyperbox - Virtual Infrastructure Manager - https://apps.kamax.lu/hyperbox/
Manage your VirtualBox infrastructure the free way!
BeafZachland
Posts: 18
Joined: 29. May 2013, 05:17
Primary OS: Ubuntu other
VBox Version: OSE Debian
Guest OSses: ubuntu server12.04

Re: clone not getting ip from vbox dhcp

Post by BeafZachland »

are you saying the MAC for the clone by default is different from the original or that one is not actually given? i will try your suggestion but i have been stting this up remotely so i have to wait until i am physically on location to try unplugging the cable. basically i cloned the vm becaue i need 30 of them on the server with the same OS and i didn't want to install ubuntu 30 times so i cloned one i already set up. i was hoping that it would give the clones all unique uuid's, .vdi's and MAC addresses so they would not conflict with each other.

note:
i just logged in to both the clone and the original and it appears you are correct. the clone has no MAC address when i run ifconfig. what modifyvm command, if any, will assigne a random MAC to the nic? i tried "VBoxManage modifyvm "student1" --macaddress1 auto". the command executed error free but the vm still has no MAC in ifconfig when i start it up. i verified the MAC was created for student1 with showvminfo and then manually added it to /etc/network/interfaces in the cloned vm then restarted /etc/init.d/networking restart and it tells me "can not locate device eth0" "failed to bring up eth0". why is this happening? i used clonevm to save time and this is turning into a nightmare.
Perryg
Site Moderator
Posts: 34369
Joined: 6. Sep 2008, 22:55
Primary OS: Linux other
VBox Version: OSE self-compiled
Guest OSses: *NIX

Re: clone not getting ip from vbox dhcp

Post by Perryg »

Linux has a "feature" that when you change the MAC address it assigns a new eth*.
edit the /etc/udev/rules.d/70-persistent-net.rules or you can delete the rules and Linux will configure it on the next boot
BeafZachland
Posts: 18
Joined: 29. May 2013, 05:17
Primary OS: Ubuntu other
VBox Version: OSE Debian
Guest OSses: ubuntu server12.04

Re: clone not getting ip from vbox dhcp

Post by BeafZachland »

by delete the rules do you mean the entire file or just the lines that are not commented out?
ip link show shows me that my correct MAC is on eth2 and there are no other ethX listed. my interfaces file shows everything is configured under eth0. i want to get rid of this eth2 and just use eth0. exactly how is that done. sorry i can't cut and paste the 70-persistent-net.rules file because i am working through rdesktop remotely on it and sftp and scp are not operational because of this whole issue i'm having
Last edited by BeafZachland on 6. Jun 2013, 03:23, edited 1 time in total.
Perryg
Site Moderator
Posts: 34369
Joined: 6. Sep 2008, 22:55
Primary OS: Linux other
VBox Version: OSE self-compiled
Guest OSses: *NIX

Re: clone not getting ip from vbox dhcp

Post by Perryg »

Usually the entire file works the best. You could back it up if it is of concern to you but it does get regenerated on reboot.
BeafZachland
Posts: 18
Joined: 29. May 2013, 05:17
Primary OS: Ubuntu other
VBox Version: OSE Debian
Guest OSses: ubuntu server12.04

Re: clone not getting ip from vbox dhcp

Post by BeafZachland »

you are the man. thanks allot. it works now i can apt-get update and connect via ssh. it just sucks i got to open 29 more vm's and remove that file but i'm glad it's fixed and i am almost done with this frickin project. i just need to install apache2 and phpvirtualbox on the host so the teachers can manage the classes vm's through a gui.

i'm going to mark this solved: basically what happens is the cloning process creating the new MAC puts it on eth1 which stops the whole thing from working. jeez i never would have figured that without help. thanks again
Martin
Volunteer
Posts: 2562
Joined: 30. May 2007, 18:05
Primary OS: Fedora other
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: XP, Win7, Win10, Linux, OS/2

Re: clone not getting ip from vbox dhcp [SOLVED]

Post by Martin »

Just to add the information to this thread:
(if you had known the problem before cloning...)
If you remove that file before cloning you wouldn't need to adjust each clone manually.
It doesn't harm the original system, the file is not needed as long as you don't change the virtual hardware settings. Normally it will be recreated at the next boot.
Post Reply