Простейший relay на Postfix для Exchange Server

Развернуть простейший relay на Postfix ничуть не сложнее, чем установить сам Postfix. Настройка тоже не представляется чем-то сверхсложным, ведь речь идет об узле, главной задачей которого будет только перенаправление входящей почты. Задачи фильтрации спама и вирусов я планирую рассмотреть в последующих статьях серии.


Если вам интересна тематика почтовых сервисов, рекомендую обратиться к рубрике Unix Mail на моем блоге.


Простейший relay на Postfix

Главная задача этой статьи — рассказать о первом этапе настройки почтового релэя — когда нужно осуществлять только пересылку входящей почты на внутренний сервер и обратно, проверяя при этом факт существования пользователя в организации.

В качестве бэкэнда будет выступать Exchange Server 2016 в связке с Active Directory, как наиболее распространенный и совершенный корпоративный почтовый сервис, но, к удивительному сожалению, не имеющий собственного продвинутого антиспама.

Подготовка

Начинать развертывание любого почтового сервера (даже релэя), нужно с покупки домена и создания необходимых DNS-записей. Конечно если почта в вашей организации уже есть, этот этап вы уверенно пропускаете. А всем остальным я советую создать у вашего регистратора записи A, MX и TXT, а также PTR — у провайдера интернет (или поставщика выделенных серверов, которые идут вместе с публичными адресами).

Примечание: у кого нет четкого понимания каким образом нужно создавать записи, что в них должно быть прописано и что об этом процессе утверждают лучше практики, советую обратиться к моей статье Базовые DNS-записи для почтового сервера.

Если нужна помощь — обращайтесь в комментариях.

Настройка Exchange

По умолчанию Exchange не имеет соединителей отправки, то есть отправить почту в интернет не сможет (но локальным получателем вполне). Обычно админы создают соединитель с областью, обозначенной знаком * (означает все существующие домены), а значит вся исходящая почта наружу идет именно через этот соединитель.

Итого, чтобы заставить всю почту идти наружу через наш релэй, в большинстве случаев надо всего лишь прописать промежуточный узел для этого соединителя:

Через powershell это сделать ещё проще (адрес 172.16.0.64, как вы догадались, принадлежит релэю Postfix):

Этот шаг лучше выполнить уже после полной настройки Postfix (чтобы не было простоя сервиса), но мне важно показать как работает релэй с уже настроенным Exchange, поэтому я сделаю это сейчас (мне можно, я ведь делаю это на лабе).

Установка Postfix

Postfix доступен из стандартных репозиториев как на Debian, так и на CentOS, оттуда и советую его ставить.

Конфигурация по умолчанию нам не подходит, а потому нужно будет кое-что подкрутить и об этом вы сможете прочитать в статье Установка Postfix на Debian.

Забегая вперед скажу, что нам понадобится ещё один пакет, установим его командой:

На этом все, можно двигаться дальше.

Базовая настройка

Мой домен, купленный специально для этого цикла статей — bq-srv.ru, на его примере и разберем конфигурацию. Если вы пропустили раздел Подготовка выше, то продублирую ещё раз основную мысль. Основная и обязательная часть настройки Postfix — это указание следующих параметров:

  • mydomain — публичное имя вашего почтового сервиса;
  • myhostname — имя хоста;
  • mydestination — список DNS-имен, которые обслуживает данный почтовый сервер (для которых он будет принимать почту).

Поскольку мы говорим о почтовом релее, для него также важны следующие опции:

  • relay_domains — список доменов, для которых сервер пересылает почту;
  • mynetworks — список доверенных сетей или хостов, которые обычно имеют более высокие привилегии. Например по умолчанию в ограниченияхsmtpd_relay_restrictions указан ключ permit_mynetworks, а это значит, что всем хостам в mynetworks разрешена пересылка сообщений через сервер;
  • transport_maps — транспортная карта, по которой сервер будет определять почту для каких доменов (или получателей) куда отправлять.

Итак, резюмируя сказанное, нужно добавить (или изменить существующие) в конфиг следующие параметры:

172.16.0.20 — адрес сервера Exchange.

Файл /etc/postfix/conf.d/transport имеет содержимое:

После его создания и заполнения не забудьте выполнить команду и перечитать конфиг Postfix:

А теперь проверим как все работает.

Итак, с любого внешнего почтового сервиса попробуем отправить почту на несуществующий ящик Exchange (здесь и далее логи немного сокращены для наглядности):

Как видно, Postfix успешно принимает почту на адрес tratata@bq-srv.ru и отправляет на Exchange. Но такого ящика в организации не существует и эксч отправляет отчет о недоставке через Postfix:

А отправителю приходит сообщение:

Можно сделать вывод, что наш релэй выполняет двойную работу — перенаправляет почту сначала на эксч, а потом от него. Кроме того, лишняя нагрузка ложится ещё и на сам Exchange. В принципе все можно оставить как есть, ведь работает, но лучше все же прикрутить проверку получателей.

Расширенная настройка

Необходимо добавить дополнительный источник почтовых алиасов, чтобы Postfix знал где их искать. Для этого допишите после запятой путь к конфигурации подключения к AD с ключом ldap:

Создайте файл ldap-aliases.cf и пропишите настройки для подключения:

Небольшие пояснения:

  • server_host — КД для подключения, можно указать несколько;
  • search_base — OU, с которого идет поиск вниз по иерархии;
  • bind_dn — полное имя (distinguishedName) и пароль к нему в поле bind_pw;
  • query_filter — фильтр для поиска ldap. В моем случае поиск идет только среди объектов пользователь и группа по полю proxyAddresses, которое может иметь враз несколько алиасов разных типов, например (нам нужны только типы smtp:, а ключ %s соответствует искомому адресу):

На этом все, перезапускаем Postfix:

И снова отправляем почту на несуществующий ящик:

Ответ теперь совсем другой — Recipient address rejected: User unknown in local recipient table — и он означает, что Postfix сначала обратился к AD и, не обнаружив там пользователя, вернул ошибку. Письмо до Exchange не дошло. Это и нужно.

Владельцу сообщения вернулся ответ, в этот раз от Postfix:

Базовая настройка на этом завершена, но это только первый этап. Об остальных моментах я планирую рассказать в следующих статьях.

 

comments powered by HyperComments
3housing
2022-07-04 19:41:42
<strong>2incisive</strong>
dissertation fellowships
2022-07-05 16:33:36
<strong>dissertation database https://professionaldissertationwriting.org/</strong>
help dissertation
2022-07-05 17:17:34
<strong>online dissertation writing https://professionaldissertationwriting.com/</strong>
law dissertation writing service
2022-07-05 21:14:38
<strong>dissertation online help https://helpwithdissertationwritinglondon.com/</strong>
dissertation defense questions
2022-07-06 00:20:46
<strong>dissertation literature review https://dissertationwritingcenter.com/</strong>
doctoral dissertation
2022-07-06 05:27:06
<strong>help me https://accountingdissertationhelp.com/</strong>
uk dissertation writing service
2022-07-06 06:51:50
<strong>electronic engineering dissertation ideas https://examplesofdissertation.com/</strong>
service writing
2022-07-06 09:17:22
<strong>professional writing service https://writing-a-dissertation.net/</strong>
doctoral dissertation writing help
2022-07-06 13:24:26
<strong>dissertation completion pathway https://bestdissertationwritingservice.net/</strong>
dissertation plan
2022-07-06 14:15:52
<strong>writing editing services https://businessdissertationhelp.com/</strong>
custom dissertation writing help
2022-07-06 18:34:38
<strong>professional dissertation help https://customdissertationwritinghelp.com/</strong>
acknowledgements dissertation
2022-07-06 20:38:47
<strong>psychology dissertation https://writingadissertationproposal.com/</strong>
doctoral dissertation help usa
2022-07-06 23:12:10
<strong>dissertation writing service online https://dissertationhelpspecialist.com/</strong>
professional writing service
2022-07-07 06:02:37
<strong>dissertation help uk https://customthesiswritingservices.com/</strong>
online casino games list
2022-07-25 18:21:18
<strong>real casino online for real money https://download-casino-slots.com/</strong>
online casino las vegas
2022-07-25 21:26:31
<strong>river online casino https://firstonlinecasino.org/</strong>
ceasars casino online
2022-07-25 23:12:29
<strong>usa online casino real money https://onlinecasinofortunes.com/</strong>
paradise casino online
2022-07-26 01:56:25
<strong>online michigan casino https://newlasvegascasinos.com/</strong>
raging bull casino online slots
2022-07-26 05:38:22
<strong>bovada online casino https://trust-online-casino.com/</strong>
best online casino pa
2022-07-26 08:08:42
<strong>online casino black jack https://onlinecasinosdirectory.org/</strong>
caesars casino online bonus code
2022-07-26 10:30:25
<strong>rivers online casino pa https://9lineslotscasino.com/</strong>
borgata online casino promotions
2022-07-26 12:50:12
<strong>fastest withdrawal online casino https://free-online-casinos.net/</strong>
resort casino online
2022-07-26 14:45:53
<strong>free online casino bonus https://internet-casinos-online.net/</strong>
caesars casino online
2022-07-26 18:20:52
<strong>casino bet online https://cybertimeonlinecasino.com/</strong>
best online casino promotions
2022-07-26 19:49:25
<strong>ocean resort casino online https://1freeslotscasino.com/</strong>
casino online dinero real usa
2022-07-27 00:11:23
<strong>jackpotcity online casino https://vrgamescasino.com/</strong>
top 10 online casino
2022-07-27 01:13:23
<strong>caesars online casino pa https://casino-online-roulette.com/</strong>
spain online casino
2022-07-27 04:16:34
<strong>online casino spielen https://casino-online-jackpot.com/</strong>
juegos de casino online
2022-07-27 07:13:38
<strong>online casino best https://onlineplayerscasino.com/</strong>
viva slots vegas™ free slot casino games online
2022-07-27 09:40:41
<strong>casino online real money https://ownonlinecasino.com/</strong>
online casino bonus
2022-07-27 12:52:12
<strong>las atlantis casino online no deposit bonus codes 2021 https://all-online-casino-games.com/</strong>
casino stream online
2022-07-27 14:04:44
<strong>borgata pa online casino https://casino8online.com/</strong>
vpn service comparison
2022-08-07 16:02:21
<strong>proton free vpn https://freevpnconnection.com/</strong>
vpn free download for pc
2022-08-07 18:31:05
<strong>ivacy vpn https://shiva-vpn.com/</strong>
proton free vpn
2022-08-07 20:17:45
<strong>free safe vpn https://freehostingvpn.com/</strong>
best vpn for apple tv
2022-08-07 22:16:24
<strong>free vpn windows 10 https://ippowervpn.net/</strong>
best vpn client
2022-08-08 01:41:46
<strong>what's the best vpn https://imfreevpn.net/</strong>
free mexican vpn
2022-08-08 02:04:53
<strong>buy vpn with credit card https://superfreevpn.net/</strong>
vpn for mac
2022-08-08 06:14:01
<strong>how to buy a vpn https://free-vpn-proxy.com/</strong>
best free vpn for firefox
2022-08-08 06:51:24
<strong>buy vpn paypal https://rsvpnorthvalley.com/</strong>
top gay dating sites dallas texas
2022-08-23 14:03:25
<strong>best gay dating app https://gay-singles-dating.com/</strong>
gay dating red flags
2022-08-23 17:41:09
<strong>gay dating site out personal custormer service https://gayedating.com/</strong>
mister gay dating app
2022-08-23 19:37:23
<strong>cruise gay dating https://datinggayservices.com/</strong>
romancemingle
2022-08-24 13:45:42
<strong>online free dating personals for singles https://freephotodating.com/</strong>
dateing sites
2022-08-24 14:55:59
<strong>dating simulator https://onlinedatingbabes.com/</strong>
dating sites free near me
2022-08-24 17:26:50
<strong>best internet dating service https://adult-singles-online-dating.com/</strong>
nyhentai
2022-08-24 20:47:07
<strong>local dating sites absolutely free https://adult-classifieds-online-dating.com/</strong>
meeting with my lady
2022-08-24 22:45:08
<strong>meet online service https://online-internet-dating.net/</strong>
asia dieting wep
2022-08-25 02:24:45
<strong>mature dating https://datingpersonalsonline.com/</strong>
100% inspektion
2022-08-25 04:20:03
<strong>dating dating site https://wowdatingsites.com/</strong>
online dating sites free chatting
2022-08-25 12:15:00
<strong>senior dating sites https://virtual-online-dating-service.com/</strong>
date chatting sites
2022-08-25 14:05:43
<strong>free daing https://zonlinedating.com/</strong>
dafing sites
2022-08-25 16:52:18
<strong>single women phone numbers https://onlinedatingservicesecrets.com/</strong>
hollywood casino online promo code
2022-08-30 10:06:36
<strong>online baccarat casino https://onlinecasinos4me.com/</strong>
best michigan online casino
2022-08-30 14:28:28
<strong>win real money online casino for free https://online2casino.com/</strong>
online casino software provider
2022-08-30 17:05:15
<strong>casino gta online https://casinosonlinex.com/</strong>
popular gay chat site
2022-09-03 00:55:11
<strong>gay perv chat https://newgaychat.com/</strong>
gay video chat apps
2022-09-03 04:04:01
<strong>gay black man chat https://gaychatcams.net/</strong>
gay chat now
2022-09-03 08:47:32
<strong>free 60 minute trial phone chat gay https://gaychatspots.com/</strong>
black gay chat
2022-09-03 14:06:47
<strong>free gay radom ewb chat https://gay-live-chat.net/</strong>
gay video chat sites
2022-09-03 21:39:36
<strong>702 gay chat number https://chatcongays.com/</strong>
gay roleplay chat
2022-09-04 01:09:04
<strong>gay male chat https://gayphillychat.com/</strong>
anonymous gay chat
2022-09-04 07:07:22
<strong>free cookeville tn gay chat rooms https://gaychatnorules.com/</strong>
gay chat washington state
2022-09-04 10:34:14
<strong>chat with gay stranger https://gaymusclechatrooms.com/</strong>
gay dirty chat
2022-09-04 15:05:33
<strong>321 gay teen chat https://free-gay-sex-chat.com/</strong>
dubuque gay chat
2022-09-04 23:12:41
<strong>gay chat for windows https://gayinteracialchat.com/</strong>
free asain gay chat lines
2022-10-20 17:29:26
<strong>free chat rooms gay chat https://gaymanchatrooms.com/</strong>
finished custom writing paper
2022-10-20 19:45:58
<strong>help writing a paper for college https://sociologypapershelp.com/</strong>
write my papers
2022-10-20 20:49:42
<strong>buy custom papers https://uktermpaperwriters.com/</strong>
paper writing services
2022-10-20 22:45:19
<strong>help in writing paper https://paperwritinghq.com/</strong>
custom writing paper service
2022-10-21 00:19:27
<strong>write my paper co https://writepapersformoney.com/</strong>
what should i write my paper about
2022-10-21 01:12:54
<strong>buy writing paper https://write-my-paper-for-me.org/</strong>
custom college papers
2022-10-21 02:10:59
<strong>custom papers online https://doyourpapersonline.com/</strong>
academic paper writers
2022-10-21 03:36:40
<strong>paper helper https://top100custompapernapkins.com/</strong>
order custom paper
2022-10-21 05:06:15
<strong>where can i buy resume paper https://researchpaperswriting.org/</strong>
someone to write my paper
2022-10-21 08:17:56
<strong>pay to do my paper https://writingpaperservice.net/</strong>
buy literature review paper
2022-10-21 09:46:03
<strong>who can write my paper for me https://buyessaypaperz.com/</strong>
where to buy papers
2022-10-21 10:45:48
<strong>do my college paper for me https://mypaperwritinghelp.com/</strong>
someone write my paper
2022-10-21 12:22:06
<strong>help paper https://writemypaperquick.com/</strong>
help with paper
2022-10-21 13:10:25
<strong>buy cheap paper https://essaybuypaper.com/</strong>
write my math paper
2022-10-21 14:05:19
<strong>buy resume paper https://papercranewritingservices.com/</strong>
pay to write my paper
2022-10-21 16:58:35
<strong>write my paper co https://ypaywallpapers.com/</strong>
pay for a paper
2022-10-21 18:32:00
<strong>custom paper https://studentpaperhelp.com/</strong>
1drawings
2023-01-26 14:31:45
<strong>3glinting</strong>
do my coursework
2023-02-05 16:35:28
<strong>coursework only degree https://courseworkninja.com/</strong>
coursework questions
2023-02-05 17:38:23
<strong>coursework online https://writingacoursework.com/</strong>
coursework info
2023-02-05 20:14:35
<strong>coursework planner https://courseworkdownloads.com/</strong>
coursework science
2023-02-05 21:22:29
<strong>coursework writing service https://courseworkinfotest.com/</strong>
coursework support
2023-02-05 23:17:21
<strong>coursework marking https://coursework-expert.com/</strong>
coursework writing
2023-02-06 01:32:03
<strong>coursework papers https://buycoursework.org/</strong>
design and technology gcse coursework
2023-02-06 03:24:24
<strong>creative writing coursework https://courseworkdomau.com/</strong>
dating single online
2023-02-08 14:16:54
<strong>singles ads https://jewish-dating-online.net/</strong>
dating sites online
2023-02-08 14:34:09
<strong>best app for meetings online free https://jewish-dating-online.net/</strong>
dating service
2023-02-08 17:38:50
<strong>dateing sites https://sexanddatingonline.com/</strong>
farmers only dating website
2023-02-08 20:24:12
<strong>which online dating site is best https://onlinedatingsuccessguide.com/</strong>
online single sites
2023-02-08 23:02:33
<strong>best dating site usa https://datingwebsiteshopper.com/</strong>
dateing websites
2023-02-08 23:46:02
<strong>internet dating sites https://allaboutdatingsites.com/</strong>
dating sites contact united states
2023-02-09 01:28:46
<strong>free dating ads https://freedatinglive.com/</strong>
best online dating website
2023-02-09 02:12:35
<strong>thai flirt https://freewebdating.net/</strong>
Яндекс.Метрика