I am building vagrant boxes for RHEL 7 for both VirtualBox and Hyper-V. I use packer to build the boxes. The build process works fine for both providers.
When I use these new boxes to create VMs, the VirtualBox versions work fine. For the Hyper-V versions, the network interface will not come up. I’m sure this is something many people have done before and has a trivial solution, I just can’t figure it out.
I traced this to the fact that the /etc/sysconfig/network-scripts/ifcfg-eth0 file hard-codes the MAC address used during the build process, and does not account for Hyper-V generating a new MAC when instantiating the VM. If I manually log on and delete the one line with the HWADDR, the interface will come up just fine. One thing I could do is hack my Kickstart file to delete that line from the config file, but that seems more like a workaround rather than a solution.
Vagrant: 2.2.6 (older version due to the vagrant version in my WSL config)
Windows 10: 10.0.19042 Build 19042
Bonus question: any idea why RHEL uses the traditional NIC naming in the VM, instead of the new predictable naming scheme?