Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

debian 9 (stretch) customizing NIC uses wrong interface name #130

Closed
gstorme opened this issue Jan 10, 2017 · 28 comments

Comments

Projects
None yet
@gstorme
Copy link

commented Jan 10, 2017

Hi,

ESXi 6.0
Debian 9 stretch/sid
open-vm-tools 10.1.0-4449150-2
guestOS other3xlinux-64
The net-tools package is installed to have the ifconfig binary.

When customizing the NIC, the wrong adapter name is parsed and instead of network interface "eth0", it configures "ether".

From toolsDeployPkg.log:

INFO: Customizing NICS ...
DEBUG: Command: 'modprobe pcnet32 2> /dev/null'
DEBUG: Result:
DEBUG: Exit Code: 0
DEBUG: Command: '/sbin/ifconfig eth0 2> /dev/null'
DEBUG: Result: eth0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
ether 00:50:56:98:1b:c5 txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

DEBUG: Exit Code: 0
INFO: Customizing NICS. { NIC1 }
INFO: Customizing NIC NIC1
DEBUG: Command: '/sbin/ifconfig -a'
DEBUG: Result: eth0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
ether 00:50:56:98:1b:c5 txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10
loop txqueuelen 1 (Local Loopback)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

DEBUG: Exit Code: 0
INFO: NIC suffix = ether

@oliverkurth

This comment has been minimized.

Copy link
Contributor

commented Jan 10, 2017

@gregster85 , could you run the ifconfig command, and copy the output? I know, it's right there in the debug output, but maybe we are missing something. It looks different to what I see in my machine.

@gstorme

This comment has been minimized.

Copy link
Author

commented Jan 11, 2017

root@debian:~# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet x.x.x.x netmask 255.255.255.224 broadcast x.x.x.x
inet6 fe80::20c:29ff:fedb:6da1 prefixlen 64 scopeid 0x20
ether 00:0c:29:db:6d:a1 txqueuelen 1000 (Ethernet)
RX packets 1666675 bytes 120657343 (115.0 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 103310 bytes 13086058 (12.4 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

@oliverkurth

This comment has been minimized.

Copy link
Contributor

commented Jan 11, 2017

Thank you. This looks like https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=820212 . Can you try upgrading the net-tools package to 1.60+git20161116.90da8a0-1 or later?

@gstorme

This comment has been minimized.

Copy link
Author

commented Jan 12, 2017

It's already that version.
net-tools 1.60+git20161116.90da8a0-1

ifconfig --version
net-tools 2.10-alpha

Reading from that bug report, I don't think they changed the formatting.
They just included an article with a statement that it has changed.

  • Add debian/NEWS warning about changing output in net-tools commands.
    Closing bugs that reported problems in 3rd-party scripts arising from these
    changes.

Which contains:

net-tools (1.60+git20161116.90da8a0-1) unstable; urgency=medium
After 15 years without upstream development, net-tools is being worked on
again, fixing many long-standing issues.
The bad news is that the output of many commands has changed, and it is sure
to break scripts that relied on parsing it.
If you have customs scripts that use any of these commands, please make sure
they still work after this upgrade:
netstat, ifconfig, ipmaddr, iptunnel, mii-tool, nameif, plipconfig, rarp,
route, slattach, arp.
Apologies in advance for the trouble that this may cause, but maintaining a
separate version of net-tools just to keep the old format is something I am
not able to do.
-- Martín Ferrari tincho@debian.org Mon, 26 Dec 2016 05:29:25 +0000

@oliverkurth

This comment has been minimized.

Copy link
Contributor

commented Jan 12, 2017

Thanks, Greg. I have created an internal bug about this.

@bzed

This comment has been minimized.

Copy link

commented Mar 1, 2017

net-tools is also pretty much deprecated. the only useful way to get information about interfaces is using the ip from iproute2. @oliverkurth

@msteenhu

This comment has been minimized.

Copy link

commented Mar 2, 2017

An update if this will get fixed anytime soon?

@bzed

This comment has been minimized.

Copy link

commented Mar 2, 2017

@msteenhu does this still fail with the version from unstable? Looking at the code it is using ip, not ifconfig. So it should work... Please make sure iproute2 is installed. I'll add that as a dependency.

@gstorme

This comment has been minimized.

Copy link
Author

commented Mar 3, 2017

@bzed I installed the package from unstable but it still seems to use ifconfig instead of ip, which causes the wrong interface to be configured, "ether" instead of "eth0".
The package iproute2 is installed.

iproute2 4.9.0-1
open-vm-tools 2:10.1.5-5055683-1

Attached is the full output of the toolsDeployPkg.log

toolsDeployPkg.txt

@msteenhu

This comment has been minimized.

Copy link

commented Mar 3, 2017

@bzed I reach same conclusions as Greg. My company relies on VMWare and Debian so it is obviously important for us that our hypervisor supports the latest version.
If we can't use guest customization we have to look for alternatives. I didn't spend time in debugging the Perl scripts myself. It is on my todo to look into it. Maybe I can help with a PR.

@bzed

This comment has been minimized.

Copy link

commented Mar 3, 2017

Looking ath the toolsDeployPkg.txt it does not seem that the script is part of open-vm-tools. Also I was unable to find code where ifconfig would be called instead of ip.

@msteenhu

This comment has been minimized.

Copy link

commented Mar 3, 2017

We use the vcenter api using pyvmomi. So i guess vcenter injects a script. Apparently using cloud-init according to the log. Key seems to be this line:
Launching deployment /bin/bash /tmp/.vmware/linux/deploy/scripts/customize.sh /tmp/.vmware/linux/deploy/cust.cfg.

@msteenhu

This comment has been minimized.

Copy link

commented Mar 3, 2017

So guess this bug can be closed/rejected here. According to this document from VMware: http://partnerweb.vmware.com/programs/guestOS/guest-os-customization-matrix.pdf
Guest customization on Debian is not even supported :-)

@bzed

This comment has been minimized.

Copy link

commented Mar 3, 2017

@msteenhu I think is should work with the current open-vm-tools. Never tested, though.

@gstorme

This comment has been minimized.

Copy link
Author

commented Mar 3, 2017

It's the scripts that are part of the package "Deploying /tmp/vmware-root/189dd580/imc3634.tmp".
The file /tmp/.vmware/linux/deploy/scripts/Customization.pm contains the ifconfig commands.

Copyright 2014 VMware, Inc. All rights reserved.
Customization.pm
This module implements a framework for OS customization.

Are these scripts deployed by the open-vm-tools package, or how does this work?

@msteenhu

This comment has been minimized.

Copy link

commented Mar 3, 2017

As mentioned before, open-vm-tools is not to blame for this VMWare issue.
In the mean time we could locate the Perl scripts on our vcenter servers and could confirm that this scripts limit the VMWare support for guest customization. Good news is that you can edit them yourself!

@eLvErDe

This comment has been minimized.

Copy link

commented Jul 27, 2017

Hi,

For the record, I had the same issue coming from net-tools update that changed ifconfig output format.
It was a blocker for me so I dig into VMWare crap and managed to patch their broken parser to something better.

The file was at C:\Program Files\VMware\vCenter Server\vpxd\imgcust\linux\imgcust-scripts\Customization.pm on vCenter server and there's nothing to reload after modifying. Everytime you create a VM with customization this file is copied from the vCenter to the server directly inside the virtual machine filesystem.

--- Customization.pm.orig	2017-07-27 20:21:04.259828942 +0200
+++ Customization.pm.new	2017-07-27 20:21:35.559476473 +0200
@@ -756,17 +756,17 @@
    if (! defined $ifcfgResult) {
       $ifcfgResult = Utils::ExecuteCommand('/sbin/ifconfig -a');
    }
+  
+   my @interfaces = split/\n\n/, $ifcfgResult;
 
-   my $result = undef;
-
-   my $macAddressValid = ($macAddress =~ /^([0-9a-f]{2}:){5}[0-9a-f]{2}$/i);
-
-   if ($macAddressValid &&
-      ($ifcfgResult =~ /^\s*(\w+?)(:\w*)?\s+.*?$macAddress/mi)) {
-      $result = $1;
+   foreach my $interface (@interfaces) {
+      if ($interface =~ /$macAddress/) {
+	      print($interface);
+          if ($interface =~ m/^(\w+)(:|\s)/) {
+              return $1;
+          }
+      }
    }
-
-   return $result;
 }
 
 sub GetInterfaceByMacAddressIPAddrShow

vcenter_Customization_pm.diff.txt

Not heavily tested but I've been able to deploy two machines with it and the method seem to work fine on a machine with legacy net-tools.

Regards, Adam.

@val0x00ff

This comment has been minimized.

Copy link

commented Nov 13, 2017

@eLvErDe I don't have such file on my vsphere server or client. Any way to get around this problem? I've exactly the same problem as mentioned above.

Any assistance much appreciated!

@TolianIPB

This comment has been minimized.

Copy link

commented Feb 20, 2018

If you edit C:\Program Files\VMware\vCenter Server\vpxd\imgcust\linux\imgcust-scripts\Customization.pm such as upper it will stop Customize older versions of Linux.
Here is my way:

sub GetInterfaceByMacAddress
{
   # This function is same as GetInterfaceByMacAddress but uses
   # '/sbin/ip addr show' instead of/sbin/ifconfig

   my ($self, $macAddress, $ipAddrResult) = @_;
   my $result = undef;
   if (! defined $ipAddrResult) {
      my $ipPath = Utils::GetIpPath();
      if ( defined $ipPath){
         $ipAddrResult = Utils::ExecuteCommand("$ipPath addr show");
      } else {
         WARN("Path to 'ip addr' not found.");
      }
   }

   my $macAddressValid = ($macAddress =~ /^([0-9a-f]{2}:){5}[0-9a-f]{2}$/i);

   if ($macAddressValid && ($ipAddrResult =~
      /^\d+:\s([^\s.:]+):\s[^\n]+[^\n]+\s+link\/\w+\s+$macAddress/mi)) {
      $result = $1;
   }

   return $result;
}
@shibumi

This comment has been minimized.

Copy link

commented Aug 17, 2018

This is still a problem on CentOS7. It customizes the /etc/sysconfig/network-scripts/ interface files with an interface called ether that will not match any interface.

@TolianIPB

This comment has been minimized.

Copy link

commented Aug 17, 2018

sub GetInterfaceByMacAddress
...

See upper.
Is work OK with CentOS7 customization.

@rongz609

This comment has been minimized.

Copy link

commented Nov 26, 2018

This is still a problem on CentOS7. It customizes the /etc/sysconfig/network-scripts/ interface files with an interface called ether that will not match any interface.

Do you still have that problem on CentOS7?
What the version of vsphere are you using now?

@rongz609

This comment has been minimized.

Copy link

commented Nov 26, 2018

@eLvErDe I don't have such file on my vsphere server or client. Any way to get around this problem? I've exactly the same problem as mentioned above.

Any assistance much appreciated!

Do you use Windows vCenter or appliances vCenter (VCSA)?
The path @eLvErDe mentioned (C:\Program Files\VMware\vCenter Server\vpxd...) is actually the default vCenter installing path in Windows. If you used another path to install vCenter in your Windows, you may need to find that file under the path you installed vCenter.
And if you are using VCSA, you can ssh to your vCenter server, and modify /lib/vmware-vpx/imgcust/linux/imgcust-scripts/Customization.pm as @eLvErDe mentioned.
I thinks @TolianIPB 's method is also OK to work around this issue.

@rongz609

This comment has been minimized.

Copy link

commented Nov 26, 2018

It's the scripts that are part of the package "Deploying /tmp/vmware-root/189dd580/imc3634.tmp".
The file /tmp/.vmware/linux/deploy/scripts/Customization.pm contains the ifconfig commands.

Copyright 2014 VMware, Inc. All rights reserved.
Customization.pm
This module implements a framework for OS customization.

Are these scripts deployed by the open-vm-tools package, or how does this work?

Those scripts will be packed and transferred from vCenter into guest OS to execute GuestOS customization. And they will be deleted in Guest OS after customization completed.
And those scripts are stored in vCenter Server. If you are using Windows vCenter, you can find those scripts under your vCenter installing path (e.g. C:\Program Files\VMware\vCenter Server\vpxd\imgcust\linux\imgcust-scripts)
If you are using VCSA, it is /lib/vmware-vpx/imgcust/linux/imgcust-scripts/.
You can modify Customization.pm as @TolianIPB mentioned as a work around method to solve your issue.

@rongz609

This comment has been minimized.

Copy link

commented Dec 4, 2018

@gstorme This issue has been fixed in ESXi6.7 and later versions, you can work around it by the solution proposed by @TolianIPB , and you can refer to my comment to find the script file which needs to be modified.

@TolianIPB

This comment has been minimized.

Copy link

commented Dec 4, 2018

In ESXi6.7 VMware fixed it by changing /etc/networking to /etc/netplan method of network setup for new releases of Debian and Ubuntu.

@jasonarieger

This comment has been minimized.

Copy link

commented Mar 29, 2019

@rongz609 @TolianIPB Hi. I just deployed the latest VCSA 6.7 (U1b) (VMware-VCSA-all-6.7.0-11726888.iso ). I compared the sub GetInterfaceByMacAddress {} function with that of a 65. VCSA, and the function is the same. So it appears to me that VMware did not fix the issue in 6.7. :( Please advise.

@ryancbutler

This comment has been minimized.

Copy link

commented Apr 19, 2019

For anyone on an older version of vCenter VCSA (6.0.0.30500) the file can be found at /usr/lib/vmware-vpx/imgcust/linux/imgcust-scripts/Customization.pm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.