You are not logged in.

#1 2024-06-22 19:37:23

OhKay_Bet
Member
Registered: 2023-11-16
Posts: 35

No internet for KVM/QEMU

having trouble getting internet connection for virt machines working. On virt-manager the virtual bridge shows as inactive and when creating a new machine a prompt asking to start the virtual network spits this out.

Could not start virtual network 'default': internal error: Child process (VIR_BRIDGE_NAME=virbr0 /usr/bin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/default.conf --leasefile-ro --dhcp-script=/usr/lib/libvirt/libvirt_leaseshelper) unexpected exit status 2: 
dnsmasq: failed to create listening socket for 192.168.122.1: Address already in use


Traceback (most recent call last):
  File "/usr/share/virt-manager/virtManager/device/netlist.py", line 208, in _check_network_is_running
    netobj.start()
  File "/usr/share/virt-manager/virtManager/object/libvirtobject.py", line 57, in newfn
    ret = fn(self, *args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/share/virt-manager/virtManager/object/network.py", line 69, in start
    self._backend.create()
  File "/usr/lib/python3.12/site-packages/libvirt.py", line 3569, in create
    raise libvirtError('virNetworkCreate() failed')
libvirt.libvirtError: internal error: Child process (VIR_BRIDGE_NAME=virbr0 /usr/bin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/default.conf --leasefile-ro --dhcp-script=/usr/lib/libvirt/libvirt_leaseshelper) unexpected exit status 2: 
dnsmasq: failed to create listening socket for 192.168.122.1: Address already in use

looking at systemctl shows this

dnsmasq.service - dnsmasq - A lightweight DHCP and caching DNS server
     Loaded: loaded (/usr/lib/systemd/system/dnsmasq.service; enabled; preset: disabled)
     Active: active (running) since Fri 2024-06-21 03:17:04 UTC; 1 day 12h ago
 Invocation: 2a666aabef574c229eb967b0114b5196
       Docs: man:dnsmasq(8)
    Process: 1052 ExecStartPre=/usr/bin/dnsmasq --test (code=exited, status=0/SUCCESS)
   Main PID: 1063 (dnsmasq)
      Tasks: 1 (limit: 76902)
     Memory: 1.5M (peak: 2.3M)
        CPU: 23ms
     CGroup: /system.slice/dnsmasq.service
             └─1063 /usr/bin/dnsmasq -k --enable-dbus --user=dnsmasq --pid-file

Jun 21 03:17:04 User systemd[1]: Started dnsmasq - A lightweight DHCP and caching DNS server.
Jun 21 03:17:04 User dnsmasq[1063]: started, version 2.90 cachesize 150
Jun 21 03:17:04 User dnsmasq[1063]: compile time options: IPv6 GNU-getopt DBus no-UBus i18n IDN2 DHCP DHC>
Jun 21 03:17:04 User dnsmasq[1063]: DBus support enabled: connected to system bus
Jun 21 03:17:04 User dnsmasq[1063]: warning: interface virbr0 does not currently exist
Jun 21 03:17:04 User dnsmasq[1063]: reading /etc/resolv.conf
Jun 21 03:17:04 User dnsmasq[1063]: using nameserver 192.168.1.1#53
Jun 21 03:17:04 User dnsmasq[1063]: read /etc/hosts - 0 names
Jun 21 03:17:04 User dnsmasq[1063]: reading /etc/resolv.conf
Jun 21 03:17:04 User dnsmasq[1063]: using nameserver 10.64.0.1#53
libvirtd.service - libvirt legacy monolithic daemon
     Loaded: loaded (/usr/lib/systemd/system/libvirtd.service; enabled; preset: disabled)
     Active: active (running) since Sat 2024-06-22 15:27:47 UTC; 4min 39s ago
 Invocation: b1070ecea68e4495b0397bc26876b565
TriggeredBy: ● libvirtd-admin.socket
             ● libvirtd-ro.socket
             ● libvirtd.socket
       Docs: man:libvirtd(8)
             https://libvirt.org/
   Main PID: 865436 (libvirtd)
      Tasks: 20 (limit: 32768)
     Memory: 14.5M (peak: 22.3M)
        CPU: 675ms
     CGroup: /system.slice/libvirtd.service
             └─865436 /usr/bin/libvirtd --timeout 120

Jun 22 15:27:47 User systemd[1]: Starting libvirt legacy monolithic daemon...
Jun 22 15:27:47 User systemd[1]: Started libvirt legacy monolithic daemon.
Jun 22 15:28:25 User dnsmasq[866642]: failed to create listening socket for 192.168.122.1: Address already in use
Jun 22 15:28:25 User dnsmasq[866642]: FAILED to start up
Jun 22 15:28:25 User libvirtd[865436]: libvirt version: 10.4.0
Jun 22 15:28:25 User libvirtd[865436]: hostname: User
Jun 22 15:28:25 User libvirtd[865436]: internal error: Child process (VIR_BRIDGE_NAME=virbr0 /usr/bin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/default.conf --leasefile-ro --dhcp-script=/usr/lib/libvirt/libvirt_leaseshelper) unexpected exit status 2: 

Offline

#2 2024-06-22 20:30:12

cryptearth
Member
Registered: 2024-02-03
Posts: 1,214

Re: No internet for KVM/QEMU

unless you NEED NAT networking I recommend using bridged networking - setting up a bridge is easy with several network managers

Offline

#3 2024-06-22 20:51:29

OhKay_Bet
Member
Registered: 2023-11-16
Posts: 35

Re: No internet for KVM/QEMU

cryptearth wrote:

unless you NEED NAT networking I recommend using bridged networking - setting up a bridge is easy with several network managers

What would determine if I need NAT. Didn't even realize I was setting it up as such. I know that I'd want to mess around with ssh and hosting via the VM.

Last edited by OhKay_Bet (2024-06-22 20:52:54)

Offline

#4 2024-06-22 22:10:09

cryptearth
Member
Registered: 2024-02-03
Posts: 1,214

Re: No internet for KVM/QEMU

to keep it short and simple:

NAT networking: exactly the same as your physical lan - your router separates the internet and your network, outgoing traffic is simple while unwanted incoming traffic is blocked and filtered, to the outside all your systems look like a single endpoint
using it with VMs the host also becomes somewhat a router between the physical lan and the VMs

bridged networking: a network bridge is a virtual switch the VMs connect to and thereby become part of the physical network as if they were real physical machines
should be avoided on public/shared networks like public wifi, work, campus and such as often the IT guys don't like random virtual system spam the network - which can lead to actions against you

my point here is: although both techniques have thier pros and cons setting up a bridge and have the VMs just become part of the network usually is simpler than to fiddle around with dnsmasq and nat networking
my wording about "need for" is due to the required restrictions some networks has unless it's your own network - I remember a topic over at the ubuntu forums where someone caused issues for the campus network and as a "punishment" got restricted to a locked down laptop issued by the IT guys and was denied any further access for thier private devices

Offline

#5 2024-06-22 22:20:31

OhKay_Bet
Member
Registered: 2023-11-16
Posts: 35

Re: No internet for KVM/QEMU

cryptearth wrote:

to keep it short and simple:

NAT networking: exactly the same as your physical lan - your router separates the internet and your network, outgoing traffic is simple while unwanted incoming traffic is blocked and filtered, to the outside all your systems look like a single endpoint
using it with VMs the host also becomes somewhat a router between the physical lan and the VMs

bridged networking: a network bridge is a virtual switch the VMs connect to and thereby become part of the physical network as if they were real physical machines
should be avoided on public/shared networks like public wifi, work, campus and such as often the IT guys don't like random virtual system spam the network - which can lead to actions against you

my point here is: although both techniques have thier pros and cons setting up a bridge and have the VMs just become part of the network usually is simpler than to fiddle around with dnsmasq and nat networking
my wording about "need for" is due to the required restrictions some networks has unless it's your own network - I remember a topic over at the ubuntu forums where someone caused issues for the campus network and as a "punishment" got restricted to a locked down laptop issued by the IT guys and was denied any further access for thier private devices

WOW, thank you for that response. That really helps out my understanding of whats going on. To clarify a home desktop would have no problem as a bridged network, while a travel laptop should be done via NAT?

Seems like I'm leaning towards a bridged network, which is what I thought I was doing. Although it seems like dnsmasq should only be used for NAT networking based on your explination?

Last edited by OhKay_Bet (2024-06-22 22:21:13)

Offline

#6 2024-06-23 07:18:33

cryptearth
Member
Registered: 2024-02-03
Posts: 1,214

Re: No internet for KVM/QEMU

OhKay_Bet wrote:

WOW, thank you for that response. That really helps out my understanding of whats going on. To clarify a home desktop would have no problem as a bridged network, while a travel laptop should be done via NAT?

exactly - when you at home usually it doesn't matter if you have one, ten or hundred clients in your network - to the outside world they all appear as one endpoint
when you connected to someone elses network - no matter if it's the hotels wifi or some uplink on the plane or you sit in a starbucks shop - it's not your network and you don't have authority over it - and you're usually restricted to one or two devices at once (i.e. a laptop and your phone) - in such case using nat networking should be preferred way as you present your local virtual multi-machine network as just one endpoint to the network you're connected to - and usually you don't want any incoming connections on public networks anyway - unless you're some evil guy but then you would an open bridge anyway

Offline

Board footer

Powered by FluxBB