Friday, February 15, 2013

Mail Server Complete Configuration on Centos or Redhat RHEL


Mail Server Configuration 

1)DNS
2)POSTFIX
3)DOVECOT

1)DNS CONFIGURATION

[root@cmj-itss-naveen ~]#yum install bind*
[root@cmj-itss-naveen ~]#vi /etc/sysconfig/network 
change host name to dns.mumbai.com
[root@cmj-itss-naveen ~]#vi /etc/resolv.conf
                                         domain mumbai.com
                                         search mumbai.com
                                         nameserver <IPADDRESS>
                                         nameserver 10.210.8.36

The main configuration file for dns server isnamed.conf.By default this file is not created in /var/named/chroot/etc/directory.

[root@cmj-itss-naveen ~]# vi /var/named/chroot/etc/named.conf
options{ 
            
                       //listen-on {127.0.0.1; 10.210.8.36};
                       isten-on port 53 { 127.0.0.1;10.210.8.36;};
                        directory  "/var/named/"; 
                        recursion no;
                         //allow-query     { localhost;any; };
                         //forwarders { 8.8.8.8 };
                       //allow-transfer { 10.210.8.1 ; };
        
}; 

zone "mumbai.com" { 
                                type master; 
                                file "mumbai.com-fw"; 
 }; 
zone "8.210.10.in-addr.arpa" { 
                               type master; 
                               file "8.210.10.in-addr.arpa.zone"; 
}; 

[root@cmj-itss-naveen ~]# vi /var/named/chroot/var/named/mumbai.com-fw
; Forward resolution for mumbai.com

@       IN      SOA     dns.mumbai.com  root.dns.mumbai.com ( 
                                        2000031601 ; serial number 
                                        7200 ; refresh (2hrs) 
                                        3600 ; retry (1hr) 
                                        151200 ; expire (1 week) 
                                        86400 ) ; default TTL 
; define our name servers: 
                        NS      dns.mumbai.com. 
; define our mail severs: 
                        MX 10   mail.mumbai.com. 
; define the contact information for this domain: 
;                       TXT     "Contact: Jim Smith" 
;                       TXT     "Great Guru of Linux" 
;                       RP      admin.mumbai.com. ;EMAIL ID 

; define addresses and aliases: 
dns                     A       10.210.8.36 
gw                      A                       10.210.8.1
ns                      CNAME           dns 
mail                   CNAME         dns 
www                  CNAME            dns

                                  
[root@cmj-itss-naveen ~]# vi /var/named/chroot/var/named/8.210.10.in-addr.arpa.zone 

; Reverse resolution for mumbai.com

@       IN      SOA     dns.mumbai.com  root.dns.mumbai.com ( 
                                                2000031601 ; serial number 
                                                7200 ; refresh (2hrs) 
                                                3600 ; retry (1hr) 
                                                151200 ; expire (1 week) 
                                                86400 ) ; default TTL 
; define our name servers: 
                         NS              dns.mumbai.com. 
1                       PTR            gw
36               PTR            dns 
36                    PTR            ns 
36                     PTR            mail 
36                     PTR            www


[root@cmj-itss-naveen ~]# /etc/init.d/named restart 
Stopping named: .                                          [  OK  ] 
Starting named:                                              [  OK  ] 

check on http://www.techrepublic.com/article/setting-up-a-dns-server-under-linux-part-1-the-configuration/1052952








2)POSTFIX CONFIGURATION

[root@cmj-itss-naveen ~]#vi /etc/postfix/mail.cf
# line 75: uncomment and specify hostname
                                       myhostname =mail.mumbai.com
# line 83: uncomment and specify domain name

                                       mydomain =mumbai.com
# line 99: uncomment

                                        myorigin = $mydomain
# line 116: change

i                                        net_interfaces =all
# line 119: change if you use only IPv4

                                         inet_protocols =ipv4
# line 164: add

                                         mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
# line 264: uncomment and specify your LAN

                                         mynetworks = 127.0.0.0/8,10.0.0.0/24
# line 419: uncomment (use Maildir)

                                         home_mailbox = Maildir/
# line 545: uncomment, line 546: add

                                         header_checks = regexp:/etc/postfix/header_checks
                                         body_checks = regexp:/etc/postfix/body_checks
# line 571: add

                                        smtpd_banner = $myhostname ESMTP
# add at the last line

# limit an email size 10M

                                        message_size_limit = 10485760

# limit mailbox 1G

                                         mailbox_size_limit = 1073741824
# for SMTP-Auth settings

smtpd_sasl_type = dovecot
smtpd_sasl_path = private/auth
smtpd_sasl_auth_enable = yes
smtpd_sasl_security_options = noanonymous
smtpd_sasl_local_domain = $myhostname
smtpd_client_restrictions = permit_mynetworks,reject_unknown_client,permit
smtpd_recipient_restrictions = permit_mynetworks,permit_auth_destination,permit_sasl_authenticated,reject


[root@cmj-itss-naveen ~]#vi/etc/postfix/header_checks
# add at the head

# reject if email address is empty

/^From:.*<#.*@.*>/ REJECT
/^Return-Path:.*<#.*@.*>/ REJECT

[root@cmj-itss-naveen ~]#vi /etc/postfix/body_checks

# reject if includes 'example.com' in mail body

/^(|[^>].*)example.com/ REJECT

[root@cmj-itss-naveen ~]#/etc/rc.d/init.d/postfix start

[ OK]

[root@cmj-itss-naveen ~]#chkconfig postfix on

check on http://www.server-world.info/en/note?os=CentOS_6&p=mail



3)DOVECOT CONFIGURATION

[root@cmj-itss-naveen ~]#yum-y install dovecot

[root@cmj-itss-naveen ~]#vi /etc/dovecot/dovecot.conf

# line 31: change ( if not use IPv6 )

listen =*
[root@cmj-itss-naveen ~]#vi /etc/dovecot/conf.d/10-auth.conf

# line 9: uncomment and change ( allow plain text auth )

disable_plaintext_auth =no
# line 97: add

auth_mechanisms = plain login

[root@cmj-itss-naveen ~]# vi /etc/dovecot/conf.d/10-mail.conf

# line 30: uncomment and add

mail_location =maildir:~/Maildir

[root@cmj-itss-naveen ~]#vi /etc/dovecot/conf.d/10-master.conf

# line 84-86: uncomment and add

# Postfix smtp-auth
unix_listener /var/spool/postfix/private/auth {
mode = 0666

user = postfix  # add
group = postfix # add
}

[root@cmj-itss-naveen ~]# /etc/rc.d/init.d/dovecot start

Starting Dovecot Imap:
[ OK ]

[root@cmj-itss-naveen ~]# chkconfigdovecot on

check on http://www.server-world.info/en/note?os=CentOS_6&p=mail&f=2
http://k2-rnd.blogspot.in/2012/04/how-to-setup-postfix-dovecot-mail.html
http://www.wtuto.com/redhat/postfix-r6.html
http://www.cyberciti.biz/faq/linux-unix-bsd-postfix-forward-email-to-another-account/

No comments:

Post a Comment