Internet is not working inside virt-manager

I have followed the Virt-manager - Official NixOS Wiki . But, the internet inside VMs aren’t working properly. I was able to view/ping my router’s dashboard from VM, but I couldn’t visit or ping any public URLs (e.g., nixos.org). Configuring DNS manually didn’t help solve the issue. I have tried on both Windows 10 and Arch Linux VMs.

I’m looking for a solution to my problem. Also, it will be really helpful if there is a similar QEMU-KVM Installation for Arch Linux · GitHub , setup guide on NixOS.

Let me know if I can help with any related information.

Are you in a system or user session, and what networking device type have you set up?

It’s my personal system and I am inside user session that has root privileges.

I gave AI bunch of info, and it says,

Based on everything you’ve provided, the problem is NOT:

  • :cross_mark: DNS (you’re pinging IPs and they fail)

  • :cross_mark: Default route missing (it exists)

  • :cross_mark: VM interface down (it’s up with an IP)

  • :cross_mark: libvirt network inactive (default is active + autostart)

  • :cross_mark: IP forwarding disabled on host (it’s enabled)

  • :cross_mark: NAT masquerade missing (your LIBVIRT_PRT MASQUERADE rules exist)

  • :cross_mark: libvirtd needing restart (you rebooted the whole system)

What do you mean “user session that has root privileges”?

Try setting up the VM in a system session.

I didn’t understand what you meant by a system session.

Can you explain what a system session is? And, it will be also helpful if you give any relevant wiki links that shows how I can create VM in a system session.

Instead of qemu:///session use qemu:///system when creating the VM.

I use virt-manager which did not prompt for asking anything like this but, my Libvirt Connection URI is qemu:///system, I checked it with virsh uri command.

I have tried installing virt-manager inside a newly installed NixOS and it has the same issues.

My configuration.nix configuration.nix · GitHub
flake.nix flake.nix · GitHub
home.nix home.nix · GitHub

Hi,

Currently you using networkmanager to handle the network on the host. If you provide us with networkmanager settings and the libvirt domain xml of your virtual machine to show the full network settings.

Perhaps someone using the networkmanager with virtual machines could give then some comments. I don’t use networkmanager but a static network definition and a bridge on my nixos host for using with multiple virtual machines.

But, when I installed the system. It does install network manager.
I found this in my /etc/nixos/configuration.nix,

  # Enable networking
  networking.networkmanager.enable = true;

And, I did not configure anything by myself. Everything should be in default values.

Also, if you think using something else other than NetworkManager is easier please share.

I just realized, I uploaded a broken configuration.nix. Can you check again? I probably tried to remove the lines related to virt-manager and reinsert them but forgot.

In the configuration I see that you use the device virbr0. That means that you want to use a virtual machine with a NATed network connection. This is the default for virtlib. If you look into libvirt: Virtual Networking it could helpto set parameters in virt-manager, for which there is no Nixos configuration. This is out of scope for my configuration.