[root@localhost ~]# dnf -y install sendmail
[root@localhost ~]# vi /etc/hostname
[root@localhost ~]# vi /etc/hosts
[root@localhost ~]# vi /etc/mail/local-host-names
[root@localhost ~]# vi /etc/sysconfig/network
[root@localhost ~]# reboot
# etc/hostname
mail.naver.com
# etc/hosts
(상략)
192.169.111.100 mail.naver.com
# etc/mail/local-host-names
(상략)
mail.naver.com
# etc/sysconfig/network
HOSTNAME=mail.naver.com
이 준비과정을 Server(B)에서도 동일하게 한다. 다만 mail.naver.com이 아닌 mail.daum.net으로 한다.
[root@mail ~]# dnf -y install bind bind-chroot
[root@mail ~]# vi /etc/named.conf
[root@mail ~]# cd /var//named/
[root@mail named]# touch naver.com.db daum.net.db
[root@mail named]# ls
chroot daum.net.db named.ca named.localhost naver.com.db
data dynamic named.empty named.loopback slaves
[root@mail named]# vi naver.com.db
[root@mail named]# vi daum.net.db
[root@mail named]# named-checkconf
[root@mail named]# named-checkzone naver.com naver.com.db
zone naver.com/IN: loaded serial 2
OK
[root@mail named]# named-checkzone daum.net daum.net.db
zone daum.net/IN: loaded serial 2
OK
#
zone "naver.com" IN {
type master;
file "naver.com.db";
allow-update { none;};
};
zone "daum.net" IN {
type master;
file "daum.net.db";
alloa-update { none;};
};
#
$TTL 3H
@ SOA @ root. ( 2 1D 1H 1W 1H )
IN NS @
IN A 192.168.111.100
IN MX 10 mail.naver.com.
mail IN A 192.168.111.100
[root@mail named]# systemctl restart named
[root@mail named]# systemctl enable named
Created symlink /etc/systemd/system/multi-user.target.wants/named.service → /usr/lib/systemd/system/named.service.
[root@mail named]# systemctl status named
● named.service - Berkeley Internet Name Domain (DNS)
Loaded: loaded (/usr/lib/systemd/system/named.service; enabled; vendor prese>
Active: active (running) since Wed 2022-07-27 18:29:40 KST; 16s ago
[root@mail named]# systemctl stop firewalld
[root@mail named]# systemctl disable firewalld
Removed /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@mail named]# nslookup
> server 192.168.111.100
Default server: 192.168.111.100
Address: 192.168.111.100#53
> mail.naver.com
Server: 192.168.111.100
Address: 192.168.111.100#53
Name: mail.naver.com
Address: 192.168.111.100
> mail.daum.net
Server: 192.168.111.100
Address: 192.168.111.100#53
Name: mail.daum.net
Address: 192.168.111.200
> exit
[root@mail named]# vi /etc/sysconfig/network-scripts/ifcfg-ens160
[root@mail named]# vi /etc/resolv.conf
[root@mail named]# reboot
# etc/sysconfig/network-scripts/ifcfg-ens160
DNS1="192.168.111.100"
# etc/resolv.conf
nameserver 192.168.111.100
Client, Server(B), WinClient에서도 각각의 파일을 편집하고 nslookup으로 네임서버 설정을 확인해본다.
- 편집할 파일
Client : etc/resolv.conf
Server(B) : etc/sysconfig/network-scripts/ifcfg-ens160, etc/resolv.conf- WinClient에서 설정하는 방법
PS C:\Windows\system32> netsh interface ip set dns "Ethernet0" static 192.168.111.100
메일 서버를 구현하는 필수 패키지는 sendmail, sendmail-cf, dovecot 이렇게 3가지다.
[root@mail ~]# dnf -y install sendmail-cf dovecot
[root@mail ~]# rpm -qa | grep sendmail
sendmail-8.15.2-31.el8.x86_64
sendmail-cf-8.15.2-31.el8.noarch
[root@mail ~]# rpm -qa dovecot
dovecot-2.2.36-5.el8_0.1.x86_64
[root@mail ~]# vi /etc/mail/sendmail.cf
[root@mail ~]# vi /etc/mail/access
[root@mail ~]# makemap hash /etc/mail/access < /etc/mail/access
[root@mail ~]# vi /etc/dovecot/dovecot.conf
[root@mail ~]# vi /etc/dovecot/conf.d/10-ssl.conf
[root@mail ~]# vi /etc/dovecot/conf.d/10-mail.conf
[root@mail ~]# useradd MailTestNaver
[root@mail ~]# passwd MailTestNaver
[root@mail ~]# systemctl restart sendmail
[root@mail ~]# systemctl enable sendmail
Created symlink /etc/systemd/system/multi-user.target.wants/sendmail.service → /usr/lib/systemd/system/sendmail.service.
Created symlink /etc/systemd/system/multi-user.target.wants/sm-client.service → /usr/lib/systemd/system/sm-client.service.
[root@mail ~]# systemctl restart dovecot
[root@mail ~]# systemctl enable dovecot
Created symlink /etc/systemd/system/multi-user.target.wants/dovecot.service → /usr/lib/systemd/system/dovecot.service.
# etc/mail/sendmail.cf
85 Cwnaver.com
267 O DaemonPortOptions=Port=smtp, Name=MTA
# etc/mail/access
naver.com RELAY
daum.net RELAY
192.168.111 RELAY
# etc/dovecot/dovecot.conf
24 protocols = imap pop3 lmtp
30 listen = *, ::
33 base_dir = /var/run/dovecot/
# etc/dovecot/conf.d/10-ssl.conf
8 ssl = yes
# etc/dovecot/conf.d/10-mail.conf
25 mail_location = mbox:~/mail:INBOX=/var/mail/%u
121 mail_access_groups = mail
166 lock_method = fcntl
앞서 언급한 것처럼 아웃룩 등을 활용한 메일보다 웹에서 메일을 송수신하는 경우가 많기 때문에 메일 서버를 구축할 때 필수적으로 웹 메일을 설치한다.
[root@mail ~]# dnf -y install httpd mariadb-server php php-mysqlnd php-gd php-mbstring php-pecl-zip php-xml php-json php-intl
[root@mail ~]# systemctl restart httpd
[root@mail ~]# systemctl enable httpd
Created symlink /etc/systemd/system/multi-user.target.wants/httpd.service → /usr/lib/systemd/system/httpd.service.
[root@mail ~]# systemctl restart mariadb
[root@mail ~]# systemctl enable mariadb
Created symlink /etc/systemd/system/mysql.service → /usr/lib/systemd/system/mariadb.service.
Created symlink /etc/systemd/system/mysqld.service → /usr/lib/systemd/system/mariadb.service.
Created symlink /etc/systemd/system/multi-user.target.wants/mariadb.service → /usr/lib/systemd/system/mariadb.service.
[root@mail ~]# wget https://github.com/roundcube/roundcubemail/releases/download/1.3.10/roundcubemail-1.3.10-complete.tar.gz
[root@mail ~]# tar xfz roundcubemail-1.3.10-complete.tar.gz
[root@mail ~]# mv roundcubemail-1.3.10 /var/www/html
[root@mail ~]# ln -s /var/www/html/roundcubemail-1.3.10 /var/www/html/roundcube
[root@mail ~]# chmod 777 /var/www/html/roundcube/temp/
[root@mail ~]# chmod 777 /var/www/html/roundcube/logs/
[root@mail ~]# mysql
MariaDB [(none)]> CREATE DATABASE emailDB;
MariaDB [(none)]> GRANT ALL ON emailDB.* TO 'emailAdmin'@'localhost' IDENTIFIED BY '1234';
MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> EXIT
[root@mail ~]# mv /root/다운로드/config.inc.php /var/www/html/roundcube/config/
[root@mail ~]# chmod 707 /var/www/html/roundcube/config/config.inc.php
vi /etc/php.ini
명령어를 통해 아래와 같이 수정하게 되면 500MB까지 업로드가 가능하다.383 max_execution_time = 300
672 post_max_size = 500M
825 upload_max_filesize = 500M
재시작이 후 비로소 웹 메일까지 설치한 메일서버가 구축된 것이다.