Bug 11347 - ifup and ifdown should update /etc/resolv.conf
Summary: ifup and ifdown should update /etc/resolv.conf
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: initscripts   
(Show other bugs)
Version: 6.2
Hardware: i386
OS: Linux
Target Milestone: ---
Assignee: Bill Nottingham
QA Contact:
Depends On:
TreeView+ depends on / blocked
Reported: 2000-05-10 16:58 UTC by dh_redhat
Modified: 2014-03-17 02:13 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2000-05-22 22:35:09 UTC
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

Description dh_redhat 2000-05-10 16:58:08 UTC
Feature request: it'd bw nice to be possible to define a set of DNS
servers per interface, e.g. eth0 should know about its
own /etc/resolv.conf, ppp0 should have its own set of /etc/resolv.conf
associated to it, ppp1, etc.

This is useful when switching between connections a lot,
the /etc/resolv.conf file should get updated (it does get updated now when
switching eth -> ppp connection, but when coming back to eth0 it does not
get reverted back).

I would have it so that when you call 'ifdown <device>' take out just the
entries from /etc/resolv.conf for that <device>, when calling 'ifup
<device> merge into /etc/resolv.conf the entries for <device>. A simple
file replacement policy would be acceptable, too.

I had to write some wrapper scripts that replace /etc/resolv.conf, it
would be nice if I did not have to maintain them myself :-) but instead
make them part of the release.


Comment 1 Nalin Dahyabhai 2000-05-11 21:11:59 UTC
Removing entries for which there is no route would be easy, but adding them back
in would be difficult.  The kernel will already give a process an error if there
is no route to a particular IP being tried, so most of the time this is only
an issue if you're running a caching nameserver with a network connection that
is down for non-trivial amounts of time.

Is there a reason this can't be done on your system with a local script named
"/sbin/ifup-local"?  (The ifup commands will run that script if it exists.)

Comment 2 dh_redhat 2000-05-14 05:38:59 UTC
I'm not sure I understand how ifup-local would work, would that get called from
ifup if the script exists? This feature needs to be added in a future release,
it is not there yet, right? What would the ifup-local script do in that case?
Just replace /etc/resolv.conf with the appropriate one?

Comment 3 Nalin Dahyabhai 2000-05-22 18:05:59 UTC
The logic to call /sbin/ifup-local has been in the initscripts package for some
time now.  It is called from ifup-post (in /etc/sysconfig/network-scripts) with
the network device name ("ppp0") as its sole argument.  Similary, a script named
/sbin/ifdown-post would be called when an interface is taken down.

I think something like "cat /etc/resolv.conf.$1 >> /etc/resolv.conf" would do
what you're looking for in an ifup-local, and a corresponding
"fgrep -vf resolv.conf.eth0 /etc/resolv.conf > /etc/resolv.conf.$$ && \
mv /etc/resolv.conf.$$ /etc/resolv.conf" in ifdown-local would undo it.

Comment 4 dh_redhat 2000-05-22 22:33:59 UTC
Thanks, that should do it.

Note You need to log in before you can comment on or make changes to this bug.