The static IP setup under CentOS 8 and Hyper-V is very simple. There are only a few steps before we are up and running.
First we will need to find the IP address of the default Gateway(the host machine) and see which IP addresses will be assigned.
Get the Gateway IP
Just open a Command Prompt(CMD) or PowerShell and then check the IP address of the Virtual Switch Gateway:
You can read more about the Virtual Switch management in this very useful article – https://mikefrobbins.com/2018/11/08/managing-the-hyper-v-default-switch-in-windows-10-version-1709-and-higher-with-powershell/
The default IP range of the Virtual Switch by default is under a class B network and ranges from 172.24.XX.XX/16.
In this case the Internal Host IP is 172.27.160.1 this means that we can use it as a gateway in the NetworkManager.
Set the static IP of the VM
First make sure that you are editing the correct interface:
Then edit it from:
To a manual IPv4 configuration:
Restart the NetworkManager
sudo systemctl restart NetworkManager.service # Or sudo nmcli networking off sudo nmcli networking on
Overall this is everything that we have to do in order to assign a static IP to CentOS 8 under Hyper-V.
Thanks for reading!