Bug 11347 - ifup and ifdown should update /etc/resolv.conf
ifup and ifdown should update /etc/resolv.conf
Status: CLOSED WORKSFORME
Product: Red Hat Linux
Classification: Retired
Component: initscripts (Show other bugs)
6.2
i386 Linux
medium Severity medium
: ---
: ---
Assigned To: Bill Nottingham
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2000-05-10 12:58 EDT by dh_redhat
Modified: 2014-03-16 22:13 EDT (History)
1 user (show)

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


Attachments (Terms of Use)

  None (edit)
Description dh_redhat 2000-05-10 12:58:08 EDT
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.

Thanks.
Comment 1 Nalin Dahyabhai 2000-05-11 17:11:59 EDT
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 01:38:59 EDT
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 14:05:59 EDT
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 18:33:59 EDT
Thanks, that should do it.

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