What DNS?
It is the name resolution protocol for TCP/IP networks, such as the Internet. A DNS server hosts information that allows client computers to resolve easy-to-remember alphanumeric DNS names to the IP addresses that computers use to communicate with each other.
DNS DOMAIN TYPE:
TOP LEVEL DOMAIN: A two- or three-letter name used to indicate a country, region, or the type of organization that uses a name: ( Example: “.com” )
SECOND LEVEL DOMAIN:Variable length registered name that an individual or organization uses and the Internet. These names are always based on an appropriate top-level domain, depending on the type of organization or geographic location where the name is used.(EXAMPLE: “NETWORK-ORBITA.”)
SUBDOMAIN: Additional names that an organization can create derived from the second-level registered domain name. These include names added to develop the DNS name tree into an organization and divide it into departments or geographic locations. (EXAMPLE: “ROKITOH.RED-ORBITA.COM”)
Tools:
Virtualbox (As always)
Debian Stable (No graphical interface)
Bind9 (Our DNS server)
Well, first of all, we are going to configure our IP addressing.
rokitoh@redorbita:~# nano /etc/network/interfaces# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
allow-hotplug eth0
#iface eth0 inet dhcp
auto eth0
iface eth0 inet static
address 192.168.1.233
netmask 255.255.255.0
gateway 192.168.1.1We start the new configuration
rokitoh@redorbita:~# /etc/init.d/networking restart
Deconfiguring network interfaces…done.Install and configure Bind9
rokitoh@redorbita:~# apt-get install bind9We stop bind9 services
rokitoh@redorbita:~# /etc/init.d/bind9 stop
Stopping domin name service…: bind9We edit the file /etc/default/bind9 . We want the bind daemon to run with the unprivileged bind user, “chrooted” to the /var/lib/named directory. To do this, we look for where it says <<OPTIONS=”-u bind”>> and we replace it with <var/lib/named”>
rokitoh@redorbita:~# nano /etc/default/bind9
#run resolvconf?
RESOLVCONF=yes
#startup options for the server
OPTIONS="-u bind -t /var/lib/named"
We create the directory tree
rokitoh@redorbita:~# mkdir -p /var/lib/named/etc
rokitoh@redorbita:~# mkdir /var/lib/named/dev
rokitoh@redorbita:~# mkdir -p /var/lib/named/var/cache/bind
rokitoh@redorbita:~# mkdir -p /var/lib/named/var/run/bind/run
rokitoh@redorbita:~# mv /etc/bind /var/lib/named/etcrokitoh@redorbita:~# ln -s /var/lib/named/etc/bind /etc/bindrokitoh@redorbita:~# mknod /var/lib/named/dev/null c 1 3
rokitoh@redorbita:~# mknod /var/lib/named/dev/random c 1 8
rokitoh@redorbita:~# chmod 666 /var/lib/named/dev/null /var/lib/named/dev/random
rokitoh@redorbita:~# chown -R bind:bind /var/lib/named/var/*
rokitoh@redorbita:~# chown -R bind:bind /var/lib/named/etc/bindrokitoh@redorbita:~# chown R bind:bind /var/lib/named/var/*
rokitoh@redorbita:~# chown R bind:bind /var/lib/named/etc/bindrokitoh@redorbita:~# nano /etc/default/rsyslogd# Options for rsyslogd
# -m 0 disables 'MARK' messages (deprecated, only used in compat mode < 3)
# -r enables logging from remote machines (deprecated, only used in compat mode < 3)
# -x disables DNS lookups on messages received with -r
# -c compatibility mode
# See rsyslogd(8) for more details
RSYSLOGD_OPTIONS="-a /var/lib/named/dev/log"We start Bind9
rokitoh@redorbita:~# /etc/init.d/bind9 startrokitoh@redorbita:~ less /var/log/syslogConfigure DNS zones
TYPES OF ZONE REGISTRATION
Configure the zone file
rokitoh@redorbita:~# cd /etc/bind/rokitoh@redorbita:/etc/bind~# cp db.255 redorbita.comrokitoh@redorbita:/etc/bind~# nano redorbita.com$TTL 1W
@ IN SOA redorbita.com. root.redorbita.com (
2 ; Serial Number
1W ; Time To Refresh
1D ; Time To Retry
28D ; Time To Expire
1W ) ; Negative Cache TTL
;
@ IN NS redorbita.com.
@ IN A 192.168.1.233Ahora nos toca configurar la zona infeversa
rokitoh@redorbita:/etc/bind~# cp db.125 1.168.192.in.addr.arparokitoh@redorbita:/etc/bind~# nano 1.168.192.in.addr.arpa$TTL 1W
@ IN SOA redorbita.com. admin.redorbita.com. (
2 ; Serial Number
1W ; Time To Refresh
1D ; Time To Retry
28D ; Time To Expire
1W ) ; Negative Cache TTL
;
@ IN NS redorbita.com.
233.1.168 IN PTR redorbita.com.Configure named.conf.
It is the configuration file of our DNS server, inside it we will have to add some parameters to call the files we have created.rokitoh@redorbita:/etc/bind~# nano named.confzone "255.inaddr.arpa" {
type master;
file "/etc/bind/db.255";
};
########################################
#### Agregado por el Administrador #####
########################################
zone "redorbita.com" {
type master;
file "/etc/bind/zones/redorbita.com";
};
zone "1.168.192.inaddr.arpa" {
type master;
file "/etc/bind/zones/1.168.192.in-addr.arpa";
};
#######################################
include "/etc/bind/named.conf.local";Modify /etc/resolv.conf
rokitoh@redorbita:/etc/bind~# nano /etc/resolv.confdomain redorbita.com
nameserver 192.168.1.233Checks
Now let's check that our server is working correctly.rokitoh@redorbita:~# host redorbita.com 192.168.1.233
Using domain server:
Name: 192.168.1.233
Address: 192.168.1.233#53
Aliases:Using Netstat
rokitoh@redorbita:~# netstat tanp | grep named
tcp 0 0 192.168.1.233:53 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:53 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:953 0.0.0.0:* LISTEN
rokitoh@redorbita:~#
Comments