On 03/27/2012 12:53 AM, Floris Bos / Maxnet wrote:
Is there any way to determinate the IP-address of the proxy DHCP/TFTP server that was used when booting iPXE in an ipxe script?


Tried (with undionly.kkpxe):

==
set use-cached 1
dhcp
show next-server
==

But it shows me the IP of the regular DHCP server, not the TFTP/proxy dhcp server (running dnsmasq) which I'm looking for.

Some more information:

Syslinux's Pxelinux does display the correct IP address.


I suspect iPXE's behavior of providing the wrong cached next-server address when a proxy DHCP server is used in addition to a regular DHCP server, is caused by it only fetching the cached DHCP ack packet in src/arch/i386/interface/pxeparent/pxeparent_dhcp.c:

===
    /* Obtain cached DHCP packet */
    memset ( &get_cached_info, 0, sizeof ( get_cached_info ) );
    get_cached_info.PacketType = PXENV_PACKET_TYPE_DHCP_ACK;

    if ( ( rc = pxeparent_call ( undi->entry, PXENV_GET_CACHED_INFO,
&get_cached_info,
                     sizeof ( get_cached_info ) ) ) != 0 ) {
        DBG ( "PXEDHCP GET_CACHED_INFO failed: %s\n", strerror ( rc ) );
        return;
    }
===

While Pxelinux not only fetches and parses the cached PXENV_PACKET_TYPE_DHCP_ACK (2) but also PXENV_PACKET_TYPE_CACHED_REPLY (3)

===
    /*
     * Get the BOOTP/DHCP packet that brought us file (and an IP
     * address). This lives in the DHCPACK packet (query info 2)
     */
    pkt_len = pxe_get_cached_info(2);
    parse_dhcp(pkt_len);
    /*
     * Save away MAC address (assume this is in query info 2. If this
     * turns out to be problematic it might be better getting it from
     * the query info 1 packet
     */
    MAC_len = bp->hardlen > 16 ? 0 : bp->hardlen;
    MAC_type = bp->hardware;
    memcpy(MAC, bp->macaddr, MAC_len);

    /*
     * Get the boot file and other info. This lives in the CACHED_REPLY
     * packet (query info 3)
     */
    pkt_len = pxe_get_cached_info(3);
    parse_dhcp(pkt_len);
    printf("\n");
===


Yours sincerely,

Floris Bos
_______________________________________________
ipxe-devel mailing list
ipxe-devel@lists.ipxe.org
https://lists.ipxe.org/mailman/listinfo/ipxe-devel

Reply via email to