VMs from Template (and Clones, too) want to keep IP address of original/template

Discussion in 'Linux Virtual Machine' started by jorn, Jul 31, 2020.

  1. jorn

    jorn Bit poster

    Messages:
    23
    What I'm trying to accomplish:
    Have a template of an Ubuntu server set up that I can clone, mostly for the purposes of building nodes for a small K8S cluster.
    I have Parallels Desktop for macOS Version 15.1.4 (47270)

    What I did:
    1. Built the template server, complete with patches, docker, etc. I named it Node01
    2. Shut down Node01
    3. Chose "Clone to template..."
    4. From that template, chose "Deploy to virtual machine..."

    What's wrong:
    A. Any new VM, despite even having a different MAC address, comes up with the same IP address as Node01. Why?
    B. I can force it to release [sudo dhclient -r enp0s5] and renew [sudo dhclient enp0s5] but when I reboot the VM, it's back to having the IP address of Node01. Why?? :eek:
     
    JeromeT3 likes this.
  2. DanS27

    DanS27 Bit poster

    Messages:
    1
    Hi! I had the same issue, though I was working on Suse Enterprise Linux Server. The solution *seems* to work in line with other distributions of Linux:
    Code:
     
    prlctl clone <template_name> --name <new_vm_name>
    prlctl set <new_vm_name> --device-set net0 --ipadd <ip_address_predecided_by_me> # sets up VM to point to new IP address
    prlctl start <new_vm_name>
    # wait for VM to boot up
    prlctl exec <new_vm_name> rm /etc/udev/rules.d/70-persistent-net.rules # Resolves conflict between
    prlctl stop <new_vm_name>
    prlctl start <new_vm_name>
    You can verify it worked by looking at
    Code:
    cat /etc/hosts
    after the VM has booted up.

    I pieced together this solution from here and here

    Hope this helps!
     
  3. ixpict

    ixpict Bit poster

    Messages:
    2
    After some research, i found corner case. New netplan configuration don't use mac as dhcp identifier in Ubuntu great 18.xx. For fix this you need change default network configuration in template vm `/etc/netplan/00-installer-config.yaml`:

    ```
    network:
    ethernets:
    <your device>:
    dhcp4: true
    dhcp6: false
    dhcp-identifier: mac
    version: 2
    ```

    or replace hostname on start (before systemd-networkd started). And everything will be fine.
     
  4. ixpict

    ixpict Bit poster

    Messages:
    2
    Sure, its yaml:
    Code:
    network:
      ethernets:
        <interfaces>:
          dhcp4: true
          dhcp6: false
          dhcp-identifier: mac
      version: 2
    You should replace <interfaces> on you primary interface name.
     

Share This Page