首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >dhclient不设置默认网关

dhclient不设置默认网关
EN

Server Fault用户
提问于 2016-06-02 17:36:17
回答 1查看 9.6K关注 0票数 5

我在Azure云中运行了几个Ubuntu16.04虚拟机。每当我重新启动VM时,我都必须手动设置默认网关。

网关应由dhclient设置。我启动了调试,得到了以下内容:

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

代码语言:javascript
复制
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'

因此,路由器选项被正确设置。甚至租约文件也显示正确的值:

代码语言:javascript
复制
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;
}

这就是我的/etc/dhcp/dhclient.conf的样子:

代码语言:javascript
复制
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";

为什么dhclient不设置我的默认路由?

EN

回答 1

Server Fault用户

回答已采纳

发布于 2016-06-03 08:38:43

我发现了问题。由于Azure设置了rfc3442-classless-static-routes选项,路由器选项被dhclient-脚本忽略。

rfc3442由/etc/dhcp/dhclient-exit-hooks.d/rfc3442-classless-routes中的退出钩子脚本处理

我的问题是,我有另一个自定义退出钩子,它在结束时执行了一个exit 0,因此结束了dhclient-脚本的执行,作为回报,它永远无法执行had 3442-无类路由退出钩子。

这件事埋得很深,花了我将近一天的时间。因此,我希望这将使将来不会有人有同样的问题。

票数 9
EN
页面原文内容由Server Fault提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://serverfault.com/questions/780604

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档