Weblog entry #5 for mar
Intro
Being a long time user of pdnsd (small and simple DNS caching daemon), I have always struggled a bit when using it with dhclient.
I have always used some custom hook scripts (pre-up, post-up, ...) in /etc/network/interfaces when I was configuring a device with dhcp to supply the just generated /etc/resolv.conf to pdnsd and generate a new one with nameserver 127.0.0.1 line in it to enable local caching. It got a bit more complicated with shorewall. Anyway, it has been a somewhat working setup, even with mapping stanzas in /etc/network/interfaces.
Before going on, I should mention I just hate the resolvconf debian package, which never seems to be doing what I want. (You may give it a try yourself.)
I was reading through the dhclient man page in hope there are some hooks or something and to my surprise, I learned they are! So finally, the much improved "receipt" for happy networking with laptop with several virtual machines, local DNS zones, local DNS caching and more ... ;-).
So much for the intro. Now the thing.
Setup
- pdnsd should be able to use the info provided by dhclient, thankfully, it has a feature for this. Apart from other standard
serverstanzas, it should contain this server section. It points to file with standardresolv.confsyntax and it could be for exampleresolv.conffile generated by dhclient.
server {
label = "resolv.conf.from.dhclient";
file = "/etc/resolv.conf.from.dhclient";
}
- Debian has another nice feature --
/etc/dhcp3/dhclient-enter-hooks.d/and/etc/dhcp3/dhclient-exit-hooks.d/directories, that can contain various scripts that are run before and after the dhclient obtains its info from server (and writes down the new/etc/resolv.conf). All i have to do is to prepare 2 simple custom scripts for pdnsd. This scripts are sourced ('.') by shell during startup/rebound/stop/... actions of dhclient.
/etc/dhcp3/dhclient-enter-hooks.d/dhclient-pdnsd-enter-hook This script just uses predefined variables by /sbin/dhclient-script and modifies them to its needs -- particullary the $new_domain_name_servers var:
# place a link to this file in /etc/dhcp3/dhclient-enter-hooks.d
echo "I: prepending 127.0.0.1 as local caching DNS server"
new_domain_name_servers="127.0.0.1 $new_domain_name_servers"
echo "I: new_domain_name_servers=$new_domain_name_servers"
and
/etc/dhcp3/dhclient-exit-hooks.d/dhclient-pdnsd-exit-hook This script generates the file mentioned in the server section of pdnsd above and notifies pdnsd that the config changed and it should re-read the DNS info.
# place a link to this file in /etc/dhcp3/dhclient-exit-hooks.d
pdnsd_resolv_conf="/etc/resolve.conf.from.dhclient"
echo "I: creating $pdnsd_resolv_conf"
cat /etc/resolv.conf | fgrep --invert-match -e "127.0.0.1" > $pdnsd_resolv_conf
echo "I: notifying pdnsd"
/usr/sbin/pdnsd-ctl config
Outro
With a setup like this, which integrates nicely into debian ways I can use pdnsd, which i like, for a long time, without worrying that future DHCP REBOUND will overwrite my /etc/resolv.conf leaving out my custom changes to this file -- ie. my local cache and local zones for virtual machines defined in pdnsd.
This set up also integrates with /etc/network/interfaces in a completely transparent way -- on a laptop, when you may be connected via bluetooth, wlan, eth, ppp -- this always ensures, that once DHCP is used, local DNS set up will nicely prevail no matter what interface is in use.
I would like to hear from you, how you handle DNS on your laptop, what tools you use and why. Until then, another happy day with debian, i must do ifdown wlan0 just to see it working again :).
Comments on this Entry
Dealing with dhclient is fairly easy. Edit the following file /etc/dhcp3/dhclient.conf
above the "request" line, tack in:
prepend domain-name-servers 127.0.0.1;
Then whenever dhcp kicks in 127.0.0.1 will be above the domain-name-servers in resolv.conf that your DHCP server provides you :)
[ Parent | Reply to this comment ]
great tip, thanks, much more simple.
[ Parent | Reply to this comment ]
anyway, i do believe, that for the nameserver 127.0.0.1 should be the only one asked, and it itself should forward any DNS request -- in order to be able to cache them, so this tip just removes the script number one from my setup, correct?
[ Parent | Reply to this comment ]
[ Parent | Reply to this comment ]
Free Malayalam Hindi Karaoke Download
Rectangle Body Type
Human Heart Clay Diagram Diagram
Ppt Template Free
Mermaid Cartoon Picture
Free Writing Ideas 3rd Grade
Volcano Fun Facts
Exploited Free Preview
Free Pics Of Saturn
A Girl And A Guy Making Out Video
Template Indesign Free
Free Resume Designer
Ladybug Desktop Wallpaper
Code Key Generator Microsoft Office 2003
Free Cartoon Character Pumpkin Stencils
World Of Warcraft Desktop Theme Free
Ninja Tattoo Art
Pokemon Fire Red Money Gameshark Cheat
Christian Anniversary Poems
Halo 2 For Pc Downloadable Demos
Used Tractors For Sale In Texas
Windows Xp Professionnel Key Generator
Liquid Measurement Chart
Fox News Syracuse
How To Account Hack In Maplestory
Homemade Astronaut Costume
Windows Media Player Skins Greece
Lent Crafts Kindergarten
Cover Letter For Ceo
Historical Symbols Pictures
[ Parent | Reply to this comment ]
[ Parent | Reply to this comment ]
[ Parent | Reply to this comment ]
[ Parent | Reply to this comment ]