IP address of VMs in gnome-boxes

@ms-patil

Because I don’t know for sure where which (type of) config file has to be stored in your environment, I tend to not just create any virtual network config manually.

My suggestion here is to install virt-manager (dnf install virt-manager) and use that to create the network and to add it to the vm.

So, install virt-manager and then open it with the same user you open gnome-boxes. Now, you should see the same VMs in virt-manager as in gnome-boxes. If this is not the case, let me know. Only if this is the case, proceed as follows:

In the virt-manager, click on “edit” in the menu bar and then click on “connection details”. In the connection details window’s menu bar, click on “Virtual Networks”. Click now on the “+” button to create a new virtual network. Give the network a name (I will assume in the next steps you call it “network1”), set it to NAT mode (should be default), Forward to: Any physical device (should be default). The IPv4 configuration should be by default a proper network with X at “Enable IPv4” and X at “Enable DHCPv4”. If not by default, enable both! Check the contained addresses/address spaces, but they should fit automatically. Then finish.

Now, a new network is added in the connection details window. Click on the new network and add the X at “on boot” and then click “apply”. Now, click on the play button to start it. Close the window.

Now open the virtual machine configuration file as before and to the following section:

<interface type='user'>
    <mac address='52:54:00:e4:c5:c0/>
    <model type='virtio'/>
    <address type='pci domain='0x0000' bus='0x01' slot='0x00' function='0x0'/>
</interface>

Now add the <source network="network1"/> line (or whatever name you choose for the virtual network) to the section:

<interface type='user'>
    <mac address='52:54:00:e4:c5:c0/>
    <source network="network1"/>
    <model type='virtio'/>
    <address type='pci domain='0x0000' bus='0x01' slot='0x00' function='0x0'/>
</interface>

Save & close.

Now systemctl restart libvirtd.service to ensure that everything gets reloaded, and now try again your vm! You can use gnome-boxes or virt-manager.

Check out your ip address within the VM and check the connection with ssh and ping.

How does it work?