This is a step by step tutorial on how to install and configure DNS server for your LAN using bind9. The DNS server will provide caching and name resolution as well as reverse name resolution for your local network. In this tutorial, we will use the domain "debian.lan" and this will be the domain of your local network. The domain "debian.lan" is not accessible from the internet; its private ip address is "192.168.4.1".

1.     Installing bind9 and dns utilities

Firstly, we need to confirm whether bind9 and dnsutils are installed on our system. Let’s install the bind9 package and dns utilities from Debian repository.

$ apt-get install bind9 dnsutils

2.     Configure your Linux system

Add nameserve to /etc/resolve.conf.

Edit your /etc/resolvconf/resolve.conf.d/base (red part is added)

192.168.4.1

202.103.24.68

8.8.8.8

This is where Linux looks to find out how it should perform DNS lookups.

3.     Lets create a zone

The zone files (or database files) are the heart of your BIND system. This is where all the information is stored on what hostname goes with what ip address.
Before we create a zone file, let’s edit first the
local configuration file/etc/bind/named.conf.local.

//

// Do any local configuration here

//

// Consider adding the 1918 zones here,
if they are not used in your

// organization

//include
"/etc/bind/zones.rfc1918";

zone "debian.lan" {

type master;

file "db.debian.lan";

};

zone "4.168.192.in-addr.arpa" {

type master;

file "db.192.168.4";

};

Let’s start creating a
zone file in /var/cache/bind/ directory. Create
a file called db.debian.lan

$ vi /var/cache/bind/db.debian.lan

And add the following entry

$TTL 604800

@ IN SOA main.debian.lan. admin.debian.lan.
(

2008080101      ;serial

04800           ;refresh

86400           ;retry

2419200         ;expire

604800          ;negative cache TTL

)

@      
IN      NS      main.debian.lan.

@      
IN      A       192.168.4.1

@      
IN      MX     10     
main.debian.lan.

main   
IN       A      192.168.4.1

www    
IN     CNAME  main

ubuntu 
IN       A     
192.168.4.2

Let’s create the reverse DNS
zone file called db.192.168.100

$ vi
/var/cache/bind/db.192.168.4

And the following entry.

$TTL 604800

@ IN SOA main.debian.lan. admin.debian.lan.
(

2008080101      ;serial

604800          ;refresh

86400           ;retry

2419200         ;expire

604800          ;negative cache TTL

)

@      
IN      NS      main.debian.lan.

@      
IN      A       192.168.4.1

1      
IN      PTR      main.debian.lan.

2      
IN      PTR      ubuntu.debian.lan.

The
zone files are created, you can check your
zone file configurations using these utilities:

$ named-checkzone main.debian.lan /var/cache/bind/db.debian.lan
$ named-checkconf
/etc/bind/named.conf.local

Let’s edit the file /etc/bind/named.conf.options

$
vi
/etc/bind/named.conf.options

Uncomment the line forwarders and add your ISP's DNS
server. (We have no ISP, so ignore)

forwarders {

202.78.97.41;

202.78.97.3;

};

Let’s restart our DNS server, and
test using the tool dig.

$ /etc/init.d/bind9 restart
$ dig debian.lan

You should see the following message

; <<>> DiG 9.3.4
<<>> debian.lan

;; global options:  printcmd

;; Got answer:

;; ->>HEADER<<- opcode:
QUERY, status: NOERROR, id: 54950

;; flags: qr aa rd ra; QUERY: 1, ANSWER:
1, AUTHORITY: 1, ADDITIONAL: 1

;; QUESTION SECTION:

;debian.lan.                    IN      A

;; ANSWER SECTION:

debian.lan.             64800   IN     
A       192.168.4.1

;; AUTHORITY SECTION:

debian.lan.             64800   IN     
NS      main.debian.lan.

;; ADDITIONAL SECTION:

main.debian.lan.        64800   IN     
A       192.168.4.1

;; Query time: 1 msec

;; SERVER: 192.168.4.1#53(192.168.4.1)

;; WHEN: Tue Aug  5 09:33:40 2008

;; MSG SIZE  rcvd: 79

Test your reverse DNS

$ dig -x debian.lan

If
you see this message, you have successfully installed the DNS
server.

; <<>> DiG 9.3.4
<<>> -x debian.lan

;; global options:  printcmd

;; Got answer:

;; ->>HEADER<<- opcode:
QUERY, status: NXDOMAIN, id: 42510

;; flags: qr rd ra; QUERY: 1, ANSWER: 0,
AUTHORITY: 1, ADDITIONAL: 0

;; QUESTION SECTION:

;lan.debian.in-addr.arpa.       IN     
PTR

;; AUTHORITY SECTION:

in-addr.arpa.             10800       IN     SOA  A.ROOT-SERVERS.NET.
dns-ops.ARIN.NET. 2008080416 1800 900 691200 10800

;; Query time: 952 msec

;; SERVER: 192.168.4.1#53(192.168.4.1)

;; WHEN: Tue Aug  5 09:34:25 2008

;; MSG SIZE  rcvd: 108

You can also check your
DNS nslookup and host command.

nslookup debian.lan
nslookup 192.168.4.1
host debian.lan
host 192.168.4.1

4.    
Update bind9.service and bind9-resolvconf.service

To boots up local DNS automatically at
startup, we need below steps.

Before, bind9.service is
dependent on network.target, and bind9-resolvconf.service
is dependent on bind9.service. However, if Wifi-ublox is not ready, bind9
service finished, then bind9 will not work. So we need to set bind9.service
be dependent on the service which boots up Wifi-ublox as below.

After /etc/init.d/bind9
restart is executed, /etc/systemd/system/multi-user.target/bind9.service
will generate a soft link to /lib/systemd/system/bind9.service. bind9-resolvconf.service
is under /lib/systemd/system/.

At last, we need to enable bind9 service at startup.

$
systemctl enable
bind9

Bind9.service

[Unit]

Description=BIND Domain Name Server

Documentation=man:named(8)

After=nio-autoexecB1.service

[Service]

ExecStart=/usr/sbin/named -f -u bind

ExecReload=/usr/sbin/rndc reload

ExecStop=/usr/sbin/rndc stop

[Install]

WantedBy=multi-user.target

bind9-resolvconf.service

[Unit]

Description=local BIND via resolvconf

Documentation=man:named(8) man:resolvconf(8)

Requires=bind9.service

After=bind9.service

ConditionFileIsExecutable=/sbin/resolvconf

[Service]

ExecStart=/bin/sh -c 'echo nameserver
127.0.0.1 | /sbin/resolvconf -a lo.named'

ExecStop=/sbin/resolvconf -d lo.named

[Install]

WantedBy=bind9.service

5.    
Configure Client Device in Lan Network

All computers in the LAN are
going to use 192.168.4.1 as a nameserver, this can be set manually by setting
statically:

$
vi
/etc/resolvconf/resolv.conf.d/base

Then put this information, add this at
the top of file.

192.168.4.1

 

 

Source
Reference
:
http://www.cahilig.net/2008/07/05/how-setup-lan-dns-server-using-bind9-under-debian-etch-and-ubuntu-804

[DNS]部署局域网DNS服务器的更多相关文章

  1. 架构师成长之路6.4 DNS服务器搭建(部署主从DNS)

    点击返回架构师成长之路 架构师成长之路6.3 DNS服务器搭建(部署主从DNS)  部署主DNS : 点击 部署从DNS : 如下步骤 1.与主DNS一样,安装bind yum -y install ...

  2. Windows10怎么架设局域网DNS服务器?

    已采纳 需要安装Windows组件进行设置.最好是安装服务器版本的Windows. 1. 安装DNS服务 开始—〉设置—〉控制面板—〉添加/删除程序—〉添加/删除Windows组件—〉“网络服务”—〉 ...

  3. DNS单机部署以及智能dns部署

    dns理论 dns的出现 网络出现的早期是使用IP地址通讯的,那时就几台主机通讯.但是随着接入网络主机的增多,这种数字标识的地址非常不便于记忆,UNIX上就出现了建立一个叫做hosts的文件(Linu ...

  4. 【Linux】DNS服务-BIND从服务器、缓存服务器及转发服务器配置(三)

    环境 操作系统:CentOS 6.5 DNS软件:bind(安装参照:[Linux]DNS服务-BIND基础配置(二)) BIND从服务器 从服务器就是在bind的主配置文件中添加从域example. ...

  5. ipv6修改DNS服务-首选DNS服务器:240c::6666

    下一代互联网国家工程中心推出的IPv6 DNS服务 首选DNS服务器:240c::6666 备用DNS服务器:240c::6644   来自下一代互联网国家工程中心官网消息显示,日前,下一代互联网国家 ...

  6. 【入门】广电行业DNS、DHCP解决方案详解(三)——DNS部署架构及案

    [入门]广电行业DNS.DHCP解决方案详解(三)——DNS部署架构及案 DNS系统部署架构 宽带业务DNS架构 互动业务DNS架构 案例介绍 案例一 案例二 本篇我们将先介绍DNS系统部署架构体系, ...

  7. DNS部署(centos 6)

    DNS部署(主从) 安装环境:CentOS 6.8 准备两台主机:192.168.137.13(主DNS).192.168.137.14(从DNS) EPEL仓库使用阿里源 rpm -ivh http ...

  8. Docker环境下搭建DNS LVS(keepAlived) OpenResty服务器简易集群

    现在上网已经成为每个人必备的技能,打开浏览器,输入网址,回车,简单的几步就能浏览到漂亮的网页,那从请求发出到返回漂亮的页面是怎么做到的呢,我将从公司中一般的分层架构角度考虑搭建一个简易集群来实现.目标 ...

  9. centos DNS服务搭建 DNS原理 使用bind搭建DNS服务器 配置DNS转发 配置主从 安装dig工具 DHCP dhclient 各种域名解析记录 mydns DNS动态更新 第三十节课

    centos  DNS服务搭建  DNS原理  使用bind搭建DNS服务器 配置DNS转发 配置主从  安装dig工具  DHCP  dhclient  各种域名解析记录  mydns DNS动态更 ...

随机推荐

  1. PHP-中文在计算机中的存储

    经常我们打开外国网站的时候出现乱码,又或者打开很多非英语的外国网站的时候,显示的都是口口口口口的字符, WordPress程序是用的UTF-8,很多cms用的是GB2312. ● 为什么有这么多编码? ...

  2. Chrome禁用缓存

    Chrome默认对JS和CSS等静态资源进行缓存,对HTML不启用缓存. 在开发阶段,我们想要更改之后马上看到效果,那就必须禁用JS和CSS. 快捷键是F12+F1,F12相当于打开dev-tool, ...

  3. Linux-支持中文

    转自:http://www.centoscn.com/CentosBug/osbug/2014/0919/3776.html 英文版的linux系统默认不支持中文显示 那么如何显示中文呢? 可以使用l ...

  4. RHEL7 -- systemd

    systemd 在RHEL7中,进程ID 1属于systemd这个新的进程.(代替之前版本中的init) systemd提供了以下新功能: ·并行化功能,可以提高系统的启动速度 ·按需启动守护进程,而 ...

  5. 打开u盘时提示是否要将其格式化的提示

    早上打开电脑插入U盘后,发现U盘报以下错误:(心中一紧,昨晚写的文档还在其中呢) 修复方法: Win+R 输入cmd 打开 ,执行命令 chkdsk G: /f 其中G为损坏区域所在盘符,即U盘在电脑 ...

  6. Linux驱动面试题总结

    1. Linux设备中字符设备与块设备有什么主要的区别?请分别列举一些实际的设备说出它们是属于哪一类设备. 字符设备:字符设备是个能够像字节流(类似文件)一样被访问的设备,由字符设备驱动程序来实现这种 ...

  7. js实现多物体运动框架并兼容各浏览器

    首先,我们须要知道在js中获取对象的宽度如offsetWidth等.可能会存在一些小小的bug.原因之中的一个在于offsetWidth只不过获取盒子模型中内容的部分宽度.并不包括内边距,边框和外边距 ...

  8. linux extundelete 删除文件恢复

    extundelete是基于Linux的一个数据恢复工具,它通过分析文件系统的日志,解析出所有文件的inode信息,从而可以恢复Linux下主流的ext3,ext4文件系统下被误删除的文件. [问题案 ...

  9. shell教程一:字符串操作

    一:Linux shell字符串截取与拼接 假设有变量 var=http://www.linuxidc.com/123.htm 1  # 号截取,删除左边字符,保留右边字符. echo ${var#* ...

  10. Spring mvc中DispatcherServlet详解

    简介 DispatcherServlet是前端控制器设计模式的实现,提供SpringWebMVC的集中访问点,而且负责职责的分派,而且与spring IOC容器无缝集成,从而可以获得Spring的优势 ...