qmail install(ft. centos7x)# E-Mail2024. 11. 15. 16:19
Table of Contents
728x90
반응형
설치환경
[root@localhost tcprules.d]# cat /etc/redhat-release
CentOS Linux release 7.9.2009 (Core)
작성일 기준 EOS됨!! 아래와 같이 리포지토리 변경
tee /etc/yum.repos.d/CentOS-Base.repo << EOF
[base]
name=CentOS-$releasever - Base
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra
baseurl=http://vault.centos.org/7.9.2009/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
[updates]
name=CentOS-$releasever - Updates
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates&infra=$infra
baseurl=http://vault.centos.org/7.9.2009/updates/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
[extras]
name=CentOS-$releasever - Extras
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras&infra=$infra
baseurl=http://vault.centos.org/7.9.2009/extras/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
[centosplus]
name=CentOS-$releasever - Plus
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus&infra=$infra
baseurl=http://vault.centos.org/7.9.2009/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
EOF
yum update -y
yum groupinstall "Development Tools" -y
yum install libev-devel openssl-devel zlib-devel -y
yum install mariadb* -y
yum install wget -y
yum install patch -y
yum install telnet -y
yum erase postfix -y
UCSPI-TCP 0.88 설치
cd /var/tmp
wget http://cr.yp.to/ucspi-tcp/ucspi-tcp-0.88.tar.gz
wget http://www.nrg4u.com/qmail/ucspi-tcp-ssl-20050405.patch.gz
tar xfz ucspi-tcp-0.88.tar.gz
cd ucspi-tcp-0.88
zcat ../ucspi-tcp-ssl-20050405.patch.gz | patch
echo "/usr/local" > conf-home
make
make setup check
Daemontools 0.76 설치
cd /var/tmp
wget http://cr.yp.to/daemontools/daemontools-0.76.tar.gz
wget http://qmail.org/moni.csi.hu/pub/glibc-2.3.1/daemontools-0.76.errno.patch
tar xfz daemontools-0.76.tar.gz
cd admin/daemontools-0.76
patch -p1 < ../../daemontools-0.76.errno.patch
echo "/usr/local" > ./src/home
make -C src
mkdir /service /command
for i in `cat package/commands`; do cp -a src/$i /usr/local/bin/$i; done
for i in `cat package/commands`; do ln -sfv /usr/local/bin/$i /command/$i; done
Daemontools 실행
tee /etc/systemd/system/svscan.service << EOF
# /etc/systemd/system/svscan.service
[Unit]
Description=Daemontools svscan Service
After=network.target
[Service]
ExecStart=/command/svscanboot
Restart=always
[Install]
WantedBy=multi-user.target
EOF
sudo systemctl daemon-reload
sudo systemctl start svscan
sudo systemctl enable svscan
sudo systemctl status svscan
[root@localhost ~]# sudo systemctl status svscan
● svscan.service - Daemontools svscan Service
Loaded: loaded (/etc/systemd/system/svscan.service; disabled; vendor preset: disabled)
Active: active (running) since 금 2024-11-15 13:50:29 KST; 4s ago
Main PID: 25405 (svscanboot)
CGroup: /system.slice/svscan.service
├─25405 /bin/sh /command/svscanboot
├─25407 svscan /service
└─25408 readproctitle service errors: ................................................................................................................................
11월 15 13:50:29 localhost.localdomain systemd[1]: Started Daemontools svscan Service.
[root@localhost ~]# ps -ef | grep svs
root 25405 1 0 13:50 ? 00:00:00 /bin/sh /command/svscanboot
root 25407 25405 0 13:50 ? 00:00:00 svscan /service
root 27961 8203 0 13:57 pts/0 00:00:00 grep --color=auto svs
Qmail, Vpopmail에서 사용할 계정과 그룹 생성
groupadd -r nofiles
groupadd -r qmail
groupadd -r vchkpw
useradd -r -M -d /var/qmail/alias -s /sbin/nologin -c "qmail alias" -g qmail alias
useradd -r -M -d /var/qmail -s /sbin/nologin -c "qmail daemon" -g qmail qmaild
useradd -r -M -d /var/qmail -s /sbin/nologin -c "qmail logger" -g qmail qmaill
useradd -r -M -d /var/qmail -s /sbin/nologin -c "qmail passwd" -g qmail qmailp
useradd -r -M -d /var/qmail -s /sbin/nologin -c "qmail queue" -g qmail qmailq
useradd -r -M -d /var/qmail -s /sbin/nologin -c "qmail remote" -g qmail qmailr
useradd -r -M -d /var/qmail -s /sbin/nologin -c "qmail send" -g qmail qmails
useradd -r -M -d /home/vpopmail -s /sbin/nologin -c "Vpopmail User" -g vchkpw vpopmail
mysql
mysql> create database vpopmail;
mysql> CREATE USER 'vpopmail'@'localhost' IDENTIFIED BY 'vpopmail';
mysql> GRANT ALL PRIVILEGES ON vpopmail.* TO 'vpopmail'@'localhost' WITH GRANT OPTION;
mysql> FLUSH PRIVILEGES;
Vpopmail 5.4.30 설치
mkdir -p /var/qmail/bin
touch /var/qmail/bin/qmail-newu
touch /var/qmail/bin/qmail-inject
touch /var/qmail/bin/qmail-newmrh
cd /var/tmp
wget http://downloads.sourceforge.net/project/vpopmail/vpopmail-stable/5.4.30/vpopmail-5.4.30.tar.gz
tar xfz vpopmail-5.4.30.tar.gz
cd vpopmail-5.4.30
./configure \
--prefix=/home/vpopmail \
--enable-vpopuser=vpopmail \
--enable-vpopgroup=vchkpw \
--enable-tcprules-prog=/usr/local/bin/tcprules \
--enable-tcpserver-file=/etc/tcprules.d/tcp.smtp \
--disable-users-big-dir \
--enable-qmail-ext \
--enable-domainquotas \
--enable-logging=v \
--enable-log-name=vpopmail \
--enable-valias \
--disable-many-domains \
--enable-auth-module=mysql \
--enable-incdir=/usr/include/mysql \
--enable-libdir=/usr/lib64/mysql
make
make install-strip
mysql 연동
vi /home/vpopmail/etc/vpopmail.mysql
# 기존
localhost|0|root|secret|vpopmail
# 변경
localhost|0|vpopmail|vpopmail|vpopmail
sed -i 's/^localhost|0|root|secret|vpopmail$/localhost|0|vpopmail|vpopmail|vpopmail/' /home/vpopmail/etc/vpopmail.mysql
Qmail Fake파일 삭제
rm -rf /var/qmail
Libdomainkeys 0.69 설치
cd /var/tmp
wget http://download.sourceforge.net/project/domainkeys/libdomainkeys/0.69/libdomainkeys-0.69.tar.gz
tar xfz libdomainkeys-0.69.tar.gz
mv libdomainkeys-0.69 libdomainkeys
cd libdomainkeys
echo "-lresolv" > dns.lib
make
Knetqmil 1.06 설치
cd /var/tmp
wget http://jeremy.kister.net/code/qmail-dk-0.54-auth.patch
tar xfz knetqmail-1.06-20110908.tar.gz
cd knetqmail-1.06-20110908
patch -p0 < ../qmail-dk-0.54-auth.patch
echo "gcc -O2 -g -DTLS=20070408 -I/usr/include/openssl -I/home/vpopmail/include" > conf-cc
echo "gcc -s -O2 -g" > conf-ld
make
make setup check
cp -a spfquery /var/qmail/bin
cp -a /var/tmp/libdomainkeys/dknewkey /var/qmail/bin
chown root:qmail /var/qmail/bin/spfquery /var/qmail/bin/dknewkey
chmod 755 /var/qmail/bin/spfquery /var/qmail/bin/dknewkey
설정파일
cd /var/qmail/control
touch rcpthosts smtproutes
echo "localhost" > locals
echo "example.com" > me
echo "example.com" > defaultdomain
echo "example.com" > defaulthost
echo "example.com" > plusdomain
echo "60" > concurrencyremote
echo "100" > concurrencyincoming
echo "86400" > queuelifetime
echo "1" > spfbehavior
echo "Welcome to Qmail SMTP Server" > smtpgreeting
echo "./Maildir/" > defaultdelivery
chmod 644 *
cd /var/qmail/users
touch cdb
echo "." > assign
chmod 644 *
Qmail Daemon을 위한 디렉터리 및 스크립트 생성
mkdir -p /var/qmail/supervise
for i in send smtp pop3 submission; do mkdir -p /var/qmail/supervise/$i/log; done
tee /var/qmail/rc << EOF
#!/bin/sh
exec env - PATH="/var/qmail/bin:$PATH" \
qmail-start "`cat /var/qmail/control/defaultdelivery`"
EOF
tee /var/qmail/supervise/send/run << EOF
#!/bin/sh
exec /var/qmail/rc
EOF
tee /var/qmail/supervise/send/log/run << EOF
#!/bin/sh
exec /usr/local/bin/setuidgid qmaill \
/usr/local/bin/multilog t /var/log/qmail/send 2>&1
EOF
tee /var/qmail/supervise/smtp/run << EOF
#!/bin/sh
VPOP_UID=`id -u vpopmail`
VPOP_GID=`id -g vpopmail`
MAXSMTPD=`cat /var/qmail/control/concurrencyincoming`
exec /usr/local/bin/softlimit -m 96000000 \
/usr/local/bin/tcpserver -vRHl0 \
-x /etc/tcprules.d/tcp.smtp.cdb \
-u ${VPOP_UID} -g ${VPOP_GID} 0 25 \
/var/qmail/bin/qmail-smtpd \
/home/vpopmail/bin/vchkpw /bin/true 2>&1
EOF
tee /var/qmail/supervise/smtp/log/run << EOF
#!/bin/sh
exec /usr/local/bin/setuidgid qmaill \
/usr/local/bin/multilog t /var/log/qmail/smtp 2>&1
EOF
tee /var/qmail/supervise/pop3/run << EOF
#!/bin/sh
VPOP_UID=`id -u vpopmail`
VPOP_GID=`id -g vpopmail`
HOSTNAME=`hostname -f`
exec /usr/local/bin/softlimit -m 96000000 \
/usr/local/bin/tcpserver -vRHl0 \
-u ${VPOP_UID} -g ${VPOP_GID} 0 110 \
/var/qmail/bin/qmail-popup ${HOSTNAME} \
/home/vpopmail/bin/vchkpw \
/var/qmail/bin/qmail-pop3d Maildir 2>&1
EOF
tee /var/qmail/supervise/pop3/log/run << EOF
#!/bin/sh
exec /usr/local/bin/setuidgid qmaill \
/usr/local/bin/multilog t /var/log/qmail/pop3 2>&1
EOF
tee /var/qmail/supervise/submission/run << EOF
#!/bin/sh
VPOP_UID=`id -u vpopmail`
VPOP_GID=`id -g vpopmail`
MAXSMTPD=`cat /var/qmail/control/concurrencyincoming`
exec /usr/local/bin/softlimit -m 96000000 \
/usr/local/bin/tcpserver -vRHl0 \
-x /etc/tcprules.d/tcp.smtp.cdb \
-c ${MAXSMTPD} \
-u ${VPOP_UID} -g ${VPOP_GID} 0 587 \
/var/qmail/bin/qmail-smtpd \
/home/vpopmail/bin/vchkpw /bin/true 2>&1
EOF
tee /var/qmail/supervise/submission/log/run << EOF
#!/bin/sh
exec /usr/local/bin/setuidgid qmaill \
/usr/local/bin/multilog t /var/log/qmail/submission 2>&1
EOF
chmod 755 /var/qmail/rc
chown root:qmail /var/qmail/rc
chmod 700 /var/qmail/supervise
chown -R qmaill:qmail /var/qmail/supervise
for i in send smtp pop3 submission; do chmod 1700 /var/qmail/supervise/$i; done
for i in send smtp pop3 submission; do chmod 700 /var/qmail/supervise/$i/log; done
for i in send smtp pop3 submission; do chmod 751 /var/qmail/supervise/$i/run; done
for i in send smtp pop3 submission; do chmod 751 /var/qmail/supervise/$i/log/run; done
tcp smtp설정
mkdir -p /etc/tcprules.d
tee /etc/tcprules.d/tcp.smtp << EOF
127.0.0.1:allow,RELAYCLIENT="",CHKUSER_RCPTLIMIT="50",CHKUSER_WRONGRCPTLIMIT="10"
:allow,CHKUSER_RCPTLIMIT="50",CHKUSER_WRONGRCPTLIMIT="10"
EOF
tcprules /etc/tcprules.d/tcp.smtp.cdb /etc/tcprules.d/tcp.smtp.tmp < /etc/tcprules.d/tcp.smtp
Qmail Log 디렉터리 생성
for i in send smtp pop3 submission; do mkdir -p /var/log/qmail/$i; done
chmod -R 750 /var/log/qmail
chown -R qmaill:qmail /var/log/qmail
구동스크립트
vi /etc/init.d/qmaild
#!/bin/sh
#
# qmaild This shell script takes care of starting and stopping
# the qmail system.
#
# chkconfig: - 30 80
# description: qmail is a small, fast, secure replacement for the sendmail package, which is
# the program that actually receives, routes, and delivers electronic mail.
export PATH="$PATH:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/var/qmail/bin"
svclist="send smtp pop3 submission"
case "$1" in
start)
echo "Starting qmail"
for svc in $svclist; do
if [ -e /service/${svc} ]; then
if svok /service/${svc}; then
svc -u /service/${svc}
else
echo "${svc} supervise not running"
fi
else
ln -s /var/qmail/supervise/${svc} /service/
fi
done
if [ -d /var/lock/subsys ]; then
touch /var/lock/subsys/qmail
fi
;;
stop)
echo "Stopping qmail..."
for svc in $svclist; do
if [ -e /service/${svc} ]; then
echo " ${svc}"
svc -dx /service/${svc} /service/${svc}/log
rm -f /service/${svc}
fi
done
if [ -f /var/lock/subsys/qmail ]; then
rm -f /var/lock/subsys/qmail
fi
;;
stat)
for svc in $svclist; do
if [ -e /service/${svc} ]; then
svstat /service/${svc}
svstat /service/${svc}/log
fi
done
qmail-qstat
;;
doqueue|alrm|flush)
if [ -e /service/send ]; then
echo "Flushing timeout table and sending ALRM signal to send."
/var/qmail/bin/qmail-tcpok
svc -a /service/send
fi
;;
queue)
qmail-qstat
qmail-qread
;;
reload|hup)
if [ -e /service/send ]; then
echo "Sending HUP signal to send."
svc -h /service/send
fi
;;
pause)
for svc in $svclist; do
if [ -e /service/${svc} ]; then
echo "Pausing ${svc}"
svc -p /service/${svc}
fi
done
;;
cont)
for svc in $svclist; do
if [ -e /service/${svc} ]; then
echo "Continuing ${svc}"
svc -c /service/${svc}
fi
done
;;
restart)
echo "Restarting qmail:"
for svc in $svclist; do
if [ -e /service/${svc} ]; then
if [ "${svc}" != "send" ]; then
echo "* Stopping ${svc}."
svc -d /service/${svc}
fi
fi
done
if [ -e /service/send ]; then
echo "* Sending send SIGTERM and restarting."
svc -t /service/send
fi
for svc in $svclist; do
if [ -e /service/${svc} ]; then
if [ "${svc}" != "send" ]; then
echo "* Restarting ${svc}."
svc -u /service/${svc}
fi
fi
done
;;
cdb)
if [ -z "`grep '\#define POP_AUTH_OPEN_RELAY 1' /home/vpopmail/include/config.h 2>/dev/null`" ]; then
tcprules /etc/tcprules.d/tcp.smtp.cdb /etc/tcprules.d/tcp.smtp.tmp < /etc/tcprules.d/tcp.smtp
else
/home/vpopmail/bin/clearopensmtp
fi
echo "Reloaded /etc/tcprules.d/tcp.smtp."
;;
*)
echo "Usage: $0 {start|stop|restart|doqueue|flush|reload|stat|pause|cont|cdb|queue}"
exit 1
;;
esac
exit 0
chmod 755 /etc/init.d/qmaild
chkconfig --add qmaild
chkconfig --level 345 qmaild
구동
[root@localhost tcprules.d]# /etc/init.d/qmaild start
Starting qmail
[root@localhost tcprules.d]# /etc/init.d/qmaild stat
/service/send: up (pid 23991) 1 seconds
/service/send/log: up (pid 23988) 1 seconds
/service/smtp: up (pid 23989) 1 seconds
/service/smtp/log: up (pid 23995) 1 seconds
/service/pop3: up (pid 23990) 1 seconds
/service/pop3/log: up (pid 23992) 1 seconds
/service/submission: up (pid 24006) 0 seconds
/service/submission/log: up (pid 23993) 1 seconds
messages in queue: 0
messages in queue but not yet preprocessed: 0
[root@localhost tcprules.d]# netstat -nl
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 0.0.0.0:110 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:25 0.0.0.0:* LISTEN
tcp6 0 0 :::22 :::* LISTEN
udp 0 0 0.0.0.0:68 0.0.0.0:*
udp 0 0 127.0.0.1:323 0.0.0.0:*
udp6 0 0 ::1:323 :::*
raw6 0 0 :::58 :::* 7
Active UNIX domain sockets (only servers)
Proto RefCnt Flags Type State I-Node Path
unix 2 [ ACC ] SEQPACKET LISTENING 778 /run/udev/control
unix 2 [ ACC ] STREAM LISTENING 786 /run/lvm/lvmetad.socket
unix 2 [ ACC ] STREAM LISTENING 19769 /var/run/vmware/guestServicePipe
unix 2 [ ACC ] STREAM LISTENING 20825 /var/run/NetworkManager/private-dhcp
unix 2 [ ACC ] STREAM LISTENING 700 /run/systemd/private
unix 2 [ ACC ] STREAM LISTENING 18885 /run/dbus/system_bus_socket
unix 2 [ ACC ] STREAM LISTENING 10708 /run/systemd/journal/stdout
unix 2 [ ACC ] STREAM LISTENING 754 /run/lvm/lvmpolld.socket
[root@localhost tcprules.d]# telnet localhost 25
Trying ::1...
telnet: connect to address ::1: Connection refused
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
220 Welcome to Qmail SMTP Server ESMTP
728x90
반응형
'# E-Mail' 카테고리의 다른 글
mailcow install(ft. docker) (0) | 2024.03.28 |
---|---|
550-5.7.1 is: duplicate To headers (0) | 2022.12.06 |
550-5.7.1 Messages missing a valid messageId header are not (0) | 2022.10.27 |
curl이용 imap 및 pop3 접속체크 (0) | 2022.09.23 |
curl smtp command (0) | 2022.09.23 |
@다크쉐라빔 :: 다크쉐라빔의 주절주절
안녕하세요. 이곳은 IT위주의 잡다한 정보를 올려두는 개인 블로그입니다.
포스팅이 좋았다면 "좋아요❤️" 또는 "구독👍🏻" 해주세요!