Configure Hyper‑V Virtual Switches: Enable NAT Networking for Linux VMs
Learn how to use Hyper‑V’s Virtual Switch Manager to create and configure internal (NAT) virtual switches, set up vEthernet adapters, and manually configure static IP, gateway, and DNS on a CentOS 7.9 VM so it gains network connectivity.
Hyper‑V includes a built‑in manager for creating and managing local virtual machines. After creating a CentOS 7.9 VM and a Windows 11 VM, the Linux VM lacks network connectivity because no local network configuration is set.
Virtual Switch Manager
Hyper‑V networking consists of virtual network adapters and virtual switches. To enable communication, attach a virtual network adapter to a virtual switch.
The "Virtual Switch Manager" component can be opened from the server name context menu or the preview pane in Hyper‑V Manager.
Using the system default virtual switch "Default Switch" (internal NAT) as shown.
Virtual Switch Types
Hyper‑V provides three types of virtual switches:
Internal : Enables communication between each VM on the host and between VMs and the host.
External : Maps the virtual network to a specific physical network adapter (including wireless), allowing VMs to access external networks.
Private : Allows communication only among VMs on the same host; the host cannot communicate with the VMs.
Tips: You can assign a VLAN ID to a virtual switch to extend existing VLANs, and VLANs can be used to partition network traffic.
Configuring the Default Switch (NAT)
The Default Switch creates a NAT network where the VM receives a gateway and subnet mask from the host.
In Windows, the relevant adapters are "vEthernet (Default Switch)" and "vEthernet (WLAN)".
vEthernet (Default Switch) IPv4 Settings
vEthernet (WLAN) IPv4 Settings
You can also view adapter details with ipconfig /all.
Setting Up Network on a CentOS VM
The CentOS VM created by Hyper‑V has no network configuration by default.
Identify the network interface (usually eth0) with ip addr and edit /etc/sysconfig/network-scripts/ifcfg-eth0:
BOOTPROTO=static – set static IP
ONBOOT=yes – enable on boot
IPADDR=… – static IP in the same subnet as the virtual NIC
GATEWAY=… – gateway address
NETMASK=… – subnet mask
Configure DNS by editing /etc/resolv.conf to match the host’s DNS.
After editing, restart the network service: systemctl restart network.service Verify the configuration; connectivity tests show the VM can reach external networks.
Thus, using the Default Switch’s internal NAT mode and configuring the CentOS network completes the virtual machine networking setup.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
MaGe Linux Operations
Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
