open-vm-tools icon indicating copy to clipboard operation
open-vm-tools copied to clipboard

Debian 9 - bad NIC interpretation (ens160)

Open ewypych opened this issue 9 years ago • 22 comments

I've just installed the new Debian 9 and I'm trying to customize Debian in the vCloud Director. Unfortunately, I cannot, because script can't customize network properly. Please take a look at this snippet from /var/log/vmware-imc/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:
DEBUG: Exit Code: 256
INFO: Customizing NICS. { NIC1 }
INFO: Customizing NIC NIC1
DEBUG: Command: '/sbin/ifconfig -a'
DEBUG: Result: ens160: flags=4098<BROADCAST,MULTICAST>  mtu 1500
        ether 00:50:56:01:0d:1a  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<host>
        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
INFO: Configuring gateway from the primary NIC 'NIC1'

As you see, Debian has a link named ens160 instead of eth0. I am not sure why script tries to check eth0, but it's bad. The worst thing is that script thinks NIC should have name "ether". After the customization my /etc/network/interfaces file looks like this:

auto ether
iface ether inet static
address X.X.X.X
...

Ens160 was created by default, so I assume it's a normal behavior on Debian 9. Customization of course fails and I have no network configured.

ewypych avatar Jun 20 '17 13:06 ewypych

Can you please provide the complete 'customization log file' available at /var/log/vmware-imc/toolsDeployPkg.log

stanguturi avatar Jun 20 '17 17:06 stanguturi

Yes, sure, you can take a look at the whole log here, on gist: CLICK. If you need more information or tests from my side, please let me know. :)

ewypych avatar Jun 20 '17 19:06 ewypych

Thanks. It seems the output of 'ifconfig -a' got changed in Debian 9. Will file a new internal bug for further investigation.

stanguturi avatar Jun 20 '17 22:06 stanguturi

Noticed that this issue was reported already in https://github.com/vmware/open-vm-tools/issues/130

stanguturi avatar Jun 20 '17 22:06 stanguturi

Oh, I didn't search for the closed issues...

Ok, from the lecture I understand that it's the vCenter's problem (Customization.pm), not with open-vm-tools. Could you please confirm me that?

In one hand ifconfig is deprecated (Red Hat also said that), but on the other hand, is still working, so everything should work perfectly with that tool. And unfortunately, I don't believe VMware's matrixes. :) Even VMware doesn't trust them and matrixes are not the reliable documents for the VMware Support.

ewypych avatar Jun 21 '17 06:06 ewypych

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.

eLvErDe avatar Jul 27 '17 18:07 eLvErDe

This is still an issue for Debian 9.X

INFO: Customizing NICS. { NIC1 }
INFO: Customizing NIC NIC1
DEBUG: Command: '/sbin/ifconfig -a'
DEBUG: Result: ens192: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet xx.xx.xx.xx  netmask 255.255.255.240  broadcast xx.xx.xx.xx
        inet6 xxxxxxxxxxxxxxxxx  prefixlen 64  scopeid 0x20<link>
        ether 00:50:56:95:17:02  txqueuelen 1000  (Ethernet)
        RX packets 31  bytes 3885 (3.7 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 23  bytes 3366 (3.2 KiB)
        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<host>
        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

As mentioned earlier the problem is the new ifconfig colons. open-vm-tools thinks that ether is the first interface. So network customization fails.

Regards, Jesse.

Randlemann avatar Oct 13 '17 12:10 Randlemann

Hi,

You can try patching VMware files with my patch above, it works just fine for me (but I nearly deploy only Debian 9).

eLvErDe avatar Oct 13 '17 12:10 eLvErDe

@eLvErDe

Thanks for your quick reply. Unfortunately we are not able to make such changes. Due to reasons ;).

This "problem" should be updated. ifconfig is deprecated in favor of iproute2. ifconfig package isn't even installed on Debian 9.x by default. And i presume more and more distros will do this.

Randlemann avatar Oct 13 '17 12:10 Randlemann

I see ;-) Hopefully I was also the guy "in charge" of the ESX server for reason that there was nobody else :D

Indeed, ip should be used. But I'm not sure ip command is available on older systems, could be an issue as well...

eLvErDe avatar Oct 13 '17 12:10 eLvErDe

Yes, backwards compatibility is a b#$%&. open-vm-tools should just use ip by default and return to ifconfig when ip is not installed.

Randlemann avatar Oct 13 '17 12:10 Randlemann

@eLvErDe "conditionals" is the answer. :) Please take a look at this code, located in open-vm-tools/scripts/linux/network:

# Find out all the non-loopback up interfaces. Use ip if available
   # otherwise fall back to the ifconfig command.
   # ifconfig is buggy on some platforms and truncates long
   # network names
   if [ -n "$ip_cmd" ]; then
      for nic in $($ip_cmd link show up | egrep '\bUP\b' | awk -F: '{print $2}'); do
         $ip_cmd link show ${nic%@*} | grep -iq 'link/ether' && echo ${nic%@*} >> $activeList
      done
   else
      for nic in $($ifconfig_cmd | sed -n 's/^\([^: \t]*\).*$/\1/p'); do
         intf_out=$($ifconfig_cmd $nic)
         echo $intf_out | grep -iq loopback && continue
         echo $intf_out | egrep -q '\bUP\b' && echo $nic >> $activeList
      done
   fi

It's possible to create the "if" conditional. And I agree with @Randlemann - ifconfig is deprecated in many systems, for example, Red Hat suggests to use ip instead of ifconfig. They have plans to remove ifconfig completely from the OS environment.

ewypych avatar Oct 13 '17 12:10 ewypych

Well, of course it's possible but I hate Perl and I'm not working at VMWare so I leave it to whom it may concern ;)

eLvErDe avatar Oct 13 '17 12:10 eLvErDe

It's weird because

Use ip if available otherwise fall back to the ifconfig command.

That doesn't work as intended apparently... I'm pretty sure ip is available on my debian 9.x image 😄

Randlemann avatar Oct 13 '17 12:10 Randlemann

I still have this issue, also with Debian 9. Question: can a script be injected into vm-tools to run after it has done its stuff, to insert a fixed version is available in the debian repos? Answer: a config can be added to /etc/network/interfaces.d/foo so that even if the foo interface is not configured correctly in /etc/network/interfaces, it will come up.

Boran avatar Nov 08 '18 10:11 Boran

I see this issue in Ubuntu 18.04 as well.

sayantandas avatar Nov 09 '18 10:11 sayantandas

The fix I mentioned above doesn’t work as expected - vmtools rewrites interfaces and removes the include to interfaces.d :(

Boran avatar Nov 09 '18 11:11 Boran

My patch works just fine, I ve been deploying Stretch VMs for ages

eLvErDe avatar Nov 09 '18 12:11 eLvErDe

Thanks. It seems the output of 'ifconfig -a' got changed in Debian 9. Will file a new internal bug for further investigation.

The issue was fixed in latest VMware vCenter releases. (At least 6.7 onwards). Please update the vCenter builds for the fix.

stanguturi avatar Jul 12 '19 19:07 stanguturi

A newer vcenter doesn't seem to work. Using Ubuntu 20.04, net-tools (1.60+git20180626.aebd88e-1ubuntu1), open-vm-tools (2:11.0.5-4) and VCSA 6.7.0 build 14368073 (aka 6.7u3) I still get a device named "ether" instead of "eth0" or "ethX" basically.

The console shows 6.7.0.4000.

I'm going to try and remove net-tools altogether and hope it works, no idea why if "ip" is present why it isn't used over "ifconfig". I did also try and set /etc/vmware-tools/scripts/vmware/network to have ifconfig_cmd set to blank (i.e. ""), but that also didn't work.

zbukhari avatar Jul 07 '20 23:07 zbukhari