5

I'm running a few Ubuntu 16.04 VMs in the Azure cloud. Whenever I reboot a VM I have to set the default gateway manually.

The gateway should be set by dhclient. I activated the debugging and get this:

root@backend01:/etc/dhcp/dhclient-exit-hooks.d# cat /tmp/dhclient-script.debug

root@backend01:/etc/dhcp/dhclient-exit-hooks.d# cat /tmp/dhclient-script.debug
Thu Jun  2 17:18:33 UTC 2016: entering /etc/dhcp/dhclient-enter-hooks.d, dumping variables.
reason='PREINIT'
interface='eth0'
--------------------------
Thu Jun  2 17:18:33 UTC 2016: entering /etc/dhcp/dhclient-enter-hooks.d, dumping variables.
reason='REBOOT'
interface='eth0'
new_ip_address='10.10.0.13'
new_network_number='10.10.0.0'
new_subnet_mask='255.255.0.0'
new_broadcast_address='10.10.255.255'
new_routers='10.10.0.1'
new_rfc3442_classless_static_routes='0 10 10 0 1 32 168 63 129 16 10 10 0 1'
new_domain_name='azure-prod'
new_domain_search='azure-prod.'
new_domain_name_servers='10.11.0.250 10.11.0.251'

So the routers option is set correctly. Even the lease file shows the correct value:

lease {
  interface "eth0";
  fixed-address 10.10.0.13;
  server-name "RD7CFE90879C98";
  option subnet-mask 255.255.0.0;
  option dhcp-lease-time 4294967295;
  option routers 10.10.0.1;
  option dhcp-message-type 5;
  option dhcp-server-identifier 168.63.129.16;
  option domain-name-servers 10.11.0.250,10.11.0.251;
  option domain-search "azure-prod.";
  option dhcp-renewal-time 4294967295;
  option rfc3442-classless-static-routes 0,10,10,0,1,32,168,63,129,16,10,10,0,1;
  option unknown-245 a8:3f:81:10;
  option dhcp-rebinding-time 4294967295;
  option domain-name "azure-prod";
  renew 0 2152/07/09 23:41:47;
  rebind 0 2152/07/09 23:41:47;
  expire 0 2152/07/09 23:41:47;
}

This is how my /etc/dhcp/dhclient.conf looks:

option rfc3442-classless-static-routes code 121 = array of unsigned integer 8;

send host-name = gethostname();
request subnet-mask, broadcast-address, time-offset, routers,
    domain-name, domain-name-servers, domain-search, host-name,
    dhcp6.name-servers, dhcp6.domain-search, dhcp6.fqdn, dhcp6.sntp-servers,
    netbios-name-servers, netbios-scope, interface-mtu,
    rfc3442-classless-static-routes, ntp-servers;


timeout 300;

supersede domain-name "azure-prod";
supersede domain-search "azure-prod";

Why doesn't dhclient set my default route?

  • Check your dhclient-enter-hooks.d for any file containing unset new_routers. – rda Jun 2 '16 at 18:46
  • Unfortunately thats not the case. I don't have any "unset" statements in my hooks (enter and exit). – Kai Jun 3 '16 at 7:37
8

I found the problem. Since the Azure DHCP sets the rfc3442-classless-static-routes option the routers option gets ignored by the dhclient-script.

The rfc3442 gets handled by an exit hook script in /etc/dhcp/dhclient-exit-hooks.d/rfc3442-classless-routes

My problem was that I had another custom exit-hook, which did an exit 0 at the end and therefore ended the execution of dhclient-script which in return never got to execute the rfc3442-classless-routes exit-hook.

This was deeply buried and cost my almost a day of work. So I hope that this will keep someone from having the same problem in the future.

  • 2
    Wanted to add something to your findings. I had the same problem, and it seems the "issue" is with the from RFC3442 If the DHCP server returns both a Classless Static Routes option and a Router option, the DHCP client MUST ignore the Router option. Similarly, if the DHCP server returns both a Classless Static Routes option and a Static Routes option, the DHCP client MUST ignore the Static Routes option. mail-archive.com/debian-bugs-dist@lists.debian.org/… – tore- Sep 25 '16 at 20:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.