<div dir="ltr"><br><div>Honestly, this is arguably the cleanest and most stable solution to this particular problem.</div><div><br></div><div>From my own experience with a variety of DHCP clients (Linux bare metal, Linux/Windows VMs, PXE, iPXE, and a variety of IPMI controllers), you are likely to run into a lot of variability with client behavior from the different DHCP clients. We couple our Kea service with a managed iPXE implementation, and early on, had to resort to using the iPXE variant that provided lease persistence (see <a href="https://forum.ipxe.org/showthread.php?tid=6989">https://forum.ipxe.org/showthread.php?tid=6989</a>) in order to ensure that a given lease was reused by Linux after the PXE environment had successfully bootstrapped the installer. I don't think that's in play here, but I think it's germane to a conversation about Packer playing fast and loose with lease information.</div><div><br></div><div>If you have any kind of IPAM solution in place, you can leverage it to manage the reserved MAC/IP information, and if you end up needing to build more templates later on, it eliminates a lot of ambiguity and confusion to do things in this manner. We're up to half a dozen weekly OVF builds leveraging this approach and they're reliable like clockwork.</div><div><br></div><div>cheers,</div><div>Klaus</div><div> </div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, Dec 27, 2020 at 1:56 PM Roland Berger <<a href="mailto:roland.berger@exasoft.ch">roland.berger@exasoft.ch</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
  
    
  
  <div>
    Hi Klaus<br>
    <br>
    I just did it like you say and it worked. I don't like the solution
    because it is more work but for now its ok.<br>
    In the packer vsphere-iso builder <a href="https://www.packer.io/docs/builders/vsphere-iso.html" target="_blank">https://www.packer.io/docs/builders/vsphere-iso.html</a>
    I configured the <tt>'mac_address'</tt> according to this
    information
<a href="https://docs.vmware.com/en/VMware-vSphere/7.0/com.vmware.vsphere.networking.doc/GUID-ADFECCE5-19E7-4A81-B706-171E279ACBCD.html" target="_blank">https://docs.vmware.com/en/VMware-vSphere/7.0/com.vmware.vsphere.networking.doc/GUID-ADFECCE5-19E7-4A81-B706-171E279ACBCD.html</a>
    and then configured a reservation in kea.<br>
    <br>
    If somebody has a cleaner solution please let us know.<br>
    <br>
    Best Roland<br>
    <br>
    <div>
      <div style="font-family:Verdana,sans-serif;font-size:11px;color:rgb(51,51,51);padding:0px;margin:0px"><a style="border:0px" href="http://www.exasoft.ch" target="_blank"><img style="border: 0px;" alt="www.exasoft.ch"></a>
      </div>
    </div>
    <div>On 12/27/20 9:59 PM, Klaus Steden
      wrote:<br>
    </div>
    <blockquote type="cite">
      <div dir="ltr"><br>
        <div>I've got a similar workflow set up but I use VMware's <i>dcli</i>
          module to create my instance, which also allows me to
          explicitly set the MAC address (and thus force reservations).</div>
        <div><br>
        </div>
        <div>Looking at the Packer docs (<a href="https://www.packer.io/docs/builders/vsphere-iso.html" target="_blank">https://www.packer.io/docs/builders/vsphere-iso.html</a>)
          you may be able to do this as well by defining the Network
          Adapter before starting the instance, and use a reservation in
          Kea to fix the IP.</div>
        <div><br>
        </div>
        <div>hth,</div>
        <div>Klaus</div>
      </div>
      <br>
      <div class="gmail_quote">
        <div dir="ltr" class="gmail_attr">On Sun, Dec 27, 2020 at 10:40
          AM Roland Berger <<a href="mailto:roland.berger@exasoft.ch" target="_blank">roland.berger@exasoft.ch</a>>
          wrote:<br>
        </div>
        <blockquote class="gmail_quote">
          <div> Hi John<br>
            <br>
            Thanks. Packer is a tool to automatically bring up and
            configure a virtual machine for the first time. It is like
            installing, for example an ubuntu, machine from an iso
            image: The installer runs and after completion the new
            machine makes a reboot and you can continue to configure the
            new machine. So, I do not know the MAC address in advance to
            make a reservation. <br>
            <br>
            The challenge I think I face is to make sure that the IP
            address after the reboot is the same like during first power
            up when the os installer is running.<br>
            I think I have to create a configuration where kea issues
            the same IP for the above scenario. I tried this to make
            sure that the MAC address and the hostname are the same. I
            also configured networking of the new machine to send
            'dhcp-identifier: mac'. But that is obviously not enough. <br>
            <br>
            Thanks to your answer I see the following things I can try.
            But may be you have even a better, simpler idea.<br>
            - Create a MAC address by hand and make a reservation<br>
            - Try to play around with the lease time for the first DHCP
            request.<br>
            - Use static IP but in this case I don't want to do that if
            I can avoid it.<br>
            - Configure kea to use only "host-reservation-identifiers":
            ["hw-address"] but not sure if this would help.<br>
            <br>
            Best Roland<br>
            <br>
            <pre>192.168.178.<b>251</b>,00:50:56:92:07:82,01:00:50:56:92:07:82,0   ,1609062019,1,1,1,ubuntu-server,0,
192.168.178.<b>252</b>,00:50:56:92:07:82,01:00:50:56:92:07:82,4000,1609066573,1,1,1,ubuntu-server,0,
</pre>
            <br>
            <br>
            <div>
              <div><a href="http://www.exasoft.ch" target="_blank"><img alt="www.exasoft.ch"></a> </div>
            </div>
            <div>On 12/27/20 12:06 PM, Gibbins, John (IM&T, Black
              Mountain) wrote:<br>
            </div>
            <blockquote type="cite">
              <pre>Hi Roland,

If the client does not request the same IP as it had before you probably need to assign a fixed IP to the device.

I'm assuming you have a config which includes your subnet.  Something like:
...
    "subnet4": [
      {
        "subnet": "<a href="http://192.168.178.0/24" target="_blank">192.168.178.0/24</a>",
        ...
      }
    ]
...

To ensure that you always get the same IP you need to create a reservation which maps the MAC to the desired IP.  Such as:
...
    "subnet4": [
      {
        "subnet": "<a href="http://192.168.178.0/24" target="_blank">192.168.178.0/24</a>",
        ...
        "reservations": [
          {
            "hw-address": "00:50:56:92:07:82",
            "ip-address": "192.168.178.251"
          }
        ]
      }
    ]
...

You may want to check out the "reservation-mode" attribute if you have both pools and reservations on the same subnet.

Regards
johng
-----Original Message-----
From: Kea-users <a href="mailto:kea-users-bounces@lists.isc.org" target="_blank"><kea-users-bounces@lists.isc.org></a> On Behalf Of rondal
Sent: Sunday, 27 December 2020 9:23 PM
To: <a href="mailto:kea-users@lists.isc.org" target="_blank">kea-users@lists.isc.org</a>
Subject: [Kea-users] Lease same IP for same MAC

Hi, I try to deploy an ubuntu server to vsphere with packer. After
installation has finished the machine reboots an gets an other IP address.
Packer can not complete its work because it is still trying to connect to
the old ip address.

>From the kea log I see the following:

192.168.178.*251*,00:50:56:92:07:82,01:00:50:56:92:07:82,0  
,1609062019,1,1,1,ubuntu-server,0,
192.168.178.*252*,00:50:56:92:07:82,01:00:50:56:92:07:82,4000,1609066573,1,1,1,ubuntu-server,0,

In the client I configure networking (netplan) with dhcp-identifier: mac

- Any ideas how I can tell kea to lease the same ip, in this case *.251,
again?


Best Roland



--
Sent from: <a href="http://kea-users.7364.n8.nabble.com/" target="_blank">http://kea-users.7364.n8.nabble.com/</a>
_______________________________________________
ISC funds the development of this software with paid support subscriptions. Contact us at <a href="https://www.isc.org/contact/" target="_blank">https://www.isc.org/contact/</a> for more information.

To unsubscribe visit <a href="https://lists.isc.org/mailman/listinfo/kea-users" target="_blank">https://lists.isc.org/mailman/listinfo/kea-users</a>.

Kea-users mailing list
<a href="mailto:Kea-users@lists.isc.org" target="_blank">Kea-users@lists.isc.org</a>
<a href="https://lists.isc.org/mailman/listinfo/kea-users" target="_blank">https://lists.isc.org/mailman/listinfo/kea-users</a>
</pre>
            </blockquote>
            <br>
          </div>
          _______________________________________________<br>
          ISC funds the development of this software with paid support
          subscriptions. Contact us at <a href="https://www.isc.org/contact/" rel="noreferrer" target="_blank">https://www.isc.org/contact/</a>
          for more information.<br>
          <br>
          To unsubscribe visit <a href="https://lists.isc.org/mailman/listinfo/kea-users" rel="noreferrer" target="_blank">https://lists.isc.org/mailman/listinfo/kea-users</a>.<br>
          <br>
          Kea-users mailing list<br>
          <a href="mailto:Kea-users@lists.isc.org" target="_blank">Kea-users@lists.isc.org</a><br>
          <a href="https://lists.isc.org/mailman/listinfo/kea-users" rel="noreferrer" target="_blank">https://lists.isc.org/mailman/listinfo/kea-users</a><br>
        </blockquote>
      </div>
    </blockquote>
    <br>
  </div>

</blockquote></div>