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.

Sorry, I wasn’t able to fix it, I just found out Quickemu to be more userfriendly and easier for me. I had to install quickemu from the unstable branch.

1 Like

If you have your own firewall installed, libvirt will stomp all over it with iptable tables and rules translated to nftables

I have my own nftable configuration and found it better to write my own nat and forwarding rules and set the libvirt network config from <forward mode='nat'/> to <forward mode=’open’/>

I think before looking at the wiki for virt-manager I didn’t tinker with anything related to firewall. So, I there was something else which was causing the issue. I have very little knowledge about customizing XML for a VM.

I’m not sure if this will work on your computer, but I found that the network can work after adding this to default.xml:

<network>
 ...
 <dns>
  <forwarder addr="8.8.8.8" />
 </dns>
</network>