UbuntuLinux: Bind dual domain name configuration-Linux Enterprise Application-Linux server application information. For details, refer to the following section. I believe that there are many places where dual DNS is used, that is, the external address is resolved to the public network address, and the internal address is resolved to the Intranet address. The general practice is to use two DNS servers separately. However, if the machine is nervous and there is only one server, or only one server can be used for security reasons, it can also be done.
The specific method can be divided into the following two situations: Bind8 and Bind9 are different, the implementation method of Bind8 runs two binds on the DNS server, provide resolution for domain name requests from the internal network and external network respectively. Each BIND has different configuration files and domain name database files, and listens on different ports respectively.
When the DNS server receives a request from the client, It redirects the request to different BIND Service ports based on the customer's IP address. In this way, different resolution results can be returned to the client based on the client's IP address, the entire process is transparent to the client. The key to implementation is to run two binds and use the iptables command to rewrite IP addresses and ports. Specific configuration: generate two named configuration files under/etc/: named. in And named. out named. in
# Named. conf-configuration for bind (named. in)
#
# Generated automatically by redhat-config-bind, alchemist et al.
# Any changes not supported by redhat-config-bind shocould be put
# In/etc/named. custom
#
Include "/etc/named. custom ";
Include "/etc/rndc. key ";
Options {
Directory "/var/named_in /";
Datasize 2098;
......
};
};
# Log Files
Logging {
Category queries {
Default_syslog;
};
};
# DataBase Files
Zone "0.0.127.in-addr. arpa "{
Type master;
File "0.0.127.in-addr. arpa. zone ";
};
Zone "10. in-addr.arpa "{
Type master;
File "10. in-addr.arpa.zone ";
};
Zone "localhost "{
Type master;
File "localhost. zone ";
};
Zone "xxu.edu.cn "{
Type master;
File "xxu.edu.cn. zone ";
};
Named. out
# Named. conf-configuration for bind (named. out)
#
# Generated automatically by redhat-config-bind, alchemist et al.
# Any changes not supported by redhat-config-bind shocould be put
# In/etc/named. custom
#
Include "/etc/named. custom ";
Include "/etc/rndc. key ";
Options {
Directory "/var/named_out /";
Datasize 2098;
......
};
# Note that the listening ports here are different
Listen-on port 8053 {
# Local IP Address
10. xx;
};
};
# Log Files
Logging {
Category queries {
Default_syslog;
};
};
# DataBase Files
Zone "0.0.127.in-addr. arpa "{
Type master;
File "0.0.127.in-addr. arpa. zone ";
};
Zone "xx. xx.210.in-addr. arpa "{
Type master;
File "xx. xx.210.in-addr. arpa. zone ";
};
Zone "localhost "{
Type master;
File "localhost. zone ";
};
Zone "xxu.edu.cn "{
Type master;
File "xxu.edu.cn. zone ";
};
Why choose external release for redirection? At that time, the consideration was that the internal resolution traffic was high, which could reduce one link.
Then, perform iptables redirection and add it to the iptable configuration file.
-A postrouting-o eth0-p udp-m udp -- sport 8053-j SNAT -- to-source 10. xx: 53
COMMIT
Finally, make a STARTUP script:
#! /Bin/sh
Echo "Enabling IP Forwarding ..."
Echo 1>/proc/sys/net/ipv4/ip_forward
Echo "Enabling DNS (outside) Service ..."
/Usr/sbin/named-u named-c/etc/named. out
Echo "Enabling DNS (inside) Service ..."
/Usr/sbin/named-u named-c/etc/named. in
Restart the machine!
Implementation Method in Bind9
You only need a named. conf file to complete the Specific Configuration:
Include "/etc/rndc. key ";
Options {
Directory "/var/named /";
......
};
};
# Log Files
Logging {
Category queries {
Default_syslog;
};
};
# DataBase Files
# Note the usage of view and match-clients, that is, they are working.
View "internal "{
Match-clients {10.0.0.0/8 ;};
Recursion yes;
Zone "."{
Type hint;
File "named. ca ";
};
Zone "0.0.127.in-addr. arpa "{
Type master;
File "0.0.127.in-addr. arpa. zone ";
};
Zone "localhost "{
Type master;
File "localhost. zone ";
};
Zone "xxu.edu.cn "{
Type master;
File "xxu.edu.cn. in. zone ";
};
Zone "10. in-addr.arpa "{
Type master;
File "10. in-addr.arpa.zone ";
};
};
View "external "{
Match-clients {any ;};
Recursion yes;
Zone "."{
Type hint;
File "named. ca ";
};
Zone "0.0.127.in-addr. arpa "{
Type master;
File "0.0.127.in-addr. arpa. zone ";
};
Zone "localhost "{
Type master;
File "localhost. zone ";
};
Zone "xxu.edu.cn "{
Type master;
File "xxu.edu.cn. out. zone ";
};
Zone "xx. xx.210.in-addr. arpa "{
Type master;
File "xx. xx.210.in-addr. arpa. zone ";
};
};
In this way, the configuration is complete! As for the specific data files, I think everyone should have configured them. I will not talk about them here!
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