Linux builds a domain name server with separate resolution

1. Configure dual network cards for the gateway server

1. Configure dual network cards for the gateway server

Add another network card in the shutdown state and restart the system

ifconfig           
cd /etc/sysconfig/network-scripts/
cp ifcfg-ens33 ifcfg-ens36

Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here

Insert picture description here
Insert picture description here

Insert picture description here
Intranet network configuration
Insert picture description here
Insert picture description here

2. Install the software on the DNS gateway client and edit the configuration file

yum install -y bind

Insert picture description here

3. Modify the main configuration file

vim /etc/named.conf
options {
        listen-on port 53 { any; };      			#监听本机或者any
#        listen-on-v6 port 53 { ::1; };   			
        directory       "/var/named";    			
        dump-file       "/var/named/data/cache_dump.db";
        statistics-file "/var/named/data/named_stats.txt";
        memstatistics-file "/var/named/data/named_mem_stats.txt";        
        recursing-file  "/var/named/data/named.recursing";
        secroots-file   "/var/named/data/named.secroots";
        allow-query     { any; };        			#允许所有主机解析
		……
};

include "/etc/named.rfc1912.zones";	
————————————————
版权声明:本文为CSDN博主「IHBOS」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/IHBOS/article/details/114002016

Insert picture description here

4. Modify the zone configuration file

vim /etc/named.rfc1912.zones
view “lan” { #define intranet view, view represents container segmentation
match-clients {192.168.132.0/24; };
#match intranet network segment zone “zhangsan.com” IN { #Set the zone to be parsed
type master;
file “zhangsan.com.zone.lan”; #Data configuration file

};
zone “.” IN {
#The root zone configuration can be cut from the main configuration file, dd+p type hint; #hint is the root zone type
file “named.ca”;
};
};

view “wan” {#define external network view
match-clients {any; };
#Match any address except the intranet network segment zone “zhangsan.com” IN { type master; file “zhangsan.com.zone.wan” ; }; };



#Note: Once the view is enabled, all zones must be under the view, so the default zone for the self-check of the system should also be placed under the view or deleted
————————————————
Copyright statement: This article is the original article of the CSDN blogger "IHBOS", following the CC 4.0 BY-SA copyright agreement. Please attach the original source link and this statement for reprinting.
Original link: https://blog.csdn.net/IHBOS/article/details/114002016
Insert picture description here

5. Modify the regional data configuration file

cd /var/named
cp -p named.localhost zhangsan.com.zone.lan
cp -p named.localhost zhangsan.com.zone.wan

vim zhangsan.com.zone.lan
$TTL 1D
@       IN SOA  zhangsan.com. admin.zhangsan.com. (
                                        0       ; serial
                                        1D      ; refresh
                                        1H      ; retry
                                        1W      ; expire
                                        3H )    ; minimum
        NS      zhangsan.com.
        A       192.168.132.10
www IN 	A       192.168.132.100			#内网主机通过解析www.zhangsan.com的地址得到192.168.132.100




vim zhangsan.com.zone.wan
$TTL 1D
@       IN SOA  zhangsan.com. admin.zhangsan.com. (
                                        0       ; serial
                                        1D      ; refresh
                                        1H      ; retry
                                        1W      ; expire
                                        3H )    ; minimum
        NS      zhangsan.com.
        A       12.0.0.1
www IN	A       12.0.0.100				#外网主机通过解析www.zhangsan.com的地址得到12.0.0.100
————————————————
版权声明:本文为CSDN博主「IHBOS」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/IHBOS/article/details/114002016

Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here

6. Start the service

Insert picture description here

7. Add the DNS server address to the domain name resolution configuration file of the client on the internal and external networks

Insert picture description here

8. Test on internal and external network clients

Insert picture description here

Insert picture description here
Insert picture description here
And set the address and DNS server address
Insert picture description here
Insert picture description here

Guess you like

Origin blog.csdn.net/zhangyuebk/article/details/114107678