If you’re running Ubuntu Server as a virtual machine under Windows 11 using Hyper-V, you may encounter the frustrating “Network Is Unreachable” error. This guide will walk you through the steps needed to effectively resolve this issue, ensuring your server can access both local and external networks. We’ll cover everything from configuring your Hyper-V settings to properly setting up network configurations inside your Ubuntu Server.

Configuring the Hyper-V Virtual Switch for Ubuntu Server

Step 1: Launch Hyper-V Manager on your Windows 11 system. In the left panel, select your host machine and proceed by clicking on “Virtual Switch Manager” located in the Actions pane. This interface lets you create and manage network switches for your virtual machines.

img 680acbb5853ed

Step 2: Choose the “New virtual network switch” option. Select “External” if you wish for your Ubuntu Server VM to connect to your physical network and the internet. Click “Create Virtual Switch,” assign it a logical name, and select the physical network adapter your computer utilizes for internet access. Remember to save your changes.

img 680acbb615325

Step 3: If your Ubuntu Server VM is currently running, shut it down. In Hyper-V Manager, access the settings for the VM. Under “Network Adapter,” select the virtual switch you just configured. Apply the changes and restart the VM.

Setting Up Network Configuration Inside Ubuntu Server

Step 1: Boot up your Ubuntu Server VM and log in. Check the status of your network interfaces by executing the following command:

1ip a

This command provides a list of all network interfaces along with their current statuses. Look for interfaces named eth0, ens33, or something similar.

Step 2: Assess whether an IP address is assigned to your chosen interface. If it lacks an IP address, you may need to enable DHCP or manually configure a static IP. Edit the netplan configuration file, often located at /etc/netplan/01-netcfg.yaml or a similar directory. For DHCP settings, your configuration should resemble:

1network:
2  version: 2
3  ethernets:
4    eth0:
5      dhcp4: true

Be sure to replace eth0 with the name of your network interface if it’s different.

Step 3: Activate the new configuration by typing:

1sudo netplan apply

This command will apply the updated network settings. To test connectivity, ping an external address such as:

1ping 8.8.8.8

If you receive replies, congratulations! Your network is up and running smoothly.

Checking Firewall and Routing Settings

Step 1: Assess any firewall rules in your Ubuntu instance that could restrict traffic. Check the status using:

1sudo ufw status

If the firewall is enabled, confirm it allows outbound connections. For temporary testing, you can disable the firewall with:

1sudo ufw disable

Step 2: Verify that the default gateway is configured correctly. Execute the following command:

1ip route

The expected output should include a line starting with default via followed by an IP address. If there is no default gateway listed, add one using:

1sudo ip route add default via [gateway_ip]

Make sure to replace [gateway_ip] with your actual network gateway address.

Alternative: Using NAT or Internal Network for Isolated Environments

If your VM does not require access to the external network, consider configuring a NAT or Internal virtual switch in Hyper-V. This method restricts the VM’s communication to only the host or other VMs, making it ideal for testing or isolated workloads. In Hyper-V Manager, create a new “Internal” or “Private” switch, link it to your Ubuntu VM, and ensure the VM’s network interface is properly configured.

Conclusion

Resolving the “Network Is Unreachable” error on your Ubuntu Server running under Windows 11 Hyper-V can be straightforward with the right steps. From configuring the virtual switch to checking firewall and routing settings, following this guide ensures reliable network connectivity for your server environment. Whether accessing the broader internet or isolating your VM for testing, these configurations will get you back online seamlessly.

Support Tech2Geek ❤️

AI-powered search engines are making it harder for small independent blogs like ours to survive. If you find our guides helpful, please consider supporting us.

You can help by sharing our articles or making a small donation.

☕ Make a Small Donation

Every contribution helps us keep creating free tech guides and reviews.

Categorized in: