Build a DNS Cache Server using Dnsmasq locally

Source: Internet
Author: User
Tags nameserver

I have already studied bind's cache dns server. Today I have studied dnsmasq's dns Cache and found that the configuration of dnsmasq is much simpler. It is better for new users to get started with complex configurations than those of bind, after all, it is difficult to maintain the service after it is used locally. Check the operation.
 
System: CentOS 5.4
Ip: 192.168.1.166
Required Software: dnsmasq
 
1. Install dnsmasq (centos can be directly installed using yum, or directly find it on the disc)
Yum-y install Dnsmasq

2. Configuration
Cp/etc/dnsmasq. conf/etc/dnsmasq. conf. bak
Vi/etc/dnsmasq. conf

Content in dnsmasq. conf:
# Find
# Resolv-file =
# Change
Resolv-file =/etc/resolv. dnsmasq. conf
Save and exit
Cp/etc/resolv. conf/etc/resolv. dnsmasq. conf
Vi/etc/resolv. conf
Keep only one record:
Nameserver 127.0.0.1
Modify resolv. dnsmasq. conf.
Vi/etc/resolv. dnsmasq. conf
Add
Nameserver 8.8.8.8
Of course, you can also add an opendns address.

3. Start
Chkconfig dnsmasq on; service dnsmasq start

4. Modify iptables configuration
Iptables-t nat-a prerouting-I eth0-p upd -- dport 53-j REDIRECT -- to-port 53
The above sentence is to forward the domain name resolution of the eth0 interface, and then enable port 53, otherwise domain name resolution will not be sent out.
Iptables-A RH-Firewall-1-INPUT-p udp-m udp -- dport 53-j ACCEPT
Iptables-A RH-Firewall-1-INPUT-p tcp-m tcp -- dport 53-j ACCEPT
Service iptables save; service iptables restart

5. Verify
You can find a Windows computer, add 192.168.1.166 to the dns server address, and delete other dns servers to avoid inaccurate resolution.

Ps: Finally, you can try setting up dnsmasq with a dual network card. One of the ip addresses is the Intranet and the other is the Internet.

For details about DNSmasq, click here
DNSmasq: click here

DNSmasq and Named in Ubuntu 10.10 may conflict.

Use DNSmasq in Ubuntu 8.10 To provide DNS and DHCP services

Use DNSmasq to build a small Intranet DNS

Install and configure Cobbler + DNSmasq + tftpd-hpa in Ubuntu Server 12.04

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.