[Dnsmasq-discuss] Enable dnsmasq to return addresses of multiple tftp servers in cycle

Bill C Riemers briemers at redhat.com
Mon Jun 20 14:09:52 BST 2011


I'm not sure about the actual patch, but the idea is a great one.   I have two NSLU2's and a router all configured with dnsmasq to act as tftp servers.   Normally, have just been relying on the race of which one wins the race when more than one is running at the same time, but that is almost always the router...   I like your idea much better.

Regards,

Bill


On 06/18/2011 12:52 PM, Sushil Agrawal wrote:
>
> Hi All,
>
> The attached patch enables dnsmasq(8) to return the ip addresses
> of multiple tftp servers (for pxe boot) having a single alias
> name (thru the /etc/hosts) in round robin fashion.
>
> We have a virtual environment where there are some managed hosts
> running kvm hypervisor and some > 150  virtual machines
> carved out of these hosts. All these virtual machines are thin
> clients which boot of the net using pxe. The arrangement is such
> that all of these machines boot at the same time and in order to
> balance the load on the tftp server, we planned to have multiple
> tftp servers (on these managed hosts themselves) running.
>
> dnsmasq currently returns only one address for tftp server
> which it finds in the dhcp-boot option in the dnsmasq.conf
> file. Although there is a provision for specifying the
> tftp server name there but it is not used. We made
> use of this name as an alias for multiple tftp servers
> (using /etc/hosts) and then return the resolved addresses
> one by one in cycle.
>
> The function cache_find_by_name() already takes care
> of all this and all we had to do was to just call
> it in dhcp_reply() to get one address and return
> that as tftp address.
>
> If the tftp server address is specified in the dhcp-boot
> option then that address is returned always. If address
> is not specified and name is specified then this cyclic
> stuff is done. This solution is working for us and hope it
> will be useful to others.
>
>
> Following is the patch (also attached) based on
> dnsmasq-2.57:
>
> ................................................................
>
> --- dnsmasq-2.57.origg/src/rfc2131.c    2011-02-17 21:00:15.000000000 +0530
> +++ dnsmasq-2.57/src/rfc2131.c    2011-06-18 17:48:59.000000000 +0530
> @@ -829,8 +829,23 @@
>               and set discovery_control = 8 */
>            if (boot)
>              {
> -              if (boot->next_server.s_addr)
> +              if (boot->next_server.s_addr) {
>              mess->siaddr = boot->next_server;
> +              } else if (boot->sname) {
> +
> +                /*
> +                 * If the pxe server name is given in the conf then
> +                 * cycle thru its addresses.
> +                 */
> +
> +                struct crec *crecp;
> +                time_t now = dnsmasq_time();
> +                crecp = cache_find_by_name(NULL, boot->sname, now,
> +                               F_DHCP | F_HOSTS);
> +                if (crecp) {
> +                    mess->siaddr = *(struct in_addr*)&crecp->addr;
> +                }
> +              }
>
>                if (boot->file)
>              strncpy((char *)mess->file, boot->file, sizeof(mess->file)-1);
> @@ -2222,8 +2237,23 @@
>          strncpy((char *)mess->file, boot->file, sizeof(mess->file)-1);
>      }
>
> -      if (boot->next_server.s_addr)
> +      if (boot->next_server.s_addr) {
>      mess->siaddr = boot->next_server;
> +      } else if (boot->sname) {
> +
> +        /*
> +         * If the pxe server name is given in the conf then
> +         * cycle thru its addresses.
> +         */
> +
> +        struct crec *crecp;
> +          time_t now = dnsmasq_time();
> +        crecp = cache_find_by_name(NULL, boot->sname, now,
> +                       F_DHCP | F_HOSTS);
> +        if (crecp) {
> +            mess->siaddr = *(struct in_addr*)&crecp->addr;
> +        }
> +      }
>      }
>    else
>      /* Use the values of the relevant options if no dhcp-boot given and
> ................................................................
>
> Sushil.
>
>
>
> _______________________________________________
> Dnsmasq-discuss mailing list
> Dnsmasq-discuss at lists.thekelleys.org.uk
> http://lists.thekelleys.org.uk/mailman/listinfo/dnsmasq-discuss

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.thekelleys.org.uk/pipermail/dnsmasq-discuss/attachments/20110620/0e79e551/attachment.htm 


More information about the Dnsmasq-discuss mailing list