VMware Cloud Community
braddman1
Enthusiast
Enthusiast

Network adapters coming up default DISCONNECTED on various servers

When I restart the hosts, I have several network adapters that come up DISCONNECTED. Is there any way to force them to connect at start up?

Reply
0 Kudos
5 Replies
Anjani_Kumar
Commander
Commander

Is this happening with you esxi servers or the Virtual machines?

Please consider marking this answer "correct" or "helpful" if you found it useful. Anjani Kumar | VMware vExpert 2014-2015-2016 | Infrastructure Specialist Twitter : @anjaniyadav85 Website : http://www.Vmwareminds.com
Reply
0 Kudos
braddman1
Enthusiast
Enthusiast

The VMs are coming up default DISCONNECTED.

Reply
0 Kudos
Anjani_Kumar
Commander
Commander

Must check the Network card type too. If your esxi host is 5.5 den you must change all those network card to "vmxnet3" Type

Here is an perl script which can help you out.

You need to set the startConnected as well as connected in the connectable property for the device to handle both poweredOn and poweredOff states of a VM.

  1. #!/usr/bin/perl -w   
  2. use strict;   
  3. use warnings;   
  4. use VMware::VIRuntime;   
  5. my %opts = (   
  6.    network => {   
  7.       type => "=s",   
  8.       help => "Network name",   
  9.       required =>0,   
  10.       default => "Network adapter 1",   
  11.    },   
  12.    operation => {   
  13.       type => "=s",   
  14.       help => "connect or disconnect",   
  15.       required => 0,   
  16.       default => "connect",   
  17.    },   
  18.    vmname => {   
  19.       type => "=s",   
  20.       help => "Name of virtual machine",   
  21.       required => 1   
  22.    }   
  23. );  
  24. Opts::add_options(%opts);   
  25. Opts::parse();   
  26. Opts::validate();   
  27. Util::connect(); 
  28. my ($vm_view, $network, $operation, @vmnics, $vmnic, $vm_spec, $dev_spec); 
  29. $vm_view = Vim::find_entity_view(view_type => 'VirtualMachine',    
  30.                                  filter => {'name' => Opts::get_option('vmname') }, 
  31.                                  properties => ['name', 'config.hardware.device'] );   
  32. die "failed to locate virtual machine '" . Opts::get_option('vmname') . "'" unless $vm_view; 
  33.     
  34. $network = Opts::get_option('network');   
  35. $operation = Opts::get_option ('operation');  
  36. # Get list of vmnics from the virtual machine config.hardware.device array 
  37. @vmnics = grep { $_->isa("VirtualEthernetCard") } @{$vm_view->{'config.hardware.device'} || []}; 
  38. # Find the vmnic by device label 
  39. ($vmnic) = grep { $_->{'deviceInfo'}{'label'} } @vmnics; 
  40. die "failed to locate virtual machine nic by label '$network'" unless $vmnic; 
  41. # Set the connectable flag for the vmnic 
  42. if ($operation =~ m/^connect$/) { 
  43.   $vmnic->{'connectable'}{'connected'} = 1; 
  44.   $vmnic->{'connectable'}{'startConnected'} = 1; 
  45. } elsif ($operation =~ m/^disconnect$/) { 
  46.   $vmnic->{'connectable'}{'connected'} = 0; 
  47.   $vmnic->{'connectable'}{'startConnected'} = 0; 
  48. } else { 
  49.   die "operation must be 'connect' or 'disconnect'"; 
  50. # Create reconfigure spec 
  51. $vm_spec = new VirtualMachineConfigSpec(); 
  52. # Create deviceChange spec 
  53. $dev_spec = new VirtualDeviceConfigSpec( device => $vmnic ); 
  54. $dev_spec->{'operation'} = new VirtualDeviceConfigSpecOperation('edit'); 
  55. $vm_spec->{'deviceChange'} = [ $dev_spec ]; 
  56. # Call ReconfigVM.  Use synchronous version 
  57. $vm_view->ReconfigVM(spec => $vm_spec); 
  58. print "Virtual machine reconfigured\n"; 
  59. Util::disconnect();   

$ perl eran.pl --username=administrator --password=VMware1! --server=172.16.254.10 --vmname=TestUUID --network="Network adapter 1" --operation=connectVirtual machine reconfigure

Please consider marking this answer "correct" or "helpful" if you found it useful. Anjani Kumar | VMware vExpert 2014-2015-2016 | Infrastructure Specialist Twitter : @anjaniyadav85 Website : http://www.Vmwareminds.com
Reply
0 Kudos
braddman1
Enthusiast
Enthusiast

All the NICS are set to FLEXIBLE.

OK I am an idiot. Connect at power on was not checked...easiest fix ever. But they are still flexible, should I change them to VMXNET3

Reply
0 Kudos
Anjani_Kumar
Commander
Commander

yes. The vmxnet3 should be checked on all the virtual machines.

As i was the victim of this.In my environment all the e1000 and flexible nic added. and it has a bug with vsphere 5.5 . so i had moved them to the vmxnet3 and the issue got fixed.

Anyways you got your fix. have a great day.

Please consider marking this answer "correct" or "helpful" if you found it useful. Anjani Kumar | VMware vExpert 2014-2015-2016 | Infrastructure Specialist Twitter : @anjaniyadav85 Website : http://www.Vmwareminds.com
Reply
0 Kudos