Set UbuntuDNS cache 1. Install dnsmasq: # Install the dnsmasq package [linuxidc @ linuxidc-ubuntu ~] $ Sudoapt-getinstall "dnsmasq" 2. Set dnsmasq to take over the local DNS resolution request: # modify the dnsmasq configuration file [linuxidc @ linuxidc-ubuntu ~] $ Sudogedit/etc/d
Set Ubuntu DNS Cache
1. Install dnsmasq:
# Install the dnsmasq Software Package
[Linuxidc @ linuxidc-ubuntu ~] $ Sudo apt-get install "dnsmasq"
2. Set dnsmasq to take over the local DNS resolution request:
# Modify the configuration file of dnsmasq
[Linuxidc @ linuxidc-ubuntu ~] $ Sudo gedit/etc/dhcp3/dhclient. conf
# Find the following content and modify it
Prepend domain-name-servers 127.0.0.1; # Remove the comment above this line
Request subnet-mask, broadcast-address, time-offset, routers,
Domain-name, domain-name-servers, host-name,
Netbios-name-servers, netbios-scope;
3. Modify the dhclient Configuration:
# Modify the configuration file of dnsmasq
[Linuxidc @ linuxidc-ubuntu ~] $ Sudo gedit/etc/dhcp3/dhclient. conf
# Find the following content and modify it
Prepend domain-name-servers 127.0.0.1; # Remove the comment above this line
Request subnet-mask, broadcast-address, time-offset, routers,
Domain-name, domain-name-servers, host-name,
Netbios-name-servers, netbios-scope;
4. Modify the resolv. conf configuration:
[Linuxidc @ linuxidc-ubuntu ~] $ Sudo gedit/etc/resolv. conf
# Note: The content of my resolv. conf file will not be rewritten because of ADSL dialing.
# Because dnsmasq takes over the DNS resolution request of the local machine, the address of 127.0.0.1 is placed at the beginning.
Nameserver 127.0.0.1
Nameserver xxx. xxx
Nameserver xxx. xxx
Search lan
5. Restart the dnsmasq service:
[Linuxidc @ linuxidc-ubuntu ~] $ Sudo/etc/init. d/dnsmasq restart
6. Modify dsl-provider
Sudo gedit/etc/ppp/peers/dsl-provider
Add # Before usepeerdns, that is, overwrite this statement.
In case, the resolv. conf setting is overwritten by pppoe.
7. Take a look at the time required for DNS resolution, and compare the data between the two before and after DNS resolution:
[Linuxidc @ linuxidc-ubuntu ~] $ Dig baidu.com # first execution
... Omitted output information...
; Query time: 8 msec
; SERVER: 127.0.0.1 #53 (127.0.0.1)
; WHEN: Mon Feb 19 20:43:32 2007
; Msg size rcvd: 229
[Linuxidc @ linuxidc-ubuntu ~] $ Dig baidu.com # Run again
... Omitted output information...
; Query time: 0 msec
; SERVER: 127.0.0.1 #53 (127.0.0.1)
; WHEN: Mon Feb 19 20:45:27 2007
; Msg size rcvd: 59