DNS server(2)  &  Mail Server With CentOS

DNS server(2) & Mail Server With CentOS

·

6 min read

  1. Server1, 2: Mail Server (clinger.com, clouding.com) Practical Architecture

    • server1 : DNS server + Mail Server

    • s0erver2 : Mail Server

    1-1
    yum -y install sendmail sendmail-cf dovecot # 서버 구성에 필수적인 package설치

    1-2 
    vi /etc/hostname # hostname 변경
    1 mail.clinger.com

    1-3 
    vi /etc/hosts # hosts 추가
    1 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
     2 ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
     3 192.168.56.100 mail.clinger.com

    1-4 
    vi /etc/mail/local-host-names # local-host-name에 mail.clinger.com 추가
    1 # local-host-names - include all aliases for your machine here.
     2 mail.clinger.com


    1-5 
    vi /etc/sysconfig/network
    1 # Created by anaconda
     2 HOSTNAME=mail.clinger.com
  • The mail server configuration for server2 is carried out in the same way.

  • The mail domain for server2 is “clouding.com

  1. Server1 - Name Server: Add domain settings for clinger.com / clouding.com

    ```bash 2-1 vi /etc/named.conf # clouding.com 도메인 추가 62 zone "clinger.com" IN { 63 type master; 64 file "/var/named/clinger.com.db"; 65 allow-update { none; }; 66 }; 67 68 zone "clouding.com" IN { 69 type master; 70 file "/var/named/clouding.com.db"; 71 allow-update { none; }; 72 };

2-2 vi /var/named/clinger.com.db # clinger.com.db 수정 1 $TTL 3H 2 @ SOA @ root. (2 1D 1H 1W 1H) 3 IN NS @ 4 IN A 192.168.56.100 5 IN MX 10 mail.clinger.com 6 7 mail IN A 192.168.56.100

2-3 cp /var/named/cliger.com.db /var/named/clouding.com.db # clinger.com.db를 복사

2-4 vi /var/named/clouding.com.db # clouding.com.db의 ip주소와 도메인 이름 변경 1 $TTL 3H 2 @ SOA @ root. (2 1D 1H 1W 1H) 3 IN NS @ 4 IN A 192.168.56.200 5 IN MX 10 mail.clouding.com 6 7 mail IN A 192.168.56.200

2-5 named-checkconf # 해당 설정이 문제 없나 확인 named-checkzone clinger.com clinger.com.db named-checkzone clouding.com clouding.com.db


3. Server1, 2 - Mail Server: DNS changes

    ```bash
    3-1
    vi /etc/sysconfig/network-scripts/ifcfg-enp0s8 # 메일서버의 DNS를 변경
    1 TYPE=Ethernet
     2 PROXY_METHOD=none
     3 BROWSER_ONLY=no
     4 BOOTPROTO=none
     5 DEFROUTE=yes
     6 IPV4_FAILURE_FATAL=no
     7 IPV6INIT=yes
     8 IPV6_AUTOCONF=yes
     9 IPV6_DEFROUTE=yes
     10 IPV6_FAILURE_FATAL=no
     11 IPV6_ADDR_GEN_MODE=stable-privacy
     12 NAME=enp0s8
     13 UUID=cfbdf73e-14a0-4616-9da3-d3b809e726ef
     14 DEVICE=enp0s8
     15 ONBOOT=yes
     16 IPADDR=192.168.56.100
     17 PREFIX=24
     18 GATEWAY=192.168.56.2
     19 DNS1=192.168.56.100
     20 IPV6_PRIVACY=no
  1. Server1 - Mail Server: clinger.com mail server configuration
💡
Configure the mail server for clinger.com. The same process applies to server2 for clouding.com (just change the domain to clouding.com).
4-1
vi /etc/mail/sendmail.cf # 메일 서버 설정 수정
...
81 # my LDAP cluster
 82 # need to set this before any LDAP lookups are done (including classes)
 83 #D{sendmailMTACluster}$m
 84
 85 CWclinger.com # Cwlocalhost
 86 # file containing names of hosts for which we receive email
 87 Fw/etc/mail/local-host-names
...
262 # SMTP daemon options
 263
 264 O DaemonPortOptions=Port=smtp, Name=MTA
 265


4-2
vi /etc/mail/access
1 # Check the /usr/share/doc/sendmail/README.cf file for a description
 2 # of the format of this file. (search for access_db in that file)
 3 # The /usr/share/doc/sendmail/README.cf is part of the sendmail-doc
 4 # package.
 5 #
 6 # If you want to use AuthInfo with "M:PLAIN LOGIN", make sure to have the
 7 # cyrus-sasl-plain package installed.
 8 #
 9 # By default we allow relaying from localhost...
 10 Connect:localhost.localdomain RELAY
 11 Connect:localhost RELAY
 12 Connect:127.0.0.1 RELAY
 13 Connect:192.168.56.100 RELAY
 14 clinger.com RELAY
 15 clouding.com RELAY
 16 192.168.56.100 RELAY
4-3
makemap hash /etc/mail/access < /etc/mail/access
4-4 
vi /etc/dovecot/dovecot.conf
...
 23 # Protocols we want to be serving
 24 protocols = imap pop3 lmtp
 25
...
 29 # edit conf.d/master.conf.
 30 listen = *, ::
 31
 32 # Base directory where to store runtime data.
 33 base_dir = /var/run/dovecot/
 34


4-5
vi /etc/dovecot/conf.d/10-ssl.conf
...
5 # SSL/TLS support: yes, no, required. <doc/wiki/SSL.txt>
 6 # disable plain pop3 and imap, allowed are only pop3+TLS, pop3s, imap+TLS and imaps
 7 # plain imap and pop3 are still allowed for local connections
 8 ssl = no # ssl = required
 9


4-6
vi /etc/dovecot/conf.d/10-mail.conf
...
 24 # mail_location = maildir:~/Maildir
 25 mail_location = mbox:~/mail:INBOX=/var/mail/%u
 26 # mail_location = mbox:/var/mail/%d/%1n/%n:INDEX=/var/indexes/%d/%1n/%n
...
 116 # Grant access to these supplementary groups for mail processes. Typically
 117 # these are used to set up access to shared mailboxes. Note that it may be
 118 # dangerous to set these if users can create symlinks (e.g. if "mail" group is
 119 # set here, ln -s /var/mail ~/mail/var could allow a user to delete others'
 120 # mailboxes, or ln -s /secret/shared/box ~/mail/mybox would allow reading it).
 121 mail_access_groups = mail
 122
...
 163 # Locking method for index files. Alternatives are fcntl, flock and dotlock.
 164 # Dotlocking uses some tricks which may create more disk I/O than other locking
 165 # methods. NFS users: flock doesn't work, remember to change mmap_disable.
 166 lock_method = fcntl
 167


4-7
useradd admin # configure what you want
passwd admin # configure what you want

4-8
systemctl restart sendmail
systemctl enable sendmail
systemctl restart dovecot
systemctl enable dovecot
  1. Client) Test if the clinger.commail server is working properly

    💡
    The same configuration applies to the clouding.com mail server (just change the domain to clouding.com).
  • Install the ‘evolution’ app on the VM machine

  1. DNS server + Mail Server Test (2) - Install Roundcube Webmail

    💡
    This is optional. Instead of installing Evolution on the client, install Roundcube on each name server to test if clients can access webmail and exchange emails. Here, we will test the mail server for Server1 (clinger.com). You can test Server2 (clouding.com) in the same way.

    ```plaintext 1-1 yum-y install httpd mariadb-server php php-mysqlnd php-gd php-mbstring php-pecl-zip php-xml php

    1-2 systemctl restart httpd systemctl enable httpd systemctl restart mariadb systemctl enable mariadb

    2-1 wget github.com/roundcube/roundcubemail/releases..

    2-2 tar xfz roundcubemail-1.3.10-complete.tar.gz # 압축 해제 mv roundcubemail -1.3.10 /var/www/html # 파일 이동 ln -s /var/www/html/roundcubemail-1.3.10 /var/www/html/roundcube # 링크 생성

    2-3 chmod 777 /var/www/html/roundcube/temp/ #권한 변경 chmod 777 /var/www/html/roundcube/logs/

    2-4

    mysql

    CREATE DATABASE emailDB; # email DB 생성 GRANT ALL ON email.*TO 'emailAdmin'@'localhost' IDENTIFIED BY '1234'; FLUSH PRIVILEGES; EXIT

3-1

#web mail.clinger.com/roundcube/installer # 접속시 php관련 부분 OK 확인 후 하단 NEXT 클릭

3-2

#web Create config화면에서 product_name 입력, Database setup(MySQL) 입력, localhost, emailDB, emailAdmin

3-3

#web config.inc.php 저장

3-4

#terminal mv /root/download/config.inc.php /var/www/html/roundcube/config chmod 707 /var/www/html/roundcube/config/config.inc.php

3-5

#web initialize database 클릭, DB Schema OK

3-6

#web Test SMTP config-Sender, Recipient에 입력, Send test mail클릭 후 OK확인

3-7

#web Test IMAP config의 Username과 password에 모두 'jeong'입력, check login클릭, OK확인

4-1 mail.clinger.com/roundcube 에 접속, 초기 화면, (이름)에 ‘jeong’ 입력, (비밀번호) ‘jeong’입력

4-2 roundcube 아이콘 클릭 후 새 메일 보내기

4-3 sender가 'jeong@localhost'라면 Preferences를 통해 ''으로 변경

4-4 메일 전송 확인 ```