<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFCC" text="#000000">
    Just a thought:<br>
    <br>
    Did you consider to let the DHCP server send the correct gateway?
    Would that solve the issue?<br>
    <br>
    <div class="moz-cite-prefix">On 08/04/14 15.03, alessandro macuz
      wrote:<br>
    </div>
    <blockquote
cite="mid:CAFrGbuX67PHoss0Td5g27FuN3-TULrK8diOFk+opKM9r_AsZ-Q@mail.gmail.com"
      type="cite">
      <div dir="ltr">
        <div class="gmail_extra">
          <div class="gmail_quote">2014-04-07 22:46 GMT+02:00 Sten
            Carlsen <span dir="ltr"><<a moz-do-not-send="true"
                href="mailto:stenc@s-carlsen.dk" target="_blank">stenc@s-carlsen.dk</a>></span>:<br>
            <blockquote class="gmail_quote" style="margin:0px 0px 0px
0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
              <div bgcolor="#FFFFCC" text="#000000">
                <div class=""> <br>
                  <div>On 07/04/14 22.23, alessandro macuz wrote:<br>
                  </div>
                  <blockquote type="cite">
                    <div dir="ltr">2014-04-07 21:15 GMT+02:00 Simon
                      Hobson <span dir="ltr"><<a
                          moz-do-not-send="true"
                          href="mailto:dhcp1@thehobsons.co.uk"
                          target="_blank">dhcp1@thehobsons.co.uk</a>></span>:<br>
                      <div class="gmail_extra">
                        <div class="gmail_quote">
                          <blockquote class="gmail_quote"
                            style="margin:0px 0px 0px
0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
                            <div>alessandro macuz <<a
                                moz-do-not-send="true"
                                href="mailto:alessandro.macuz@gmail.com"
                                target="_blank">alessandro.macuz@gmail.com</a>>

                              wrote:<br>
                              <br>
                              > I could deduce the gateway from the
                              DHCP server IP address because normally
                              they coincide but that would be my
                              assumption.<br>
                              <br>
                            </div>
                            You've heard the expression that "assume"
                            makes an "ass" out of "u" and "me", well
                            your assumption is badly wrong. In home and
                            small networks it is likely to be true (not
                            mine though). But once you get to business
                            networks then its more likely that the DHCP
                            server is not at the same IP address as the
                            router.<br>
                          </blockquote>
                          <blockquote class="gmail_quote"
                            style="margin:0px 0px 0px
0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
                            However, I'm still not quite sure why you
                            are doing things the long way round. What's
                            specifically wrong with using the route that
                            comes with the lease ? Or more to the point,
                            what's wrong with dealing with it when you
                            get it ? And BTW - have you considered the
                            possibility of getting different answers to
                            your two queries ?<br>
                          </blockquote>
                          <div><br>
                          </div>
                          <div>Sorry maybe I should have added more
                            details but there is only one defaut gateway
                            on the network of that interface and hence
                            the dry-run returns always the same IP
                            address. As to the second reply it will
                            configure the interface.<br>
                            <br>
                          </div>
                          <div>Why I want to run a dry-run? Because
                            eventually I need to install some routes
                            pointing to the only gateway on the network.
                            On the system there is another interface
                            that gets the IP dinamically and two default
                            routes are not OK <br>
                          </div>
                        </div>
                      </div>
                    </div>
                  </blockquote>
                </div>
                I suggest you look at: /sbin/dhclient-scripts<br>
                <br>
                It contains the following code, I think a small
                modification to this will do your job:<br>
                ~~~~~~~~~~~~~~~~~~~~~<br>
                add_default_gateway() {<br>
                    router="${1}"<br>
                <br>
                    if is_router_reachable ${router} ; then<br>
                        metric=""<br>
                        if [ $# -gt 1 ] && [ ${2} -gt 0 ]; then<br>
                            metric="metric ${2}"<br>
                        fi<br>
                        ip -4 route replace default via ${router} dev
                ${interface} ${metric}<br>
                        if [ $? -ne 0 ]; then<br>
                            logmessage "failed to create default route:
                ${router} dev ${interface} ${metric}"<br>
                            return 1<br>
                        else<br>
                            return 0<br>
                        fi<br>
                    fi<br>
                <br>
                    return 1<br>
                }<br>
              </div>
            </blockquote>
            <div><br>
            </div>
            <div><br>
            </div>
            <div>Thanks Sten,</div>
            <div><br>
            </div>
            <div>I don't see such <font face="arial, sans-serif">add_default_gateway()
                function in my Ubuntu 12.04.4 but I do see</font><br>
              <br>
              <div><font face="arial, sans-serif">            for router
                  in $new_routers; do</font></div>
              <div><font face="arial, sans-serif">                if [
                  "$new_subnet_mask" = "255.255.255.255" ]; then</font></div>
              <div><font face="arial, sans-serif">                    #
                  point-to-point connection => set explicit route</font></div>
              <div><font face="arial, sans-serif">                    ip
                  -4 route add ${router} dev $interface >/dev/null
                  2>&1</font></div>
              <div><font face="arial, sans-serif">                fi</font></div>
              <div><font face="arial, sans-serif"><br>
                </font></div>
              <div><font face="arial, sans-serif">                # set
                  default route</font></div>
              <div><font face="arial, sans-serif">                ip -4
                  route add default via ${router} dev ${interface} \</font></div>
              <div><font face="arial, sans-serif">                   
                  ${metric_arg} >/dev/null 2>&1</font></div>
              <div><font face="arial, sans-serif">            done</font></div>
              <div style="font-family:arial,sans-serif;font-size:13px">
                <br>
              </div>
            </div>
            <div><span
                style="font-family:arial,sans-serif;font-size:13px">when
                $reason is set to </span><font face="arial, sans-serif">BOUND
                or RENEW or REBIND or REBOOT or TIMEOUT.</font></div>
            <div><font face="arial, sans-serif"><br>
              </font></div>
            <div><font face="arial, sans-serif">Eventually I realized I
                have access to the DHCP server (openwrt) and the trick
                may be not to send the default route and at the same
                time to use the option 121 (client must explicitly
                request it)</font></div>
            <div><font face="arial, sans-serif"><br>
              </font></div>
            <div><font face="arial, sans-serif"><a
                  moz-do-not-send="true"
href="http://lists.thekelleys.org.uk/pipermail/dnsmasq-discuss/2006q2/000818.html">http://lists.thekelleys.org.uk/pipermail/dnsmasq-discuss/2006q2/000818.html</a><br>
                <br>
                I'll give it a try.</font></div>
            <div><font face="arial, sans-serif"><br>
              </font></div>
            <div>Alex<br>
            </div>
          </div>
        </div>
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
dhcp-users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:dhcp-users@lists.isc.org">dhcp-users@lists.isc.org</a>
<a class="moz-txt-link-freetext" href="https://lists.isc.org/mailman/listinfo/dhcp-users">https://lists.isc.org/mailman/listinfo/dhcp-users</a></pre>
    </blockquote>
    <br>
    <pre class="moz-signature" cols="72">-- 
Best regards

Sten Carlsen

No improvements come from shouting:

       "MALE BOVINE MANURE!!!" 
</pre>
  </body>
</html>