Operations 8 min read

How to Configure Network for Linux VMs in Hyper‑V Using the Default Switch (NAT)

This guide walks through using Hyper‑V's Virtual Switch Manager to set up a Default Switch with NAT, configure the vEthernet adapters, and manually assign static IP, gateway, netmask, and DNS on a CentOS 7.9 VM so it gains network connectivity.

Raymond Ops
Raymond Ops
Raymond Ops
How to Configure Network for Linux VMs in Hyper‑V Using the Default Switch (NAT)

Hyper‑V includes a built‑in Hyper‑V Manager and a Virtual Switch Manager for creating and managing local virtual machine environments. The author created two VMs—CentOS 7.9 (Linux) and Windows 11—and discovered the Linux VM had no network connectivity because its network settings were not configured by default.

Virtual Switch Manager

The Virtual Switch Manager can be opened by right‑clicking the server name in the left‑hand pane of Hyper‑V Manager or via the preview pane. It allows creation and configuration of virtual switches and network adapters.

Virtual Switch Manager UI
Virtual Switch Manager UI

The default virtual switch is Default Switch (default network).

Default Switch configuration
Default Switch configuration

Virtual Switch Types

Internal : Enables communication between VMs on the same Hyper‑V host and between those VMs and the host.

External : Maps the virtual network to a physical network adapter (including wireless adapters) on the host.

Private : Allows communication only among VMs on the same host; the host cannot communicate with the VMs.

Additional tips: VLAN IDs can be assigned to virtual adapters to extend existing VLANs, and VLANs partition traffic between logical networks.

Default Switch (NAT) Details

When using the Default Switch, the host creates two adapters: vEthernet (Default Switch) and vEthernet (WLAN) . These adapters are the source of the virtual network for the VMs.

vEthernet adapters in Network Connections
vEthernet adapters in Network Connections

Viewing the host's network configuration with ipconfig /all shows the IP address and subnet mask that will serve as the VM's gateway.

ipconfig /all
ipconfig output
ipconfig output

Configuring Network on the CentOS VM

Inside the CentOS VM, the default network interface is eth0. Verify it with:

ip addr
ip addr output showing eth0
ip addr output showing eth0

Edit the interface configuration file:

vi /etc/sysconfig/network-scripts/ifcfg-eth0
Editing ifcfg-eth0
Editing ifcfg-eth0

Set the following parameters:

BOOTPROTO=static – use a static IP.

ONBOOT=yes – enable the interface at boot.

IPADDR – assign an IP address in the same subnet as the virtual switch.

GATEWAY – specify the gateway (the host’s vEthernet address).

NETMASK – set the subnet mask.

Configure DNS by editing /etc/resolv.conf to match the host’s DNS servers.

Editing resolv.conf
Editing resolv.conf

After saving changes, restart the network service: systemctl restart network.service Verify the new settings:

Network settings after restart
Network settings after restart

Test connectivity from the VM to external networks:

Ping test from CentOS VM
Ping test from CentOS VM

With these steps, the CentOS VM can communicate through the Default Switch’s internal NAT network.

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.

NATVirtualizationNetwork ConfigurationCentOSHyper-VVirtual Switch
Raymond Ops
Written by

Raymond Ops

Linux ops automation, cloud-native, Kubernetes, SRE, DevOps, Python, Golang and related tech discussions.

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.