Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

There are two WAN interfaces to different ISP, which are configured with PEERDNS=yes and installed BIND 9 server which is configured with forward only.

These interfaces are used in rotation (not same time).

What is the preferred method in CentOS 6.3 allows to change the BIND forwarders to active ISP nameservers when changing active WAN interface?

share|improve this question

2 Answers 2

up vote 2 down vote accepted

It sounds like you have a fairly simple use case. Assuming that you are only operating as a forwarder (i.e. you do not have a large set of zone data or complicated configuration to reload) you might as well just have something which just changes the configuration file and then causes named to reload it using "rndc reconfig"

What I might do to make this a little cleaner would be to use the "include" directive in your named.conf, e.g.

# {stuff that you do all the time}
blah
blah
blah

# ISP specific forwarding section
include "ISP-forwarder-config.conf";

# {other stuff}

and then have "ISP-forwarder-config.conf" be a symlink that you can switch between target files for "ISP-1.conf" and "ISP-2.conf". (choose your own names, but the idea is that if you are only switching the symlink and not messing with your master named.conf file all the time there's much less chance of suffering some mishap that messes up your config.

To change forwarders, then, all you would need to do is change the target of the symlink and do an "rndc reconfig"

share|improve this answer
    
Exactly, a symbolic link to preformatted configs is a solution, because isn't possible to include /var/run/ppp/resolv.conf directly inside forwardes { } section of named.conf. Thank you, you gave me the idea (I place it as a response). –  Yuriy Oct 2 '12 at 7:08

set PEERDNS=no for my interfaces to ISPs in /etc/sysconfig/network-scripts/ifup-ppp0 and /etc/sysconfig/network-scripts/ifup-ppp1

create executable script /usr/sbin/ifup-local with:

#!/bin/sh
if [[ "ppp0 ppp1" =~ $1 ]] ; then
  conf='/etc/named/forwarders.conf'
  fetc=$(cat $conf)
  frun=$(echo 'forwarders {';sed 's/nameserver //g;s/$/;/g' /var/run/ppp/resolv.conf;echo '};';)
  echo $frun > $conf
  named-checkconf > /dev/null 2>&1 || echo $fetc > $conf
  rndc reconfig
fi

edit option { } section in /etc/named.conf with:

include "/etc/named/forwarders.conf";
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.