<html>
  <head>

    <meta http-equiv="content-type" content="text/html; charset=utf-8">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <div class="moz-text-html" lang="x-unicode"> Hi,<br>
        here is a small patch that allows dnsmasq to assign IP addresses
      from subnet, that is not configured on listening interface.<br>
      <br>
      Use case: <br>
        - I've a server(s) with multiple virtual machines, with network
      settings configured via DHCP.<br>
        - Each VM has statically assigned private IPs from subnet range
      on the bridge, but some of them might have also public addresses
      from subnet range that is <b>only routed</b> on that bridge.<br>
        - With this patch I'm able to let dnsmasq assign this public
      addresses by defining a <b>virtual subnet</b>. This is not
      otherwise allowed, because dnsmasq is doing 'same net' checking on
      the incoming interface subnet and to-be-assigned IP address.<br>
      <br>
      Usage is simple:<br>
      <br>
      <tt>dhcp-range=wan,XXX.XXX.XXX.1,<b>virtual</b>,255.255.255.240,12h</tt><br>
      <br>
      It's a quick hack, but it works for me perfectly.<br>
      <br>
      Kind regards<br>
        Sam<br>
      <br>
      <br>
    </div>
    <br>
    <fieldset class="mimeAttachmentHeader"><legend
        class="mimeAttachmentHeaderName">virtual-dhcp-range.diff</legend></fieldset>
    <br>
    <div class="moz-text-plain" wrap="true" style="font-family:
      -moz-fixed; font-size: 14px;" lang="x-unicode">
      <pre wrap="">diff --git a/src/dhcp.c b/src/dhcp.c
index fb2f650..b9a73d0 100644
--- a/src/dhcp.c
+++ b/src/dhcp.c
@@ -526,8 +526,9 @@ static int complete_context(struct in_addr local, int if_index, char *label,
       }
       
       if (context->netmask.s_addr != 0 &&
-         is_same_net(local, context->start, context->netmask) &&
-         is_same_net(local, context->end, context->netmask))
+         ((is_same_net(local, context->start, context->netmask) &&
+         is_same_net(local, context->end, context->netmask)) ||
+         context->flags & CONTEXT_VIRTUAL))
        {
          /* link it onto the current chain if we've not seen it before */
          if (if_index == param->ind && context->current == context)
diff --git a/src/dnsmasq.h b/src/dnsmasq.h
index 4b55bb5..95eee82 100644
--- a/src/dnsmasq.h
+++ b/src/dnsmasq.h
@@ -872,6 +872,7 @@ struct dhcp_context {
 #define CONTEXT_OLD            (1u<<16)
 #define CONTEXT_V6             (1u<<17)
 #define CONTEXT_RA_OFF_LINK    (1u<<18)
+#define CONTEXT_VIRTUAL        (1u<<19)
 
 struct ping_result {
   struct in_addr addr;
diff --git a/src/option.c b/src/option.c
index 50d26ba..af69e0e 100644
--- a/src/option.c
+++ b/src/option.c
@@ -2775,6 +2775,8 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma
              new->flags |= CONTEXT_STATIC;
            else if (strcmp(a[1], "proxy") == 0)
              new->flags |= CONTEXT_PROXY;
+           else if (strcmp(a[1], "virtual") == 0)
+             new->flags |= CONTEXT_STATIC | CONTEXT_VIRTUAL;
            else if (!inet_pton(AF_INET, a[1], &new->end))
              ret_err(_("bad dhcp-range"));
            
</pre>
    </div>
  </body>
</html>