大网数据广告活动
服务器运维问答

Multiple DHCP uplinks - How to ignore DNS and default route on all but one?

· 52CE 我爱测

A multi-homed box needs more than one uplink to be configured for DHCP. It needs to ignore default-route and DNS for all but one DHCP uplink. There is a similar question here [ Debian interfaces file - ignore gateway and dns entr…

问题原文

原帖链接 · Nils Toedtmann · CC BY-SA 3.0

A multi-homed box needs more than one uplink to be configured for DHCP. It needs to ignore default-route and DNS for all but one DHCP uplink.

There is a similar question here [ Debian interfaces file - ignore gateway and dns entries from dhcp ], but the answers there do not solve my problem:

  • Editing the global DHCP client configuration (/etc/dhcp[3]/dhclient.conf) would result in default-route and DNS being ignored on all DHCP uplinks.
  • The ifmetric suggestion only deals with the route, not with DNS.

Also, i hope that things have changed since 2009.

Note that i am talking headless embedded systems. NetworkManager is not an option.

Preferred solution would be /etc/network/interfaces{.d/} only. I am looking for something like this:

auto  eth0
iface eth0 inet dhcp

auto  eth1
iface eth1 inet dhcp
    ignore-dhcp-option routers domain-name-servers domain-name

Addendum:

We have dozens of these boxes installed in various environments. The networks are not under our control. In some cases, the boxes need to do DHCP on more than one interface. Default route and DNS are usually not known to us beforehand, and even if they were they might change over time without notice. Hence we can't set them statically but must configure them via the 'main' DHCP client.

已采纳解答

原帖链接 · Nils Toedtmann · CC BY-SA 3.0

(I am still interested in solutions that only touch /etc/network/interfaces{,.d/}, but not /etc/dhcp/. In the absence of such solutions, I use this one.)

In /etc/dhcp*/dhclient.conf, remove the options routers, domain-name-servers, domain-name, domain-search from the global request statement. Then add this (assuming eth0 is the device where default route and DNS shall not get ignored):

interface "eth0" {
    also request routers, domain-name-servers, domain-name, domain-search;
}

This solution works at least for isc-dhcp-client version 4.2.2.dfsg.1-5+deb70u8 as it is shipped with Debian 7. I assume it works for later versions too.


Edit:

  • Confirmed that the original idea works with minor changes (eth0 must be quoted, and it should be request, not required)
  • Specified the dlclient version this works for

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2015-03-11)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。