GNS3 / gns3-gui

GNS3 Graphical Network Simulator
http://www.gns3.com
GNU General Public License v3.0
2.19k stars 437 forks source link

Spice fails with only IPV4. (no IPV6) #3588

Closed jsaenzh01 closed 5 months ago

jsaenzh01 commented 6 months ago

I have the opposite case to https://github.com/GNS3/gns3-gui/issues/2352

Gns3 is always opening a IPV6 connection even if IPV6 is disabled.

I have disabled ipv6 with sysctl: net.ipv6.conf.all.disable_ipv6 = 1 net.ipv6.conf.default.disable_ipv6 = 1 net.ipv6.conf.lo.disable_ipv6 = 0 net.ipv6.conf.tun0.disable_ipv6 = 1 net.ipv6.conf.br0.disable_ipv6 = 1

In "ip address show", ipv6 is not showed (not even in loopback): 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc knockout state UNKNOWN group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master br0 state UP group 57841 qlen 1000 link/ether..... )

However, spice connection is always an error-> It tried to connect is always with ::

Start QEMU with /usr/bin/qemu-system-x86_64 -name Debian12-1 -m 2048M -smp cpus=1,sockets=1 -enable-kvm -machine smm=off -boot order=c -drive file=/run /media/jesus/GNS3/projects/forense/project-files/qemu/2d7239e9-8e1d-406b-bd07-7662ef0cebad/hda_disk.qcow2,if=virtio,index=0,media=disk,id=drive0 -uuid 2d7239e9- 8e1d-406b-bd07-7662ef0cebad -spice addr=::,port=5003,disable-ticketing .... Execution log: qemu-system-x86_64: -spice addr=::,port=5003,disable-ticketing: warning: short-form boolean option 'disable-ticketing' deprecated Please use disable-ticketing=on instead qemu-system-x86_64: warning: Spice: reds.cpp:2551:reds_init_socket: getaddrinfo(::,5003): Address family for hostname not supported qemu-system-x86_64: warning: Spice: reds.cpp:3441:do_spice_init: Failed to open SPICE sockets qemu-system-x86_64: failed to initialize spice server.

I am able to fix it changing this: sudo nano /usr/lib/python3.11/site-packages/gns3server/compute/qemu/qemu_vm.py

` if self._console: console_host = self._manager.port_manager.console_host if console_host == "0.0.0.0": if socket.has_ipv6:

to fix an issue with Qemu when IPv4 is not enabled

                # see https://github.com/GNS3/gns3-gui/issues/2352
                # FIXME: consider making this more global (not just for Qemu + SPICE)
                console_host = "0.0.0.0"
            else:`

Its not a big deal, i write this if It help anyone. Cheers

GNS3 version and operating system (please complete the following information):

To Reproduce Steps to reproduce the behavior:

  1. Open a VM
  2. Click on Start
  3. See errror
grossmj commented 5 months ago

We rely on Python to tell us that IPv6 is enabled. Can you try the following command please?

python -c "import socket ; print(socket.has_ipv6)"

ghost commented 5 months ago

A look into the Python sources tells me that socket.has_ipv6 returns a boolean value indicating if IPv6 is supported by this Python binary. But it doesn't tell, if IPv6 is active in the OS. This can be tested in a Docker container. Although Docker uses interfaces with only IPv4 addresses socket.has_ipv6 returns True.

I find the following StackOverflow discussion interesting: https://stackoverflow.com/questions/66246308/detect-if-ipv6-is-supported-os-agnostic-no-external-program

jsaenzh01 commented 5 months ago

Hi,

Of course. My output: Captura de pantalla_20240617_091403

Thanks