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