|
Reply
Re: How do I script changing from Bridged to NAT? Jul 3, 2009 9:03 AM
Reply
2.
Re: How do I script changing from Bridged to NAT? Jul 3, 2009 9:03 AM
That is a helpful suggestion. I had not thought of two NICs, yes that would do it. I am familiar with netsh and am already using that in what I am doing, as I am switching from DHCP to STATIC with that command, and yes, I did not mean "immediate" to be exactly literal. I would llike to find a way to do it though on the same NIC. I wish there was a command to order the infrastructure to make the switch. |
|
Reply
Re: How do I script changing from Bridged to NAT? Jul 4, 2009 11:12 AM
Reply
3.
Re: How do I script changing from Bridged to NAT? Jul 4, 2009 11:12 AM
I am no VIX guru, but it looks to me like VIX is intended for manipulating the guest OS from an external source. Unfortunately, this does not include messing with the settings in the VMX file. I'm not that familiar with VMware Server and its APIs, but that is more along the lines of what you are asking.
You might look into using vmware-cmd -- it lives in C:\Program Files\VMware\VMware Server, I think: I am guessing that setting the connectionType to "bridged" would revert to Bridged, but I am not certain since I don't have a VMware Server machine to play with. (Update) A little more information. You may be able to run vmware-cmd from within a VM and have it talk to the host that is running the VM. Get vmware-cmd.exe and any required support files into the guest, and use the connection options described below (put them before the path to the VMX file) Message was edited by: DougBaer |
|
Reply
Re: How do I script changing from Bridged to NAT? Jul 4, 2009 11:19 AM
Reply
4.
Re: How do I script changing from Bridged to NAT? Jul 4, 2009 11:19 AM
Thanks for the helpful answer. Unfortunately that command is not available in Windows with Server 2.x. Also, I need this command to run from inside the VM. I think you answer is close to the right track, but I'm not quite there yet. Any more suggestions? It seems that no one out there knows how to make this happen, but I am still hoping.
|
|
Reply
Re: How do I script changing from Bridged to NAT? Jul 6, 2009 6:41 PM
Reply
5.
Re: How do I script changing from Bridged to NAT? Jul 6, 2009 6:41 PM
I'm wondering if it's as simple as calling Set-NetworkAdapter cmdlet and setting the network name, VMNet0/1/2/etc... Can anyone confirm?
Looking at my Virtual Network Editor in Server2.0, VMnet0 is bridged, VMnet1 is host-only and VMnet8 is nat.... http://blogs.vmware.com/files/vi-toolkit-lab----vmworld-europe-2009.pdf |
|
Reply
Re: How do I script changing from Bridged to NAT? Jul 6, 2009 8:05 PM
Reply
6.
Re: How do I script changing from Bridged to NAT? Jul 6, 2009 8:05 PM
RE:
vmware-cmd (path to VMX file) setconfig ethernet0.connectionType="nat"
d/l and install http://communities.vmware.com/thread/191565?tstart=10. All you'll care about is the Console shortcut. See the pic for explanation. Do you have a specific test we could do?
|
|
Reply
Re: How do I script changing from Bridged to NAT? Jul 6, 2009 10:51 PM
Reply
7.
Re: How do I script changing from Bridged to NAT? Jul 6, 2009 10:51 PM
Wow - I think you are on to the answer here. I downloaded and installed all of that and have the VIX Virtuozo Client available. But I don't know what to do next. A specific test? Well, here is what needs to happen. From a command line inside a VM, run a script that changes the NIC of that VM from Bridged to NAT, and another script that does the reverse, changes it from NAT back to Bridged. |
|
Reply
Re: How do I script changing from Bridged to NAT? Jul 7, 2009 5:44 AM
Reply
8.
Re: How do I script changing from Bridged to NAT? Jul 7, 2009 5:44 AM
Once you have the Virtuozo Suite installed, run the Console from Vix_Virtuozo_Suite folder. Connect to your Server2.0. Select the VM. Then use R and W to read/write RUNTIME variables. (http://www.vmware.com/support/developer/vix-api/vix16_reference/lang/com/functions/WriteVariable.html)
We need a network traffic test to see if the NIC is actually changing from NAT to BRIDGED. How will you know that this change is working correctly? My worry is that changing the variable might not be enough. If you look at your virtual network/switch configuration using the 'Manage Virtual Networks' app that comes with Server2.0, you'll see on the 'NAT' tab that, by default, VMNet8 virtual switch is used by the NAT service (http://www.extremetech.com/article2/0,2845,1156371,00.asp). So, the thing to do in this situation is either keep searching for answers inside the VI Toolkit, or assign two Virtual NICs to the VM. One on VMNet0 and one on VMNet8. Then, as suggested, use netsh to switch between the two (http://sanbarrow.com/network/commandlineguide2vnets.html)(http://communities.vmware.com/thread/133297). Any other ideas? |
|
Reply
Re: How do I script changing from Bridged to NAT? Jul 7, 2009 9:50 AM
Reply
9.
Re: How do I script changing from Bridged to NAT? Jul 7, 2009 9:50 AM
A good test is this: If it switched to NAT, then the VM can see the real network and map drives to machines on the physical network, but no machines on the physical network can see a VM that is on NAT. If it is bridged, then machines on the physical network can see and map drives to the VM. I think that is the ultimate test.
|
|
Reply
Re: How do I script changing from Bridged to NAT? Jul 8, 2009 5:42 AM
Reply
10.
Re: How do I script changing from Bridged to NAT? Jul 8, 2009 5:42 AM
Have you tried this by just changing the connectionType variable?
Do you have Powershell and VI Toolkit installed... We can try something once you do. |
|
Reply
Re: How do I script changing from Bridged to NAT? Jul 8, 2009 9:48 AM
Reply
11.
Re: How do I script changing from Bridged to NAT? Jul 8, 2009 9:48 AM
I will install those right now. Do you know the URL link to download them? Tell me how to change the connectiion type varialble or any other command you want me to try and I'll try this right away.
|
|
Reply
Re: How do I script changing from Bridged to NAT? Jul 8, 2009 6:39 PM
Reply
12.
Re: How do I script changing from Bridged to NAT? Jul 8, 2009 6:39 PM
Ok, I now have Windows Powershell 1.0 and VMware vSphere PowerCLI installed? Is this correct? Do I have the right things installed? Bear in mind I am not running ESX, but am running Windows Vista 64-bit as the host with VMware Server 2.x and am running 2003 Server in a VM as the guest. What do I do now?
|
|
Reply
Re: How do I script changing from Bridged to NAT? Jul 9, 2009 7:15 AM
Reply
13.
Re: How do I script changing from Bridged to NAT? Jul 9, 2009 7:15 AM
With the VI toolkit there is a CMDLETs reference.
I would try playing with VMNET0/VMNET8 with Set-VirtualSwitch , Set-NetworkAdapter to begin with. Here is how you connect to your server:
|
|
Reply
Re: How do I script changing from Bridged to NAT? Jul 9, 2009 6:41 PM
Reply
14.
Re: How do I script changing from Bridged to NAT? Jul 9, 2009 6:41 PM
I wasn't sure what to do with that code. I put it in a batch file, but those don't run in powershell apparently. I then pasted it directly into the powershell windw. Is that right? This is what I get when I do that. I'm a bit lost here. I appreciate your help... PS C:\Documents and Settings\Administrator> $VMCore = Get-PSSnapin VMware.VimAutomation.Core -EA 0 PS C:\Documents and Settings\Administrator> if ( -not $VMCore ) { Add-PSSnapin VMware.VimAutomation.Core }; PS C:\Documents and Settings\Administrator> PS C:\Documents and Settings\Administrator> voidhttp://Reflection.Assembly::LoadWithParti alName("VMware.VimAutomation.Core") Unable to find type http://Reflection.Assembly: make sure that the assembly containing thi s type is loaded. At line:1 char:62 + voidhttp://Reflection.Assembly: <<<< :LoadWithPartialName("VMware.VimAutomation.Core") PS C:\Documents and Settings\Administrator> voidhttp://Reflection.Assembly::LoadWithParti alName("VMware.Vim") Unable to find type http://Reflection.Assembly: make sure that the assembly containing thi s type is loaded. At line:1 char:62 + voidhttp://Reflection.Assembly: <<<< :LoadWithPartialName("VMware.Vim") PS C:\Documents and Settings\Administrator> voidhttp://Reflection.Assembly::LoadWithParti alName("VMware.VimAutomation.Types") Unable to find type http://Reflection.Assembly: make sure that the assembly containing thi s type is loaded. At line:1 char:62 + voidhttp://Reflection.Assembly: <<<< :LoadWithPartialName("VMware.VimAutomation.Types" ) PS C:\Documents and Settings\Administrator> voidhttp://Reflection.Assembly::LoadWithParti alName("VMware.VimAutomation") Unable to find type http://Reflection.Assembly: make sure that the assembly containing thi s type is loaded. At line:1 char:62 + voidhttp://Reflection.Assembly: <<<< :LoadWithPartialName("VMware.VimAutomation") PS C:\Documents and Settings\Administrator> voidhttp://Reflection.Assembly::LoadWithParti alName("VMware.VimAutomation.Common") Unable to find type http://Reflection.Assembly: make sure that the assembly containing thi s type is loaded. At line:1 char:62 + voidhttp://Reflection.Assembly: <<<< :LoadWithPartialName("VMware.VimAutomation.Common ") PS C:\Documents and Settings\Administrator> voidhttp://Reflection.Assembly::LoadWithParti alName("VMware.VimAutomation.Client20") Unable to find type http://Reflection.Assembly: make sure that the assembly containing thi s type is loaded. At line:1 char:62 + voidhttp://Reflection.Assembly: <<<< :LoadWithPartialName("VMware.VimAutomation.Client 20") PS C:\Documents and Settings\Administrator> voidhttp://Reflection.Assembly::LoadWithParti alName("VMware.Security.CredentialStore") Unable to find type http://Reflection.Assembly: make sure that the assembly containing thi s type is loaded. At line:1 char:62 + voidhttp://Reflection.Assembly: <<<< :LoadWithPartialName("VMware.Security.CredentialS tore") PS C:\Documents and Settings\Administrator> PS C:\Documents and Settings\Administrator> PS C:\Documents and Settings\Administrator> $chost = "192.168.0.4"; PS C:\Documents and Settings\Administrator> $cuser = "mswarbrick"; PS C:\Documents and Settings\Administrator> $cpassword = "cnecne997"; PS C:\Documents and Settings\Administrator> $cport = 8333; PS C:\Documents and Settings\Administrator> $cprotocol = "https"; PS C:\Documents and Settings\Administrator> PS C:\Documents and Settings\Administrator> Connect-VIServer -Server $chost -User $cUser -Password $cPassword -Port $cpo rt -Protocol $cprotocol; WARNING: There were one or more problems with the server certificate:
IsConnected : True Name : 192.168.0.4 Port : 8333 SessionId : A4FA03DA-B4B1-4336-8FF4-15B864F79EA0 User : mswarbrick PS C:\Documents and Settings\Administrator> PS C:\Documents and Settings\Administrator> if ( $DefaultVIServer -eq $null) { Write-Host "Connection Failed!"; return $false } else { Write-Host "Connected : " $DefaultVIServer.IsConnected; ## Lets assign some views to variables $global:moServiceInstance = (get-view ServiceInstance); $global:moHostSystem = Get-View -VIObject (Get-VMHost); $global:DefaultVIServer = $DefaultVIServer; }; PS C:\Documents and Settings\Administrator> #do something PS C:\Documents and Settings\Administrator> PS C:\Documents and Settings\Administrator> Disconnect-VIServer -Server $global:DefaultVIServer -WhatIf:$False -Confirm: $false -EA 0; PS C:\Documents and Settings\Administrator> |