Now that CentOS7 is out, time to make sure I can setup my virtual machines with the VMXNET3 vmnic. As I documented in my previous post, CentOS 6.x using the VMXNET3 driver requires VMware Tools, VMware Tools needs Perl, Perl is not included in the minimal ISO so I need network access to get Perl to install VMware Tools to get network access. That order of operations doesn’t work very well.
Also, as of CentOS7, VMware now recommends Open Virtual Machine Tools so you would not be installing VMware Tools as I pointed out in my CentOS 6.x post on VMXNET3. Good news, though, VMXNET3 drivers in CentOS7 do not need VMware Tools but there are seemingly some new steps to get networking working. So, lets get started; now obviously we don’t want to install the OS every single time you need it, so my assumption here is that the use case if for your initial template build. With that assumption out of the way I am going to create a new virtual machine in the vSphere Web Client with the following settings:
- VM hardware version 10 (since now we can edit them in the C# client)
- Guest OS Family - Linux
- Guest OS Version - CentOS 4/5/6/7 (64-bit)
- Virtual Hardware
- 1 vCPU
- 1GB memory
- New hard disk - thin provisioned
- 1x vmnic - VMXNET3 connected
Once the new machine is created, power it on and connect to the console, install the OS as you normally would - notice when you get to the Installation Summary screen the network says Not Connected; click on it and you’ll see that i seems to recognize the VMXNET3 controller. I am not going to set this adapter to “ON” right now, I am going to leave it “OFF” to show you how to bring it up on the command line. Finish the and reboot once completed. Log in and run ifconfig…egads command not found? What is Linux going all Microsoft on us and changing things for the sake of changing it!! Well if you tried to do a yum or ping anything right now, you’d not have network access as you might expect. So where to go from here?
Well it appears there is no more /etc/udev/rules.d/70-persistent-net.rules file any more, so lets have a look at /etc/sysconfig/network-scripts. Hmm where is my ifcfg-eth0 file?
That has been replaced now, notice the ifcfg-eno16777984 file, that is what we want (though not sure where the numbering comes from) - open it in vi so we can have a look. Yup looks just like the old ifcfg-eth0 file, lets get to work. Change BOOTPROTO from dhcp to none and add the following with valid information for your network; IPADDR, NETMASK, GATEWAY, DNS1. Here is what my file looks like now:
Now that you are all set, [esc] :wq [enter] to save it and service network restart - now ping 220.127.116.11…wait what - I STILL can’t ping? What is wrong? Apparently in CentOS7 restarting the network service is not enough, we need to bring the actual interface up. If you do an ls in /etc/sysconfig/network-scripts you’ll notice the ifup command - always been there, I never used it before but this is what you’ll use to bring up your interface, something like
Now, here you can see our network is up
But… this will not be persistent over network service or virtual machine restarts so you’ll need also edit the ifcfg-eno######## file and change ONBOOT to yes, now you can restart networking or your virtual machine and maintain networking
More information about the changes can be found in the CentOS7 FAQ.