VMware Cloud Community
stevenbright
Enthusiast
Enthusiast

Modify Guest OS IP Address

Is it possible to modify the IP address and associated settings using vCO without doing a full guest customization? If so, could someone provide an example?

The scenario that I have is that during a server provision, the server must initially be placed in a "provisioning" VLAN and assigned a static IP. Then after certain tasks are completed, the VM needs to be relocated to a "final" VLAN and assigned a new static IP address.

Thanks!

Reply
0 Kudos
5 Replies
cdecanini_
VMware Employee
VMware Employee

You can use guest operations workflows "run program in guest" to run a script / command to change the IP.

If my answer resolved or helped you, please mark it as Correct or Helpful to award points. Thank you! Visit http://www.vcoteam.info & http://blogs.vmware.com/orchestrator for vCenter Orchestrator tips and tutorials - @vCOTeam on Twitter
Reply
0 Kudos
stevenbright
Enthusiast
Enthusiast

Any ideas on how to get this to function in Windows 2008 R2 by using a local account with membership to the Administrators group instead of using the built in Administrator account? I can utilize c:\windows\system32\netsh.exe by using the "Run program in guest" workflow under the built in Administrator, but no other account will work. Disabling UAC doesn't affect the outcome.

Reply
0 Kudos
iiliev
VMware Employee
VMware Employee

I haven't tried it, but tools like PsExec could be useful for remote execution.

http://technet.microsoft.com/en-us/sysinternals/bb897553

Reply
0 Kudos
thechaos
Enthusiast
Enthusiast

Hi,

i have solved this by running a powershell script using the 'Run Programm in Guest'. The script is copied to the guest and than gets executed. As the identifier for which network card to configure i use the MAC address of the network card.

The script looks like this:

[CmdletBinding()]

param (

    [parameter(Mandatory=$true,Position=1)]

    [string]$mac="xxxxx",

   

    [parameter(Mandatory=$true,Position=2)]

    [string]$ip="",

   

    [parameter(Mandatory=$true,Position=3)]

    [string]$netmask="",

   

    [parameter(Mandatory=$false,Position=4)]

    [string]$gw="",

   

    [parameter(Mandatory=$false,Position=5)]

    [string]$dnslist=""

)

if (!(Test-Path("c:\temp\"))) {

    New-Item "c:\temp\" -type directory

}

start-transcript c:\temp\ConfigureNetwork.log

$NIC = Get-WmiObject Win32_NetworkAdapterConfiguration | where {$_.MACAddress -eq "$mac"}

if ($NIC) {

    "Configure adapter"

    if (!$ip) {

        "Ip not given"

        exit 1

    }

    "Using IP $ip"

    if (!$netmask) {

        "Netmask not given"

        exit 2

    }

   

    "Using netmask $netmask"

    $NIC.EnableStatic($ip, $netmask)

    if ($gw) {

        "Using default gw $gw"

          $NIC.SetGateways($gw)

    }

   

    if ($dnslist) {

        "Using dnsserver $dnslist"

        $DNSServer = @();

        foreach ($server in $dnslist.split(",")) {

            $DNSServer += $server

        }

          $NIC.SetDNSServerSearchOrder($DNSServer)

    }

      $NIC.SetDynamicDNSRegistration("FALSE")

} else {

    "Netwokcard not found"

    exit 10

}

exit 0

Stop-Transcript

Thomas

Reply
0 Kudos
julienvarela
Commander
Commander

Hi,

In my workflow  i am using "run program in a guest" but just before this workflow i defined my environnement variable.

basically i run this command inside the VM :

c:\windows\system32\cmd.exe /c

Programpath :c:\windows\system32\cmd.exe

Argumentpath : netsh interface ip set address name="Local Area Connection" static IP netmask  gateway 1 & dns1 & dns2

But in my workflow it is a little more complicated because IP , netmask etc.. are variable that i defined before (using scriptable task).

Regards,

Julien.

Regards, J.Varela http://vthink.fr
Reply
0 Kudos