Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to build a simple DNS server

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

How to build a simple DNS server, in view of this problem, this article introduces the corresponding analysis and answers in detail, hoping to help more partners who want to solve this problem to find a more simple and easy way.

Simple DNS server

Domain name server,dns protocol, its implementation software is mainly composed of configuration files and regional data files. Bind.bind software is composed of configuration files and regional data files.

Regional database files are mainly used to record resource records. One line of data.

Resource record types (RR_TYPE) include:

An A record, record FQDN-- > IPv4

AAA A record, record FQDN-- > IPv6

PTR PRT record, reverse parse, record IP-- > FQDN

NS NS record, name server, record the information of the DNS server itself, followed by A record

SOA SOA record, start of authity, the first authorization record, there is only one, must be the first.

CNAME CNAME alias

MX email record

Resource record format:

NAME [TTL] IN RR_TYPE VALUE

Bjs.io 888640 IN A 192.168.122.3

Bjs.io 888640 IN SOA bjs admin.bjs

SOA format: NAME VALUE

Name:dns server FQDN administrator mailbox version serial number refresh time retry time expiration time negative answer time

@ IN SOA ns1.bjs.io. Dnsadmin.bjs.io. 201811201 1H 10M 5D 1D

Note: @ in the administrator's mailbox is used. Instead of @ because @ has a special purpose in dns, the version serial number can only be 10, and more than 10 bits will make an error.

NS:

Name: current zone name

Value current zone DNS server name

For example:

Bjs.com. 86400 IN NS ns1

Bjs.com. 86400 IN NS ns2

MX:

Name current zone name

Value Mail Exchanger name

Baidu.com. IN MX 10 mx1.baidu.com.

Baidu.com. IN MX 10 mx2.baidu.com.

A record:

Www.baidu.com. IN A 1.1.1.1

Www.baidu.com. IN A 1.1.1.2

Bbs.baidu.com. IN A 1.1.1.1

PTR

Name:IP address, in a specific format, IP in reverse, and a specific suffix

Value FQDA

4.3.2.1.in-addr.arpa. IN PTR www.baidu.com.

CNAME

Web.baidu.com. IN CNAME www.baidu.com.

Note that TTL can be defined globally

@ indicates the current zone name

When two adjacent records have the same name, do not write

When a type of value such as MX,NS is FQDN, it should be followed by an A record

Dns is the protocol and bind is the implementation program of the protocol.

Yum-y install bind

Master configuration file

/ etc/named.conf can contain other configuration files

Global configuration segment:

Options {

Listen-on port 53 {192.168.136.4;}

Allow-query {any;}

}

Log configuration segment

Logging {...}

Zone configuration segment

Zone {...}

Every sentence ends with {there must be a space around}

The cache server must listen on IP addresses that can communicate with the outside world

Check for configuration file syntax errors

Named-checkconf

Parse the library file:

/ var/named/ directory

The general name is ZONE_NAME.zone

Note 1. A DNS service can provide services for multiple regions at the same time

two。 Must have root zone resolution library file named.ca

3. There should also be two local zone files localhost and 127.0.0.1

Forward: named.localhost

Reverse: named.loopback

Configure to resolve a forward area:

1. Define area

Implement in the main configuration file

Zone "ZONE_NAME" IN {

Type {master | slave | hint | forward}

File "ZONE_NAME.zone"

}

Take bjs.io as column

Zone "bjs.io" IN {

Type master

File "bjs.io.zone"

}

two。 Create a zone file

Under the / var/named directory, bjs.io is the column, the group is named, and the permission is unreadable to other users.

Vi / var/named/bjs.io.zone

$TTL 1D

@ IN SOA ns1.bjs.io root.localdomain 2019011601 1H 10m 3D 1D

IN NS ns1

Ns1 IN A 192.168.122.11

Www IN A 192.168.122.3

Www IN A 192.168.122.4

3. Permission setting

Chown .named bjs.io.zone

Chmod o = bjs.io.zone

4. Check configuration files and area files

Named-checkconf

Named-checkzone bjs.io / var/named/bjs.io.zone

5. Let the service reload the configuration file

Systemctl restart named

6. Check the monitoring situation

Ss-lnt

7. Set the dns address to this server on another server, and then test

Dig-t A www.bjs.io

Dig-t NS bjs.io

Configure to resolve a reverse area:

1. Define area

Zone "122.168.192" IN {

Type master

File "122.168.192.in-addr.arpa"

}

two。 Create a zone file

Vi 122.168.192.in-addr.arpa

$TTL 1D

@ IN SOA ns1.bjs.io root.localdomain 2019011601 1H 10m 3D 1D

IN NS ns1.bjs.io.

11 IN PTR ns1.bjs.io.

3 IN PTR www.bjs.io.

4 IN PTR www.bjs.io.

3. Permission setting

Chown .named 122.168.192.in-addr.arpa

Chmod o = 122.168.192.in-addr.arpa

4. Check configuration files and area files

Named-checkconf

Named-checkzone 122.168.192.in-addr.arpa / var/named/122.168.192.in-addr.arpa

5. Let the service reload the configuration file

Systemctl reload named

6. Check the monitoring situation

Ss-lnt

7. Set the dns address to this server on another server, and then test

Dig-x 192.168.122.3

This is the answer to the question about how to build a simple DNS server. I hope the above content can be of some help to you. If you still have a lot of doubts to solve, you can follow the industry information channel for more related knowledge.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report