3

I've set up a guest machine on kvm on ubuntu 18.04 (guest is also ubuntu 18.04). I was able to connect to it via ssh and I can see an ip address is assigned to it when I type virsh domifaddr vm1 I see the following output:

 Name       MAC address          Protocol     Address
-------------------------------------------------------------------------------
 vnet0      52:54:00:64:10:51    ipv4         192.168.122.246/24

However, when I clone it with

virt-clone --connect qemu:///system --original vm1 --name vm2 --auto-clone

and the start the machine, virsh domifaddr vm2 shows the following output:

 Name       MAC address          Protocol     Address
-------------------------------------------------------------------------------

So no ip address and I don't even know how to connect to it, although the guest itself shows as "running":

# virsh list --all
 Id    Name                           State
----------------------------------------------------
 1     vm1                            running
 2     vm2                            running

I've checked xml config files for both guests - only difference is mac addresses and names of machines and disks attached. I've even added this mac address and assigned static ip to it in virsh net-edit default:

  1 <network>
  2   <name>default</name>
  3   <uuid>9a270817-c5bc-4571-877a-43b97a5a3e48</uuid>
  4   <forward mode='nat'/>
  5   <bridge name='virbr0' stp='on' delay='0'/>
  6   <mac address='52:54:00:8a:fe:4f'/>
  7   <ip address='192.168.122.1' netmask='255.255.255.0'>
  8     <dhcp>
  9       <range start='192.168.122.2' end='192.168.122.254'/>
 10       <host mac='52:54:00:64:10:51' name='vm1' ip='192.168.122.246'/>
 11       <host mac='52:54:00:f0:38:6e' name='vm2' ip='192.168.122.247'/>
 12     </dhcp>
 13   </ip>
 14 </network>

then restarted everything. Didn't help. What else do I need to do to get an ip address assigned to the cloned guest?

And for the reference, the interface-network section of xml configs for each guest:

vm1

 45     <interface type='network'>
 46       <mac address='52:54:00:64:10:51'/>
 47       <source network='default'/>
 48       <model type='virtio'/>
 49       <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
 50     </interface>


vm2

 45     <interface type='network'>
 46       <mac address='52:54:00:f0:38:6e'/>
 47       <source network='default'/>
 48       <model type='virtio'/>
 49       <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
 50     </interface>

I was also able to connect to vm2 with virsh console vm2 and ifconfig inside it gives me:

~$ ifconfig
lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 2184  bytes 191249 (191.2 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 2184  bytes 191249 (191.2 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

Update: I also re-generated machine id in /etc/machine-id /var/lib/dbus/machine-id, changed ssh keys and ran virt-sysprep -d vm2. Then rebooted everything. That didn't help either.

Update 2: running ip a on the host gives this:

5: vnet0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel master virbr0 state UNKNOWN group default qlen 1000
    link/ether fe:54:00:64:10:51 brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fc54:ff:fe64:1051/64 scope link 
       valid_lft forever preferred_lft forever
6: vnet1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel master virbr0 state UNKNOWN group default qlen 1000
    link/ether fe:54:00:f0:38:6e brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fc54:ff:fef0:386e/64 scope link 
       valid_lft forever preferred_lft forever

which corresponds to both VMs mac addresses.

4
  • I can't check my idea by myself but try to use same mac address you use for VM in dhcp host section for that VM. It looks like it may be the reason of that behaviour. Jun 10, 2019 at 5:57
  • I haven't got enough rep to comment, but what do you get from > virsh net-dhcp-leases default & what is the network portion of the dumped xml > virsh dumpxml vm2 > vm2.xml I use virt-clone in tandem with virt-sysprep - here's an example makefile for cloning.
    – Mylo Mylo
    Jun 10, 2019 at 8:14
  • Mac addresses in the dhcp section match those in the xml config files for each guest.
    – snitko
    Jun 10, 2019 at 8:20
  • virsh dumpxml just shows what I'd see anyway from virsh edit vm2. Nothing there.
    – snitko
    Jun 11, 2019 at 0:57

1 Answer 1

1

What eventually solved the problem was running dhclient ens3 on a guest.

Now working on assigning static ip address to the guest, will update the answer later.

Update. To assign static ip on Ubuntu 18.04, you need to edit /etc/netplan/[file that's there] to look something like this:

network:
    version: 2
    ethernets:
        ens3:
            dhcp4: no
            addresses: [192.168.122.245/24]
            gateway4: 192.168.122.1
            nameservers:
              addresses: [8.8.8.8,8.8.4.4]
1
  • Hi! Why did you need to assign static addresses to guest? Was running dhclient ens3 not enough? How? TIA Aug 11 at 15:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.