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 - bad NIC interpretation (ens160) #172

Closed
ewypych opened this issue Jun 20, 2017 · 22 comments
Closed

Debian 9 - bad NIC interpretation (ens160) #172

ewypych opened this issue Jun 20, 2017 · 22 comments

Comments

@ewypych
Copy link

ewypych commented Jun 20, 2017

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.

@stanguturi
Copy link
Contributor

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

@ewypych
Copy link
Author

ewypych commented Jun 20, 2017

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. :)

@stanguturi
Copy link
Contributor

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

@vmware vmware deleted a comment from vmwareopenvmtools Jun 20, 2017
@stanguturi
Copy link
Contributor

Noticed that this issue was reported already in #130

@ewypych
Copy link
Author

ewypych commented Jun 21, 2017

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.

@eLvErDe
Copy link

eLvErDe 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.

@Randlemann
Copy link

Randlemann commented Oct 13, 2017

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.

@eLvErDe
Copy link

eLvErDe commented Oct 13, 2017

Hi,

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

@Randlemann
Copy link

@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.

@eLvErDe
Copy link

eLvErDe commented Oct 13, 2017

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...

@Randlemann
Copy link

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

@ewypych
Copy link
Author

ewypych commented Oct 13, 2017

@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.

@eLvErDe
Copy link

eLvErDe commented Oct 13, 2017

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 ;)

@Randlemann
Copy link

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 😄

@Boran
Copy link

Boran commented Nov 8, 2018

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.

@sayantandas
Copy link

I see this issue in Ubuntu 18.04 as well.

@Boran
Copy link

Boran commented Nov 9, 2018

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

@eLvErDe
Copy link

eLvErDe commented Nov 9, 2018

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

@stanguturi
Copy link
Contributor

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.

@zbukhari
Copy link

zbukhari commented Jul 7, 2020

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.

@fluggelgleckheimlen
Copy link

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.

You can add 20.04 to /usr/lib/vmware-vpx/imgcust/linux/imgcust-scripts/UbuntuNetplanCustomization.pm on the VCSA to make it works with Ubuntu 20.04.

@mahkorayem
Copy link

You can add 20.04 to /usr/lib/vmware-vpx/imgcust/linux/imgcust-scripts/UbuntuNetplanCustomization.pm on the VCSA to make it works with Ubuntu 20.04.

Just did it and worked flawlessly

(17.10|20.04|1[8-9].(04|10))/i)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants