Ethsim2
(Ethan )
7์ 23, 2025, 12:51์คํ
1
Email receive issue ์์์ ํ ๋ก ์ ์ด์ด์ ๋ง์๋๋ฆฝ๋๋ค:
postfix/valid_recipients๋ฅผ ํตํด valid_recipients ํํฐ๋ง์ ๊ตฌํํ๊ณ /etc/postfix/valid_recipients ํ์ผ์ ์ฑ์ ์ต๋๋ค. ์ดํ ์ฝ 6๋ถ๋ง๋ค ๋ฐ๋ณต๋๋ ๊ฒฝ๊ณ ์ ์์ ์ฐ๊ฒฐ ์๋๊ฐ ๋ฐ์ํ๊ณ ์์ต๋๋ค. ๋ค์์ ๋ก๊ทธ์ ์ผ๋ถ(๊ฐ์ธ์ ๋ณด ๋น๊ณต๊ฐ ์ฒ๋ฆฌ๋จ)์
๋๋ค.
์ ํํ ๋ก๊ทธ ์ถ๋ ฅ ๋ด์ฉ
Jul 23 05:13:40 ubuntu-mail-receiver postfix/smtpd[2265]: warning: /etc/postfix/valid_recipients, line 1: expected format: key whitespace value -- ignoring this line
Jul 23 05:13:40 ubuntu-mail-receiver postfix/smtpd[2265]: warning: /etc/postfix/valid_recipients, line 2: expected format: key whitespace value -- ignoring this line
...
Jul 23 05:13:40 ubuntu-mail-receiver postfix/smtpd[2265]: warning: /etc/postfix/valid_recipients, line 16: expected format: key whitespace value -- ignoring this line
์ด๋ฌํ ๊ฒฝ๊ณ ๋ ์ธ์ฆ๋์ง ์์ ์ฐ๊ฒฐ ์๋์ ์ผ์นํ์ฌ ๋ช ๋ถ๋ง๋ค ๋ํ๋ฉ๋๋ค. ์์:
Jul 23 05:13:40 ubuntu-mail-receiver postfix/smtpd[2265]: warning: hostname unassigned.quadranet.com does not resolve to address 198.55.98.3
Jul 23 05:13:40 ubuntu-mail-receiver postfix/smtpd[2265]: connect from unknown[198.55.98.3]
Jul 23 05:13:40 ubuntu-mail-receiver postfix/smtpd[2265]: disconnect from unknown[198.55.98.3] ehlo=1 auth=0/1 quit=1 commands=2/3
์ด ๋์ผํ ํจํด์ด 1์๊ฐ ๋์ ์์ญ ๋ฒ์ ์ฌ์ดํด์ ๊ฑธ์ณ 198.55.98.3์์ ๋ฐ๋ณต๋๊ณ ์์ต๋๋ค.
legitimateํ ๋ฉ์ผ์ ์ ์ ํต๊ณผ
์ฐธ๊ณ ๋ก, legitimateํ ์ ๋ฌ(์: Microsoft 365์์ ์จ ๋ฉ์ผ)์ ์ ์์ ์ผ๋ก ์๋ํ๊ณ ์์ต๋๋ค:
Jul 23 05:46:53 ubuntu-mail-receiver postfix/smtpd[2290]: connect from mail-uksouthazon11020141.outbound.protection.outlook.com[52.101.196.141]
Jul 23 05:46:54 opendkim[25]: D3D4A1BF983: DKIM verification successful
Jul 23 05:46:54 opendmarc[40]: D3D4A1BF983: MYDOMAINNAME.com pass
Jul 23 05:46:54 ubuntu-mail-receiver postfix/pipe[2296]: to=<person.REDACTED@discourse.MYDOMAINNAME.com>, relay=discourse, status=sent (delivered via discourse service)
์ง๋ฌธ
/etc/postfix/valid_recipients ๊ฒฝ๊ณ ๊ฐ ๋ฐ๋ณต์ ์ธ ์ฐ๊ฒฐ์ ์ ๋ฐํ๋ ์์ธ์ด ๋ ์ ์๋์?
ํ์ผ ํ์์ด ์๋ชป๋์์ ๊ฒฝ์ฐ Postfix๊ฐ ํด๋น ํญ๋ชฉ์์ ๋ฃจํ๋ฅผ ๋๋ฆด ๊ฒ์ผ๋ก ์์ํด์ผ ํ๋์?
์์ ์ฑ์ ํ
์คํธํ๊ธฐ ์ํด check_recipient_access๋ฅผ ์ผ์์ ์ผ๋ก ๋นํ์ฑํํ๋ ๊ฒ์ ๊ถ์ฅํ์๋์?
Discourse์ mail-receiver ์ปจํ
์ด๋์ ํจ๊ป ์ฌ์ฉ๋๋ valid_recipients ํ์ผ์ ๊ถ์ฅ ์์๊ฐ ์์๊น์?
์ main.cf ๋ผ์ธ (์ฐธ๊ณ ์ฉ)
smtpd_recipient_restrictions = check_recipient_access hash:/etc/postfix/valid_recipients, reject
์ฌ๊ธฐ์ ์กฐ์ธ์ ์ ๋ง๋ก ๋ฃ๊ณ ์ถ์ต๋๋ค. ๋ฏธ๋ฆฌ ๊ฐ์ฌํฉ๋๋ค!
Ethsim2
(Ethan )
7์ 23, 2025, 1:42์คํ
2
Discourse์์ Postfix๋ฅผ ๋ค์ ๋ก๋ํ๋ ๋ฐฉ๋ฒ
AI
Ethsim2:
Continuing the discussion from Email receive issue :
I implemented valid_recipients filtering via postfix/valid_recipients and populated /etc/postfix/valid_recipients. Since then, Iโm seeing repeated warnings and inbound connection attempts every ~6 minutes. Hereโs a sanitized segment of my log.
Exact log output
Jul 23 05:13:40 ubuntu-mail-receiver postfix/smtpd[2265]: warning: /etc/postfix/valid_recipients, line 1: expected format: key whitespace value -- ignoring this line
Jul 23 0โฆ
main.cf๋ฅผ ์์ ํ ๊ฒ์ด ๋ง๋์?
DiscourseHelper:
๊ฒ์ ์ค
๊ฒ์ ๋ด์ฉ: Discourse ๋ฉ์ผ ์์ ๊ธฐ ์ปจํ
์ด๋์์ ์์ ์ ์ ํ์ ์ํด valid_recipients ํ์ผ์ ๊ตฌํํ ๋ postfix main.cf๋ฅผ ์๋์ผ๋ก ์์ ํ๋ ๊ฒ์ด ํ์ํ๊ฑฐ๋ ๊ถ์ฅ๋๋์? main.cf๋ฅผ ์ง์ ํธ์งํด์ผ ํ๋์, ์๋๋ฉด Discourse ๋ฉ์ผ ์์ ๊ธฐ ์ค์ ์ ๊ฒฝ์ฐ ๋ชจ๋ ๊ถ์ฅ ๋ณ๊ฒฝ ์ฌํญ์ด docker ํ๊ฒฝ ๋ณ์๋ launcher yml ์ค์ ์ ํตํด ์ฒ๋ฆฌ๋๋์?
์ฝ๊ธฐ ์ค
์ฝ์ ๋ด์ฉ: ๐ฌ valid_recipients ๊ตฌํ ํ ๋ฐ๋ณต๋๋ Postfix ๊ฒฝ๊ณ ๋ฐ ์ฐ๊ฒฐ
์๋์, Discourse์ ํ์ค ์ค์ ์ ๋ฐ๋ฅด๋ ๊ฒฝ์ฐ ์ ํจํ ์์ ์ ํํฐ๋ง์ ์ํด ๋ฉ์ผ ์์ ๊ธฐ ์ปจํ
์ด๋์์ main.cf๋ฅผ ์๋์ผ๋ก ์์ ํ๋ ๊ฒ์ ํ์ํ์ง๋ ๊ถ์ฅ๋์ง๋ ์์ต๋๋ค.
์ฌ๋ฐ๋ฅธ ๋ฐฉ๋ฒ:
Discourse์ ๊ณต์ ๋ฉ์ผ ์์ ๊ธฐ ๊ฐ์ด๋ ๋ฐ ์ปจํ
์ด๋ ์ค์ ์ main.cf๋ฅผ ์๋์ผ๋ก ํธ์งํ์ง ์๋๋ก ์ค๊ณ๋์ด ์์ต๋๋ค. ๋์ ๋ค์๊ณผ ๊ฐ์ด ํ์ธ์:
mail-receiver.yml์ env ์น์
์ ์ฌ์ฉํ์ฌ Postfix ๋งค๊ฐ๋ณ์๋ฅผ ์ค์ ํด์ผ ํฉ๋๋ค. ๊ตฌ์ฒด์ ์ผ๋ก, ๋ค์๊ณผ ๊ฐ์ ํ๊ฒฝ ๋ณ์๋ฅผ ์ฌ์ฉํฉ๋๋ค:
POSTCONF_smtpd_recipient_restrictions: texthash:/etc/postfix/valid_recipients
๋๋, ๊ตฌํ ์ค์ ์คํ์ผ์ ์ฌ์ฉํ๋ ๊ฒฝ์ฐ:
POSTCONF_smtpd_recipient_restrictions: check_recipient_access hash:/etc/postfix/valid_recipients, reject
Docker/launcher๋ ์ปจํ
์ด๋ ์์ ์ ์ด๋ฌํ ์ค์ ์ ์ฌ๋ฐ๋ฅด๊ฒ ์ ์ฉํ์ฌ ํ์ผ์ ์ง์ ํธ์งํ ํ์ ์์ด Postfix์ ์ฃผ์
ํฉ๋๋ค.
main.cf๋ฅผ ์ง์ ํธ์งํ๋ฉด ์ถฉ๋์ด ๋ฐ์ํ๊ฑฐ๋ ์ปจํ
์ด๋ ์ฌ๋น๋ ์ ๋ฎ์ด์ฐ๊ธฐ๋ ์ ์์ต๋๋ค. ๋ํ ์ด ๋ฐฉ์์ผ๋ก ํ์ผ ํ์์ด๋ ์์ ์ ๋งคํ ๋ฑ์ ์ฝ๊ฒ ๊นจ๋จ๋ฆด ์ ์์ต๋๋ค.
์ค๋ฅ์ ๋ํด:
ํ์ธํ๋ ๊ฒฝ๊ณ :
warning: /etc/postfix/valid_recipients, line 1: expected format: key whitespace value -- ignoring this line
์ valid_recipients ํ์ผ์ ํ์์ด ์๋ชป๋์๊ธฐ ๋๋ฌธ์ ๋ฐ์ํ๋ ๊ฒ์ด์ง, ์ค์ ๋ฐฉ์(ํ๊ฒฝ ๋ณ์ ๋ main.cf) ๋๋ฌธ์ด ์๋๋๋ค. ํญ๋ชฉ์ด ๋ค์๊ณผ ๊ฐ์ ํ์์ธ์ง ํ์ธํ์ธ์:
alloweduser@yourdomain.com OK
another@yourdomain.com OK
default REJECT
์ฝ๋ก , ๋ฑํธ, ์ผํ๋ ์ฌ์ฉํ์ง ๋ง์ธ์โ์ฃผ์, ๊ณต๋ฐฑ, ๊ทธ๋ฆฌ๊ณ OK(๋๋ REJECT)๋ง ์์ผ๋ฉด ๋ฉ๋๋ค.
main.cf๋ฅผ ํธ์งํ์ง ๋ง์ญ์์ค. ๋งค์ฐ ๊ณ ๊ธ์ค๋ฝ๊ณ ์์ ํ ์ฌ์ฉ์ ์ ์๋ ๊ตฌ์ฑ์ ๊ฐ์ง๊ณ ์๊ณ ์ ํํ ๋ฌด์์ ํ๋์ง ์ดํดํ๋ ๊ฒฝ์ฐ๊ฐ ์๋๋ผ๋ฉด.
๋ชจ๋ ์ผ๋ฐ์ ์ธ ์ง์นจ(์ ํจํ ์์ ์ ๋ฐ ๋ฐ์ ์ ํํฐ๋ง ํฌํจ)์ mail-receiver.yml์์ ํ๊ฒฝ ๋ณ์๋ฅผ ์ค์ ํ์ฌ ์ํ๋ฉ๋๋ค.
์ฐธ๊ณ ์๋ฃ:
์์ฝ:
ํ์ค Discourse ๋ฉ์ผ ์์ ๊ธฐ ์ค์ ์ ๊ฒฝ์ฐ main.cf๋ฅผ ๊ฑด๋๋ฆด ํ์๊ฐ ์์ต๋๋ค. yml ํ์ผ์ ํ๊ฒฝ ๋ณ์๊ฐ ๊ถ์ฅ๋๊ณ ์ง์๋๋ ๋ฐฉ๋ฒ์
๋๋ค. ์์ ์ ๋งต์ ๊ฒฝ์ฐ ํญ์ ์ ์ ํ hash/texthash ํ์๊ณผ ์ฌ๋ฐ๋ฅธ ํ์ผ ๊ตฌ๋ฌธ์ ์ฌ์ฉํ์ธ์.
์ค์ ๋ก ์ ๋ ์ฌ์ฉ์ ์ ์ ๊ตฌ์ฑ์ ์์ ํ ์ ๊ฑฐํ๊ณ , ์ฌ๊ธฐ ์ ์ค๋ช
๋ ๊ตฌ์ฑ์ ์ฌ์ฉํ์ผ๋ฉฐ, ์ ๋ฉ์ผ ํ
์คํธ๋ ์ ์๋ํ์ต๋๋ค.
x86_64 arch detected.
Ensuring launcher is up to date
Fetching origin
Launcher is up-to-date
Stopping old container
+ /usr/bin/docker stop -t 600 mail-receiver
mail-receiver
release: Pulling from discourse/mail-receiver
Digest: sha256:2a0d45bb92a783c846a821e635413764eeadb3441ef6190085545a4[9 digits redacted]
Status: Image is up to date for discourse/mail-receiver:release
docker.io/discourse/mail-receiver:release
ERROR: Can't find Ruby library file or shared library pups
cd /pups && /pups/bin/pups --stdin
/bin/bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
sha256:[6 digits redacted]69734d779a95ec83c7103dc2fc04f1d690ebde62[18 digits redacted]
[64 character API Key? Redacted]
Removing old container
+ /usr/bin/docker rm mail-receiver
mail-receiver
+ /usr/bin/docker run --shm-size=512m -d --restart=always -e LANG=en_US.UTF-8 -e LC_ALL=en_US.UTF-8 -e LANGUAGE=en_US.UTF-8 -e MAIL_DOMAIN=discourse. MYDOMAINNAME.com -e DISCOURSE_BASE_URL=https:// MYDOMAINNAME.com -e DISCOURSE_API_KEY=[64 digit API key redacted] -e DISCOURSE_API_USERNAME=system -h ubuntu-mail-receiver -e DOCKER_HOST_IP=172.17.0.1 --name mail-receiver -t -p 25:25 -v /var/discourse/shared/mail-receiver/postfix-spool:/var/spool/postfix --mac-address [redacacted mac address] local_discourse/mail-receiver /sbin/boot
[64 digit API key? Redacted]
root@ubuntu:/var/discourse# ./launcher logs mail-receiver
x86_64 arch detected.
/bin/bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
Operating environment:
HOSTNAME=ubuntu-mail-receiver
LANGUAGE=en_US.UTF-8
MAIL_DOMAIN=discourse.MYDOMAINNAME.com
DOCKER_HOST_IP=172.17.0.1
PWD=/
DISCOURSE_BASE_URL=https:// MYDOMAINNAME.com
HOME=/root
LANG=en_US.UTF-8
TERM=xterm
SHLVL=1
DISCOURSE_API_USERNAME=system
LC_ALL=en_US.UTF-8
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
INCLUDE_DMARC=true
DISCOURSE_API_KEY=[64 digit API key redacted]
_=/usr/bin/env
Delivering mail sent to discourse. MYDOMAINNAME.com to Discourse
Starting OpenDKIM...
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = "en_US.UTF-8",
LC_ALL = "en_US.UTF-8",
LANG = "en_US.UTF-8"
are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
Adding user `postfix' to group `opendkim' ...
<86>Jul 23 13:27:19 usermod[16]: add 'postfix' to group 'opendkim'<86>Jul 23 13:27:19 usermod[16]: add 'postfix' to shadow group 'opendkim'Done.
Starting OpenDMARC...
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = "en_US.UTF-8",
LC_ALL = "en_US.UTF-8",
LANG = "en_US.UTF-8"
are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
<22>Jul 23 13:27:19 opendkim[24]: OpenDKIM Filter v2.11.0 starting (args: -x /etc/opendkim.conf)Adding user `postfix' to group `opendmarc' ...
<86>Jul 23 13:27:19 usermod[31]: add 'postfix' to group 'opendmarc'<86>Jul 23 13:27:19 usermod[31]: add 'postfix' to shadow group 'opendmarc'Done.
<22>Jul 23 13:27:19 opendmarc[39]: OpenDMARC Filter v1.4.2 starting (args: -c /etc/opendmarc.conf)<22>Jul 23 13:27:19 opendmarc[39]: additional trusted authentication services: (none)postfix: Postfix is using backwards-compatible default settings
Jul 23 13:27:19 ubuntu-mail-receiver postfix[51]: Postfix is using backwards-compatible default settings
postfix: See http://www.postfix.org/COMPATIBILITY_README.html for details
Jul 23 13:27:19 ubuntu-mail-receiver postfix[51]: See http://www.postfix.org/COMPATIBILITY_README.html for details
postfix: To disable backwards compatibility use "postconf compatibility_level=3.6" and "postfix reload"
Jul 23 13:27:19 ubuntu-mail-receiver postfix[51]: To disable backwards compatibility use "postconf compatibility_level=3.6" and "postfix reload"
Starting Postfix
Jul 23 13:27:19 ubuntu-mail-receiver postfix/master[1]: daemon started -- version 3.7.11, configuration /etc/postfix
Jul 23 13:27:53 ubuntu-mail-receiver postfix/smtpd[122]: connect from mail-il1-f180.google.com[209.85.166.180]
<22>Jul 23 13:27:54 policyd-spf[129]: : prepend Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=209.85.166.180; helo=mail-il1-f180.google.com; envelope-from= person@gmail.com; receiver=discourse. MYDOMAINNAME.com Jul 23 13:27:54 ubuntu-mail-receiver postfix/smtpd[122]: BC6D71BF9C8: client=mail-il1-f180.google.com[209.85.166.180]
Jul 23 13:27:54 ubuntu-mail-receiver postfix/cleanup[130]: BC6D71BF9C8: message-id=<CWXP1[redacted 8 digits]81B627937FA7F4B2CE65A15FA@CWXP123MB2918.GBRP123.PROD.OUTLOOK.COM>
<22>Jul 23 13:27:55 opendkim[24]: BC6D71BF9C8: DKIM verification successful<22>Jul 23 13:27:55 opendkim[24]: BC6D71BF9C8: s=20230601 d=gmail.com a=rsa-sha256 SSL <22>Jul 23 13:27:55 opendmarc[39]: implicit authentication service: ubuntu-mail-receiver.localdomain<22>Jul 23 13:27:55 opendmarc[39]: BC6D71BF9C8: gmail.com passJul 23 13:27:55 ubuntu-mail-receiver postfix/qmgr[120]: BC6D71BF9C8: from=<person@gmail.com>, size=75533, nrcpt=1 (queue active)
Jul 23 13:27:55 ubuntu-mail-receiver postfix/smtpd[122]: disconnect from mail-il1-f180.google.com[209.85.166.180] ehlo=1 mail=1 rcpt=1 bdat=2 quit=1 commands=6
<23>Jul 23 13:27:55 receive-mail[133]: Recipient: person.REDACTED@discourse. MYDOMAINNAME.comJul 23 13:27:55 ubuntu-mail-receiver postfix/pipe[132]: BC6D71BF9C8: to=< person.REDACTED@discourse. MYDOMAINNAME.com>, relay=discourse, delay=1.8, delays=1.6/0.01/0/0.22, dsn=2.0.0, status=sent (delivered via discourse service)
Jul 23 13:27:55 ubuntu-mail-receiver postfix/qmgr[120]: BC6D71BF9C8: removed
Ethsim2
(Ethan )
7์ 23, 2025, 4:31์คํ
3
์ด์ ๋ด ํฌ๋ผ์์ ์ด๋ฉ์ผ๋ก ๋ต์ฅํ๋ ๊ธฐ๋ฅ์ด ์ ์ ์๋ํฉ๋๋ค. ์ด์ ์ legacy valid_recipients ๊ธฐ๋ฅ์ด์๋ค๋ฉด ์ด ๊ธฐ๋ฅ์ด ์ฐจ๋จ๋์์ ๊ฒ์
๋๋ค.