Assigning a different gateway address based on gi-addr

Nicolas De Cristofaro at
Sat Oct 30 01:57:07 UTC 2010

Hi David,

I'll have to test that as well actually, I didn't check for the RENEW condition. The other option I see is we pass the router's hostname in option 82, so I guess we could match on substring from the agent as well?


-----Original Message-----
From: at [ at] On Behalf Of David W. Hankins
Sent: October-29-10 5:22 PM
To: Users of ISC DHCP
Subject: Re: Assigning a different gateway address based on gi-addr

On Fri, Oct 29, 2010 at 08:56:01PM +0100, Simon Hobson wrote:
> How about just using a conditional like this :
>      if packet(24, 4) = {
>        option routers ;
>      }
>      else
>      {
>        option routers ;
>      }

Some mild syntax problems, but there's a deeper issue;

The 'giaddr' will be zero when the client renews.  The most straightforward workaround is to store the 'giaddr' in a 'binding scope' on the dynamic lease when it is nonzero;

  if (packet(24, 4) != 00:00:00:00) {
    set last_giaddr = packet(24, 4);

  subnet netmask {
    # Default to for clients that haven't gone through the
    # relay yet.
    option routers = pick-first-value(last_giaddr, 0a:00:00:01);


This way the 'last_giaddr' value will be cached on the active dynamic lease and reused when the client returns.

David W. Hankins	"If you don't do it right the first time,
Software Engineer		     you'll just have to do it again."
Internet Systems Consortium, Inc.		-- Jack T. Hankins

More information about the dhcp-users mailing list