问题原文
原帖链接 · 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
ifmetricsuggestion 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 (
eth0must be quoted, and it should berequest, notrequired) - Specified the dlclient version this works for
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
