You are not logged in.

#1 2024-11-21 21:40:59

zf
Member
Registered: 2019-03-04
Posts: 10

[libivrt] Static IP address not being used by guest machine

I am running the official Arch Basic VM preinstalled image on a guest machine using the libvirt/qemu/vkm stack intended for testing Ansible playbooks. I'm struggling to gest the guest to receive a static IP address--here's the steps I've taken:

    $ virsh shutdown <guest>
    $ virsh net-edit default             # Edit the 'default' network to: https://0x0.st/Xnd_.txt
    $ systemctl restart libvirtd
    $ virsh start <guest>
    $ virsh net-dhcp-leases default  # Output below:


    Expiry Time           MAC address         Protocol   IP address         Hostname    Client ID or DUID
    -----------------------------------------------------------------------------------------------------------------------------------------------
    2024-11-21 12:14:42   52:54:00:99:3b:2d   ipv4       192.168.122.3/24   archlinux       ff:56:50:4d:98:00:02:00:00:ab:11:fc:ef:36:3f:44:8e:ef:d5

IP address is not set to 19.2168.122.101 as given. Any ideas? I've also tried the following:

    $ virsh domif-setlink arch-vm 52:54:00:99:3b:1d down
    $ sleep 10
    $ virsh domif-setlink arch-vm 52:54:00:99:3b:1d up

    $ sudo mv '/var/lib/libvirt/dnsmasq/virbr0'* /tmp     # This is supposed to renew the lease
    $ sudo net-destroy default
    $ sudo net-start default


And in the guest, also tried:

    $ sudo ip link set eth0 down
    $ sudo ip link set eth0 up

Primary source of reference: https://docs.redhat.com/en/documentatio … ip-address


Any ideas is much appreciated, this is driving me crazy. I have a feeling it's supposed to work if I run the second block of commands in a particular order. But from google search, it also seems like they shouldn't be necessary and simply restart the libvirtd.service is enough. I'm thinking about switch to bridge interface, but I'm not sure if it's a good idea to leave the host using the bridge network permanently even if I don't interact with virtual machines any more, or if it's okay to easily switch between bridged networking and "regular" networking depending on whether I work with the VMs on the host. I assume it would disrupt internet connection (however briefly, which can be an issue for dropped downloads).

Last edited by zf (2024-11-21 21:45:10)

Offline

#2 2024-11-23 15:57:21

Lone_Wolf
Administrator
From: Netherlands, Europe
Registered: 2005-10-04
Posts: 13,245

Re: [libivrt] Static IP address not being used by guest machine

The redhat guide mentions 2 commands to verify settings, and a 3rd to set the static address.

What are the outputs if you use the 3 commands from that guide ?



Moderator Note: Moving to Networking, Server, and Protection board.


Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.

clean chroot building not flexible enough ?
Try clean chroot manager by graysky

Offline

#3 2024-11-23 18:43:30

zf
Member
Registered: 2019-03-04
Posts: 10

Re: [libivrt] Static IP address not being used by guest machine

Lone_Wolf wrote:

The redhat guide mentions 2 commands to verify settings, and a 3rd to set the static address.

What are the outputs if you use the 3 commands from that guide ?



Moderator Note: Moving to Networking, Server, and Protection board.


    $ virsh domiflist arch-vm
    Interface   Type      Source    Model    MAC
    -------------------------------------------------------------
    vnet0       network   default   virtio   52:54:00:99:3b:1d

    $ virsh net-dumpxml default | egrep 'range|host\ mac'
    egrep: warning: egrep is obsolescent; using grep -E
    grep: warning: stray \ before white space
          <range start='192.168.122.2' end='192.168.122.254'/>
          <host mac='52:54:00:99:3B:1D' ip='198.168.122.201'/>

    $ virsh net-update default add ip-dhcp-host '<host mac="52:54:00:99:3B:1D" ip="198.168.122.101"/>' --live --config

    error: Failed to update network default
    error: Requested operation is not valid: there is an existing dhcp host entry in network 'default' that matches "<host mac='52:54:00:99:3B:1D' name='(null)' ip='198.168.122.101'/>"


Last command fails because it was already added (no errors when it was initially added).

Last edited by zf (2024-11-23 18:44:10)

Offline

Board footer

Powered by FluxBB