Generally, for host → virtual, or host ← virtual, there is already a virtual bridge (usually called Virtual Network 'default' : NAT) that is created when you installed the software. You would need to find out what IP each device has and then you can use the IP to connect. If you wanted to use host names, you could edit the /etc/hosts file to add a mapping for the needed IP, on each host. Virtual ↔ virtual generally works out of the box with host names, as long as they are both on the same virtual network.
A Network bridge is much more difficult to set up, and usually only needed if you need a VM to appear as a physical host on the network. I.E. a second physical host that needs access to VM on first physical host. Depending on your network setup, you still may need to edit the hosts file to reach them by name. The following Arch wiki entry can help with a network bridge, if it is indeed needed
Thank you for your help.
I’ll explain my setup better, it’s very simple.
I have 2 virtual machines, the first with Ubuntu and the second with Windows and it would be enough for me that they were reachable from each other.
The problem is that starting them both receive the same IP address. Of course the ping between the two machines doesn’t work either.
I tried setting the IP address manually but without success, I set the windows machine to the address 10.0.2.20 but it can’t see the ubuntu at the address 10.0.2.15 (but can navigate to internet…)
C:\Users\User>ipconfig
Windows IP Configuration
Ethernet adapter Ethernet 3:
Connection-specific DNS Suffix . :
Site-local IPv6 Address . . . . . : fec0::dbf6:28c8:2b79:3cc5%1
Link-local IPv6 Address . . . . . : fe80::b2fe:b061:541:c0ae%14
IPv4 Address. . . . . . . . . . . : 10.0.2.20
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . : fe80::2%14
10.0.2.2
C:\Users\User>ping 10.0.2.2
Pinging 10.0.2.2 with 32 bytes of data:
Reply from 10.0.2.2: bytes=32 time=1ms TTL=255
Reply from 10.0.2.2: bytes=32 time<1ms TTL=255
Reply from 10.0.2.2: bytes=32 time<1ms TTL=255
Reply from 10.0.2.2: bytes=32 time<1ms TTL=255
Ping statistics for 10.0.2.2:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 0ms, Maximum = 1ms, Average = 0ms
C:\Users\User>ping 10.0.2.15
Pinging 10.0.2.15 with 32 bytes of data:
Reply from 10.0.2.20: Destination host unreachable.
Reply from 10.0.2.20: Destination host unreachable.
Reply from 10.0.2.20: Destination host unreachable.
Reply from 10.0.2.20: Destination host unreachable.
Ping statistics for 10.0.2.15:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
The default network segment for me has always been 192.168.122.0/24, with a gateway of 192.168.122.1, In Virt-manager under Edit->Connection Details then Virtual Networks tab you should have a screen like this:
Yes, it appears that you have created a bridge through libvirt possibly. Honestly, I was never able to make that work, in a useful way. I always create my bridge through the OS itself, which then show up as an option in virt-manager when creating the VM (or can be changed on existing VMs).
I would recommend creating the default network again, the instructions and where to get the data can be found here (from Stackoverflow): Restore default network libvirt
If you create the file just make sure it is named default.xml
Again, if you want a network bridge, I would follow the link for the Arch wiki above to create through the OS.
sudo cat /etc/libvirt/qemu/networks/default.xml
<!--
WARNING: THIS IS AN AUTO-GENERATED FILE. CHANGES TO IT ARE LIKELY TO BE
OVERWRITTEN AND LOST. Changes to this xml configuration should be made using:
virsh net-edit default
or other application using the libvirt API.
-->
<network>
<name>default</name>
<uuid>56514044-f1e9-4b48-aa1a-14a5f9eeb61d</uuid>
<forward mode='nat'/>
<bridge name='virbr0' stp='on' delay='0'/>
<mac address='52:54:00:4f:38:2e'/>
<ip address='192.168.122.1' netmask='255.255.255.0'>
<dhcp>
<range start='192.168.122.2' end='192.168.122.254'/>
</dhcp>
</ip>
</network>
This is the error I get following the method you linked to me
sudo virsh net-define default.xml
errore: impossibile collegarsi all'hypervisor
errore: Operazione non supportata: Cannot use direct socket mode if no URI is set
No need to thank me, especially since I haven’t “solved” anything for you.
From your previous post where you mentioned qemu:///session, something of a faint memory came to me. I looked at the link you worked from, checked my installs (all qemu:///system), and did a little research (one of the better pages). I stumbled back across that qemu:///session is running unprivileged, and networking is limited. There is a way to use virbr0 still though, as long as it is in /etc/qemu/bridge.conf, you can check yours to see that you get this.
$ cat /etc/qemu/bridge.conf
allow virbr0
What I don’t know, is how that might show up in the list when you choose networking for a new or existing VM. I can try spinning up a VM, running through the instructions you used later (after I get some sleep), and hopefully get back to you with a solution.
Edit: You might try in NIC setting of a VM by using setting Network source: to Bridge device…, and Device name: to virbr0 (screenshot is just where you want to be, don’t use my setting)
OK, sorry this took so long. When I started earlier I wasn’t quite awake, and introduced a completely unrelated issue, and followed it right down the rabbit hole. Once I came out the other side with a solution, I had steps that then didn’t seem necessary. I flattened my lab and started over, without said rabbit hole, and indeed the solution was as easy as my last post screenshot under the Edit:
To recap, in your settings for the VM, goto NIC
in Network source: use Bridge device...
in Device name: type virbr0
This will allow the VMs to communicate with each other by name or IP, and you can communicate with the host by IP. To use hostname you would need to edit the /etc/hosts file appropriately on each machine.
From your screenshot, it looks like the default connection of QEMU/KVM was deleted. You may want to add that back, in case you ever want to edit the virbr0 network with a GUI. If you decide to, just click File -> Add Connection... make sure it says QEMU/KVM, and click Connect.