Domain Name System (DNS)
Contents
Client
For Linux, domain name lookup is handled by glibc. NSCD (Name Server Cache Daemon) is part of glibc to add caching service.
Client settings
Domain name servers are set in /etc/resolve.conf:
search example.com nameserver 1.2.3.4
The order of looking up a domain name is defined in /etc/nsswitch.conf:
hosts: files dns
Accelerating
To accelerate DNS look up speed under linux, you can use NSCD or setup a local cache only DNS server (like dnsmasq).
Windows has builtin DNS cache service called "DNS Client".
Windows DNS Client service
To display the DNS resolver cache:
C:\>ipconfig /displaydns
To flush the cache:
C:\>ipconfig /flushdns
To turn off the DNS cache service, you can use either of these two commands:
C:\>net stop dnscache C:\>sc <servername> stop dnscache
This will disable DNS caching until the next reboot. To make the change permanent, use the Service Controller tool or the Services tool to set the DNS Client service startup type to Disabled.
You can tune the DNS cache service parameters by setting two registry entries under the HKEY_LOCAL_MACHINESYSTEMCurrentControlSetServicesDnscacheParameters registry key.
- MaxCacheTtl: represents the maximum time that the results of a DNS lookup will be cached. The default value is 86,400 seconds. If you set this value to 1, DNS entries will only be cashed for a single second.
- MaxNegativeCacheTtl: represents the maximim time that the results of a failed DNS lookup will be cached. The default value is 900 seconds. If you set this value to 0, failed DNS lookups will not be cached.
NSCD (Name Server Cache Daemon)
/etc/nscd.conf:
# logfile /var/log/nscd.log # threads 6 # max-threads 128 server-user nscd # stat-user nocpulse debug-level 0 # reload-count 5 paranoia no # restart-interval 3600 enable-cache passwd yes positive-time-to-live passwd 600 negative-time-to-live passwd 20 suggested-size passwd 211 check-files passwd yes persistent passwd yes shared passwd yes max-db-size passwd 33554432 auto-propagate passwd yes enable-cache group yes positive-time-to-live group 3600 negative-time-to-live group 60 suggested-size group 211 check-files group yes persistent group yes shared group yes max-db-size group 33554432 auto-propagate group yes enable-cache hosts yes positive-time-to-live hosts 3600 negative-time-to-live hosts 20 suggested-size hosts 211 check-files hosts yes persistent hosts yes shared hosts yes max-db-size hosts 33554432Start:
# /etc/init.d/nscd start
Stop:
# /etc/init.d/nscd stop
Flush the cache:
# /etc/init.d/nscd restart
Restart without flush the cache:
# /etc/init.d/nscd reload
Dnsmasq
Install dnsmasq if your distribution doesn't have it.
Change /etc/dnsmasq.conf:
listen-address=127.0.0.1
Start:
# /etc/init.d/dnsmasq start
Stop:
# /etc/init.d/dnsmasq stop
Flush the cache:
# /etc/init.d/dnsmasq restart
Restart without flush the cache:
# /etc/init.d/dnsmasq reload
Change /etc/resolv.conf:
search example.com nameserver 127.0.0.1 nameserver 1.2.3.4
Reference
- Domain Name System (DNS): http://en.wikipedia.org/wiki/Domain_Name_System
- Dynamic DNS: http://en.wikipedia.org/wiki/Dynamic_DNS
- dnsmasq: http://www.thekelleys.org.uk/dnsmasq/
- Bind: http://www.isc.org/software/bind
