Saturday, July 27, 2013

DNS Server using Bind on CentOS 6.4 - 1



DNS Server using BIND on CentOS 6.4

Part I  Essential DNS Functions 1
 Chapter 1 DNS Service
 Chapter 2 DNS Server Software
 Chapter 3 Terms (Resource Records)
 Chapter 4 Bind Installation and startup

Part II  Essential DNS Functions 2
 Chapter 5 Creating zones- Forward & Reverse
 Chapter 6 Adding More zone
 Chapter 7 DNS Load Sharing
 Chapter 8 Master/Slave name server

Part III  Advanced DNS Functions
 Chapter 9 BIND ACL
 Chapter 10 Spilt DNS: VIEW
 Chapter 11 Dynamic DNS Update (DDNS)
 Chapter 12 How to use Client tools   - nslookup, dig, host

Part IV  DNS Security
 Chapter 13 TSIG and DNSSEC
 Chapter 14 RNDC service
 Chapter 15 Some DNS Security Issues
 Chapter 16 DNS Cache Poisoning

Part V  DNS Bind GUI Tools

Chapter 1  DNS Service
1. Domain Name System (DNS)
       Resolves hostnames into IP addresses (forward lookup)
         Name (Human being friendly)  -> IP address (Computer friendly)
       Resolves IP addresses into hostnames (reverse lookup)
          IP address -> Name
       Allows machines to be logically grouped by name domains
       Provides email routing information
2. Zones, Domains and Delegation
       A domain is a complete sub-tree of the hierarchical namespace
       A zone is the part of the domain managed by a particular server
       Subdomains may be delegated into additional zones
       A zone may directly manage some subdomains
3. Name Server Types
a. Master name server (Primary)
    Contains the master copy of data for a zone
b. Slave name server (Secondary)
§   Provides a backup to the master name server
§   All slave servers maintain synchronization with their master name server
c. Caching–only Name Server
§   forwards queries and caches results.
§   provides Internet root server 'hints' or references via named.ca
§   /etc/resolv.conf should include nameserver 127.0.0.1 

4. DNS Hierarchy




5. DNS Name Resolution Process













Chapter 3 DNS Server Terms 

Authoritative server
A DNS server that hosts a primary or secondary copy of zone data
Non-authoritative server
do not contain copies of any domains but have a cache file that is constructed from all the DNS lookups performed in the past for which it has gotten an authoritative response
FQDN
A DNS name that uniquely identifies a node in a DNS namespace. Fully qualified domain name
Iterative query
A query made by a client to a DNS server for an authoritative answer that can be provided by the server without generating additional server-side queries to other DNS servers
Recursive query
A query made by either a client or a DNS server on behalf of a client, the response to which can be an authoritative answer or a referral to another server
CNAME
Canonical Name record is used to create aliases that point to other names
Address (A) record
associates a domain name with an IP address
Pointer (PTR) record
provides data for reverse DNS, which is used for logging the domain name and verification purposes
Name Servers (NS)
identifies the authoritative DNS servers for a domain
Mail Servers (MX):
identifies the server to which e-mail is directed
Text Record (TXT)
can be used for any kind of documentation
First Record (SOA)
the first record in the zone file to contains the name of the primary DNS server, which must correspond to an NS record in the file
Serial :
Number to  increment when any resource record in the zone file is updated. A slave (Secondary) server will read the master DNS SOA record periodically
Refresh :
Indicates the time when the slave will try to refresh the zone from the master
Retry:
Defines the time between retries if the slave (secondary) fails to contact the master when refresh (above) has expired
Expire :
Indicates when the zone data is no longer authoritative. Used by Slave or (Secondary) servers only
Minimum:
redefined this value to be the negative caching time - the time a NAME ERROR = NXDOMAIN result may be cached by any resolver
TTL (Time to Live) :
defines the duration in seconds that the record may be cached


Chapter 4  Bind Installation & Startup
1. Package Installation
# rpm –qa | grep bind
      bind-utils-9.8.2-0.17.rc1.el6.i686          - Utilities for querying DNS
      bind-libs-9.8.2-0.17.rc1.el6.i686            - Libraries
      bind-9.8.2-0.17.rc1.el6.i686        - The Berkeley Internet Name Domain (BIND)
      bind-chroot-9.8.2-0.17.rc1.el6.i686    - Chroot runtime environment
      bind-devel-9.8.2-0.17.rc1.el6.i686           - Header files and libraries
# yum install bind-utils bind-libs bind-chroot bind-devel bind -y

2. Service Startup
# service named start
# ps –ef | grep named
# netstat –nat | grep 53
# tail –f /var/log/messages
3. Service Registration
# chkconfig –add named
# chkconfig named on
# chkconfig –list named
 



Saturday, July 13, 2013

OpenDKIM with Postfix on CentOS 6.4



OpenDKIM with Postfix on CentOS 6.4

l   Chapter 1 DKIM Service

l   Chapter 2 DKIM Installation and startup

l   Chapter 3 OpenDKIM Configuration

l   Chapter 4 Postfix Configuration

l   Chapter 5 OpenDKIM Testing



Chapter 1 DKIM Service

1.    What is DKIM (DomainKeys Identified Mail)? 
  • Cryptography-based protocol, signs selected header fields and message body
  •       Validate identifier and msg data integrity - DNS identifiers, Public keys in DNS
  • Intended to allow good senders to prove that they did send a particular message
  • Prevent forgers from masquerading as good senders (if those senders sign all outgoing mail)
DomainKeys (Yahoo) + Identified Mail (Cisco)

Chapter 2  DKIM  Installation and Startup
1. Requirements
a. Postfix must be working
# ps –ef | grep postfix
b. Sendmail is turned off
# chkconfig sendmail off
2.Package installation
# rpm –qa | grep opdndkim
libopendkim-2.8.3-2.el6.i686
libopendkim-devel-2.8.3-2.el6.i686
opendkim-2.8.3-2.el6.i686
3. User and Directory checking
# grep opendkim /etc/passwd /etc/shadow /etc/group
# ls –l /etc/opendkim /var/run/opendkim
4. Service startup
# service opendkim start
Chapter 3  OpenDKIM Configuration
1.Generate Keys for signing
# mkdir /etc/opendkim/keys/chul.com
# cd /etc/opendkim/keys/chul.com
# opendkim-genkey -d chul.com -s default
# chown -R opendkim:opendkim /etc/opendkim/keys/chul.com
# chmod 640 default.private
2. Create KeyTable file
# cat /etc/opendkim/KeyTable
default._domainkey.chul.com chul.com:default:/etc/opendkim/keys/chul.com/default.private
3. Create SigningTable file
# cat /etc/opendkim/SigningTable
*@chul.com default._domainkey.chul.com
4. Create TrustedHosts file
# cat /etc/opendkim/TrustedHosts
127.0.0.1
server.chul.com
chul.com
192.168.80.0/24
5. Adding DNS Records
 # cat /etc/opendkim/keys/chul.com/default.txt >> /var/named/chul.zone
6. Configuring main file
# vi  /etc/opendkim.conf
#MTA sometimes modify email in transit, so it can invalidate the DKIM signature
Canonicalization         relaxed/relaxed  or simple
# Selectors allows a domain to have more than one public-key in DNS
Selector                                  default
KeyTable                refile:/etc/opendkim/KeyTable
Mode                              sv (Sign and verify)
SigningTable                       refile:/etc/opendkim/SigningTable
Socket                   inet:8891@localhost
UserID                   opendkim:opendkim
ExternalIgnoreList         refile:/etc/opendkim/TrustedHosts
InternalHosts             refile:/etc/opendkim/TrustedHosts

Chapter 4  Postfix Configuration
1. Edit Postfix configuration file
# vi  /etc/postfix/main.cf
# opendkim setup
smtpd_milters = inet:localhost:8891
non_smtpd_milters = inet:localhost:8891
milter_default_action = accept
2. Service startup
# service opendkim start
# service postfix restart
# service named restart
# chkconfig opendkim on
# ps –ef | grep dkim
# netstat –nat | grep 8891

Chapter 5 OpenDKIM Testing
1.Testing using Local email address on Evolution and Thunderbird
Sender: tland@chul.com 
Recipient: linux@chul.com
# tail –f  /var/log/maillog
server opendkim[12275]: DC5873A4: DKIM-Signature field added (s=default, d=chul.com)
2. Testing using External email address
Send a signed email to      : autorespond+dkim@dk.elandsys.com
                                             : sa-test@sendmail.net
                                             : check-auth@verifier.port25.com