Setting hostname on guest
-
- Posts: 15
- Joined: 2. Jul 2009, 09:54
- Primary OS: Fedora other
- VBox Version: OSE Fedora
- Guest OSses: Win XP
Setting hostname on guest
Hi everyone,
I am trying to set up a classrom using VirtualBox. I am using Fedora 11 as host and Win XP or Windows server 2003 as guest.
I have set up one computer with fedora, virtualbox and a set of different images for use in the different kind of courses.
My problem is that if I make changes to an image I want to copy the VMDK-file to all the other PC's, which works, but makes all the host names of the guests become the same(like coursePC1).
Is there a way, by script or command in my LAN to set the host names of the guests? When the guest is starting up? With a VirtualBox-command? A linux-command?
??
Thank you for all help!
I am trying to set up a classrom using VirtualBox. I am using Fedora 11 as host and Win XP or Windows server 2003 as guest.
I have set up one computer with fedora, virtualbox and a set of different images for use in the different kind of courses.
My problem is that if I make changes to an image I want to copy the VMDK-file to all the other PC's, which works, but makes all the host names of the guests become the same(like coursePC1).
Is there a way, by script or command in my LAN to set the host names of the guests? When the guest is starting up? With a VirtualBox-command? A linux-command?
??
Thank you for all help!
-
- Volunteer
- Posts: 3572
- Joined: 28. May 2008, 08:40
- Primary OS: Ubuntu other
- VBox Version: PUEL
- Guest OSses: Ubuntu 10.04 & 11.10, both Svr&Wstn, Debian, CentOS
- Contact:
Re: Setting hostname on guest
IIRC, the hostname of a PC is acquired from the registry pretty early on in the boot sequence, and you can't reset it without rebooting. Is it just the hostname or do you want unique SIDs as well? The easiest way to do this is to use VBoxManage guestproperty command to set properties for the hostname and SID, then have a startup script on the guest which checks if these are set correctly and if not then resets them and reboots the PC, so that they will be correct on restart. You can do this with a small WSH script. You'll need to search the appropriate windows forums for the correct commands to use. Try googling windows sid sysprep and the like.
Read the Forum Posting Guide
Google your Q site:VirtualBox.org or search for the answer before posting.
Google your Q site:VirtualBox.org or search for the answer before posting.
Re: Setting hostname on guest
Before shutting down the Guest run a ipconfig/release. At login use a script(cmd/batch file) that fetches the last digit of the IP address (if using Bridge mode) and use that to append as hostname, remove script and reboot.
[This space is intentionally left blank]
If you can read this, you can read the VirtualBox Manual, the Forum FAQ, and the QuickClick FAQ
-=[ Search this forum with Keywords, VirtualBox solutions at you're fingertips]=-
If you can read this, you can read the VirtualBox Manual, the Forum FAQ, and the QuickClick FAQ
-=[ Search this forum with Keywords, VirtualBox solutions at you're fingertips]=-
-
- Posts: 15
- Joined: 2. Jul 2009, 09:54
- Primary OS: Fedora other
- VBox Version: OSE Fedora
- Guest OSses: Win XP
Re: Setting hostname on guest
Thank you for the help. I am sorry I am late answering you. I hope you still can help
Thank you TerryE for pointing out the VBoxManage guestproperty, but I could use with an example
I do not see exactly what I need to change (I want to change as little as possible).
This is my scenario: A teacher modifies a VBox-image on his/hers computer. Then the VMDK-file is copied to the classroom-server (which has 2 NICs and is thereby connected to both school-LAN and classrom-LAN). A script on the server distribute the VMDK-file to all classroom computers and overwrites the old VMDK-file. The name of the VMDK-file is standarised! Now all the hosts/MAC/IP etc. will be the same on all guests in my classroom. How do I change that? Can I run a script from the classroom server (OS is Fedora 11 on all the computers)?
Thank you!
Thank you TerryE for pointing out the VBoxManage guestproperty, but I could use with an example
I do not see exactly what I need to change (I want to change as little as possible).
This is my scenario: A teacher modifies a VBox-image on his/hers computer. Then the VMDK-file is copied to the classroom-server (which has 2 NICs and is thereby connected to both school-LAN and classrom-LAN). A script on the server distribute the VMDK-file to all classroom computers and overwrites the old VMDK-file. The name of the VMDK-file is standarised! Now all the hosts/MAC/IP etc. will be the same on all guests in my classroom. How do I change that? Can I run a script from the classroom server (OS is Fedora 11 on all the computers)?
Thank you!
Re: Setting hostname on guest
No, you do this INSIDE the VM, you prepare the VM before shutting it down and sending it to the server. Any script you make is stored and run once inside the VM once it starts, it should reboot after that coming up with unique names. TerryE's method or others can be used to generate names.
[This space is intentionally left blank]
If you can read this, you can read the VirtualBox Manual, the Forum FAQ, and the QuickClick FAQ
-=[ Search this forum with Keywords, VirtualBox solutions at you're fingertips]=-
If you can read this, you can read the VirtualBox Manual, the Forum FAQ, and the QuickClick FAQ
-=[ Search this forum with Keywords, VirtualBox solutions at you're fingertips]=-
-
- Posts: 15
- Joined: 2. Jul 2009, 09:54
- Primary OS: Fedora other
- VBox Version: OSE Fedora
- Guest OSses: Win XP
Re: Setting hostname on guest
OK, I have several issues here
I am now sitting in the classrom. I have 2 student computers with OS Fedora running VBox 3.0.2 with the same XP-guest.
Before changing anything with a script I wanted to test it out manually. I now see that each VBox works as an DHCP-server giving the same IP-adress to both computers. They are member of a classrom-workgroup, but all alone since they cannot see each other (which I want).
I am swimming a bit here and not sure where to start. Will I be better of without a DHCP-server and set IPs manually? Can I have one VBox work as DHCP-server with the others shut of? But then what happens with the hostname (taken from the IP) as u suggested.
All computers/hosts are on the same LAN with a fixed IP (with Fedora 11)!
Can you point me in a direction on scripting to change hostname/SID as you talked about (catch the last digit of the IP is beyond me:) FYI: I have programmed in VB for 15 years so I know that well!
Thank you for all the help
I am now sitting in the classrom. I have 2 student computers with OS Fedora running VBox 3.0.2 with the same XP-guest.
Before changing anything with a script I wanted to test it out manually. I now see that each VBox works as an DHCP-server giving the same IP-adress to both computers. They are member of a classrom-workgroup, but all alone since they cannot see each other (which I want).
I am swimming a bit here and not sure where to start. Will I be better of without a DHCP-server and set IPs manually? Can I have one VBox work as DHCP-server with the others shut of? But then what happens with the hostname (taken from the IP) as u suggested.
All computers/hosts are on the same LAN with a fixed IP (with Fedora 11)!
Can you point me in a direction on scripting to change hostname/SID as you talked about (catch the last digit of the IP is beyond me:) FYI: I have programmed in VB for 15 years so I know that well!
Thank you for all the help
-
- Volunteer
- Posts: 3572
- Joined: 28. May 2008, 08:40
- Primary OS: Ubuntu other
- VBox Version: PUEL
- Guest OSses: Ubuntu 10.04 & 11.10, both Svr&Wstn, Debian, CentOS
- Contact:
Re: Setting hostname on guest
It sounds to me as if you are running your guests using NAT. If you want them to be active members on the LAN then you should used a bridged configuration. The user guide explains all of this in the networking section.hanske72 wrote:I now see that each VBox works as an DHCP-server giving the same IP-adress to both computers.
The best scripting tool for you to use here would be VBscript since this is similar to VB. The MS Script Centre allows you to download a CHM which has loads of coding examples, largely based on WMI to do things like interrogate network and system resources (e.g. IP addresses). You would have come across this if you'd googled WSH and I've already suggested that you google windows sid sysprep to findout more about changing the SID. This is really a straightforward MS system management issue.hanske72 wrote:Can you point me in a direction on scripting to change hostname/SID as you talked about (catch the last digit of the IP is beyond me:) FYI: I have programmed in VB for 15 years so I know that well!
Read the Forum Posting Guide
Google your Q site:VirtualBox.org or search for the answer before posting.
Google your Q site:VirtualBox.org or search for the answer before posting.
-
- Posts: 15
- Joined: 2. Jul 2009, 09:54
- Primary OS: Fedora other
- VBox Version: OSE Fedora
- Guest OSses: Win XP
Re: Setting hostname on guest
I have now tried 3 totaly different ways of scripting this and none of them work
I put it into registry with :
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run]
"NewSID"="B:\\SetNewSID.vbs"
..where B is a mapped up folder to the a folder in the boot-partition of my computer.
Maybe someone here know what I can do? My solution is to put a VBS-file in the boot-section of every computer (which run OS-Fedora). This file will never change and can therefore set the parameters in the guest. I will also need to set IP etc., but that can come next
How should the script look?
1st-script:
---------------------
sName = class2
sOldName=Wscript.CreateObject("Wscript.Network").Computername
if sOldName <> sName then
netdom renamecomputer sOldName /newname:sName /usero:administrator /passwordo:mypass /reboot:1
end if
---------------------
2nd-script:
---------------------
strUser = class2
strPassword = mypass
Set objNetwork = CreateObject("WScript.Network")
strComputer = objNetwork.ComputerName
if strComputer <> strUser then
Set objComputer = GetObject("winmgmts:{impersonationLevel=Impersonate}!\\" & strComputer & "\root\cimv2:Win32_ComputerSystem.Name='" & strComputer & "'")
echo objComputer.Name
Error= objComputer.Rename(strUser, strPassword, strUser)
shutdown -r
end if
----------------------
3rd-script:
----------------------
sName = class2
if Wscript.CreateObject("Wscript.Network").Computername <> sName then
B:\newsid.exe /a sName
end if
----------------------
I put it into registry with :
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run]
"NewSID"="B:\\SetNewSID.vbs"
..where B is a mapped up folder to the a folder in the boot-partition of my computer.
Maybe someone here know what I can do? My solution is to put a VBS-file in the boot-section of every computer (which run OS-Fedora). This file will never change and can therefore set the parameters in the guest. I will also need to set IP etc., but that can come next
How should the script look?
1st-script:
---------------------
sName = class2
sOldName=Wscript.CreateObject("Wscript.Network").Computername
if sOldName <> sName then
netdom renamecomputer sOldName /newname:sName /usero:administrator /passwordo:mypass /reboot:1
end if
---------------------
2nd-script:
---------------------
strUser = class2
strPassword = mypass
Set objNetwork = CreateObject("WScript.Network")
strComputer = objNetwork.ComputerName
if strComputer <> strUser then
Set objComputer = GetObject("winmgmts:{impersonationLevel=Impersonate}!\\" & strComputer & "\root\cimv2:Win32_ComputerSystem.Name='" & strComputer & "'")
echo objComputer.Name
Error= objComputer.Rename(strUser, strPassword, strUser)
shutdown -r
end if
----------------------
3rd-script:
----------------------
sName = class2
if Wscript.CreateObject("Wscript.Network").Computername <> sName then
B:\newsid.exe /a sName
end if
----------------------
-
- Volunteer
- Posts: 17798
- Joined: 17. Mar 2008, 13:41
- Primary OS: Debian other
- VBox Version: PUEL
- Guest OSses: Windows XP, Windows 7, Linux
- Location: /dev/random
Re: Setting hostname on guest
At my school, the teachers placed the tool newsid.exe on the desktop of the Guest OS, let the students run it first thing when they start with the class to generate new SIDs and provide a computer name like the first three letters of their name, along with the class name. We always worked in pairs, so you ended up with a name that is 10 characters long (e.g. sastersv4a, that's the combination of sasquatch, terry and sv4a, my class name). Other examples can be the birthday.
Really, I personally would adjust the study material instead of spending all this time scripting things that might not even be needed. After all, you only get a conflict in computer names and SIDs if you use bridged networking.
Really, I personally would adjust the study material instead of spending all this time scripting things that might not even be needed. After all, you only get a conflict in computer names and SIDs if you use bridged networking.
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.
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.
Re: Setting hostname on guest
Alternate approach: use "VBoxManage geustcontrol" with user credentials and the command of your choice.
Template/Sample:
Template/Sample:
Code: Select all
VBoxManage.exe guestcontrol <id> run --username <user> --password <pass> -- /usr/bin/which which
-
- Site Moderator
- Posts: 39134
- Joined: 4. Sep 2008, 17:09
- Primary OS: MS Windows 10
- VBox Version: PUEL
- Guest OSses: Mostly XP
Re: Setting hostname on guest
Posting to an 11 year old topic, not really a good idea.