Operations 7 min read

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.

MaGe Linux Operations
MaGe Linux Operations
MaGe Linux Operations
Configure Hyper‑V Virtual Switches: Enable NAT Networking for Linux VMs

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.

Virtual Switch Manager location
Virtual Switch Manager location

Using the system default virtual switch "Default Switch" (internal NAT) as shown.

Default Switch configuration
Default Switch configuration

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 adapters in Network Connections
vEthernet adapters in Network Connections

vEthernet (Default Switch) IPv4 Settings

IPv4 settings of Default Switch
IPv4 settings of Default Switch

vEthernet (WLAN) IPv4 Settings

IPv4 settings of WLAN adapter
IPv4 settings of WLAN adapter

You can also view adapter details with ipconfig /all.

ipconfig output
ipconfig output

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.

Network configuration verification
Network configuration verification

Thus, using the Default Switch’s internal NAT mode and configuring the CentOS network completes the virtual machine networking setup.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

WindowsNATCentOSHyper-VVirtual Switch
MaGe Linux Operations
Written by

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.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.