Network not working in a QEMU/KVM virtual machine running Arch linux

21,585

OK. One image you posted shows that you do have a network adapter configured in QEMU, and another one shows that it appears in the VM's Arch Linux when you enter ip a. However, the interface (here ens5) is not configured in the VM.

Please configure the network in the VM using the excellent Arch Linux page on network configuration here (better than I could explain it!):

Arch Linux Wiki: Network configuration

and report back.

As a quick test, you can try (as root, within the VM):

dhcpcd ens5

(on other systems you sometimes need to type dhclient ens5 instead) as a temporary initiation of a connection.

If this works, there are several methods of creating a permanent configuration which also works.

Method with netctl:

While being connected (see dhcpcd command aboove):

pacman -S netctl

to install netctl, in case it isn't already installed. (It might actually be a good idea to upgrade your system using pacman -Syu at some point, perhaps before this command, but it might also make this situation more complicated - choose yourself!)

Then, create a configuration file for your network interface (called ens5 as seen per ip a command):

cp /etc/netctl/examples/ethernet-dhcp /etc/netctl/ens5_dhcp_profile

Then edit the file as needed (or create it from scratch right away) so that it looks like this:

Interface=ens5
Connection=ethernet
IP=dhcp

Then start netctl and enable this profile for netctl:

systemctl enable netctl
systemctl start netctl

cd /etc/netconfig
netctl enable ens5_dhcp_profile
netctl start ens5_dhcp_profile

And try rebooting to see whether it works.

BTW: Linking images that contain text is deprecated because people and search engines cannot read the text within your question and they may not find your question if they type in the same error messages or output contained within the images. Next time, please try to copy and enter the actual text if possible. (External images may also be deleted outside of our control which means that the question on StackExchange - since it was not self-contained - is rendered incomplete.)

Share:
21,585
Akshay Rathod
Author by

Akshay Rathod

Updated on September 18, 2022

Comments

  • Akshay Rathod
    Akshay Rathod almost 2 years

    I have installed Arch Linux in a KVM/QEMU virtual machine using the virt-manager program. However, network inside the VM is not working.

    My host system has Ubuntu 18.04 and I am using a Wi-Fi based internet connection on host.

    Connection details in virt-manager:

    enter image description here

    This was there by default.

    enter image description here

    This was created by me.

    Output of ip a:

    enter image description here

    • Ned64
      Ned64 almost 5 years
      Check the virtual machine settings (e.g. in virt-manager) and add a network card. If it exists, issue the "ifconfig" or "ip a" commands as root in the VM after rebooting it and post the answers.
    • Akshay Rathod
      Akshay Rathod almost 5 years
      @Ned64 Thank you for your reply. i have edited the question and added the images.
  • Akshay Rathod
    Akshay Rathod almost 5 years
    You mean interface ens3? how do i configure it? dhcpcd ens3 worked. now i am able to ping. but you said it is a temporary. so can you tell me how to configure it. and for the images which contained text, i don't know how to copy text from VM to my host machine.that's why i took a screenshot of it.
  • Akshay Rathod
    Akshay Rathod almost 5 years
    Yesterday dhcpcd was working but today it is not working. showing error: no IPv6 Router available.is it because i did pacman -Syyy yesterday??? but netctl was installed so i followed your steps but it didn't work. i tried setting static IP also but that did'nt work as well. and by the way you are explaining very thoroughly.
  • Akshay Rathod
    Akshay Rathod almost 5 years
    It is working. thank you very much. :D .i had changed NIC settings to macvtap. that's why it was not working. i changed it to virtaul machine's NAT and it started working.
  • Ned64
    Ned64 almost 5 years
    @AkshayRathod I am glad it works! :-)