{"id":44236,"date":"2024-10-06T14:02:11","date_gmt":"2024-10-06T06:02:11","guid":{"rendered":"https:\/\/server.hk\/cnblog\/44236\/"},"modified":"2024-10-06T14:02:11","modified_gmt":"2024-10-06T06:02:11","slug":"centos-%e4%b8%8b%e4%bd%bf%e7%94%a8-postfix-dovecot-dnsmasq-%e6%90%ad%e5%bb%ba%e7%b0%a1%e6%98%93%e5%b1%80%e5%9f%9f%e7%b6%b2%e9%83%b5%e4%bb%b6%e7%b3%bb%e7%b5%b1","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/44236\/","title":{"rendered":"CentOS \u4e0b\u4f7f\u7528 Postfix + Dovecot + Dnsmasq \u642d\u5efa\u7c21\u6613\u5c40\u57df\u7db2\u90f5\u4ef6\u7cfb\u7d71"},"content":{"rendered":"<h1 id=\"centos-%e4%b8%8b%e4%bd%bf%e7%94%a8-postfix-dovecot-dnsmasq-%e6%90%ad%e5%bb%ba%e7%b0%a1%e6%98%93%e5%b1%80%e5%9f%9f%e7%b6%b2%e9%83%b5%e4%bb%b6%e7%b3%bb%e7%b5%b1-tmfybMdxFD\">CentOS \u4e0b\u4f7f\u7528 Postfix + Dovecot + Dnsmasq \u642d\u5efa\u7c21\u6613\u5c40\u57df\u7db2\u90f5\u4ef6\u7cfb\u7d71<\/h1>\n<p>\u5728\u7576\u4eca\u6578\u4f4d\u5316\u7684\u6642\u4ee3\uff0c\u90f5\u4ef6\u7cfb\u7d71\u4ecd\u7136\u662f\u4f01\u696d\u548c\u500b\u4eba\u6e9d\u901a\u7684\u91cd\u8981\u5de5\u5177\u3002\u672c\u6587\u5c07\u4ecb\u7d39\u5982\u4f55\u5728 CentOS \u74b0\u5883\u4e0b\uff0c\u5229\u7528 Postfix\u3001Dovecot \u548c Dnsmasq \u642d\u5efa\u4e00\u500b\u7c21\u6613\u7684\u5c40\u57df\u7db2\u90f5\u4ef6\u7cfb\u7d71\u3002\u9019\u500b\u7cfb\u7d71\u4e0d\u50c5\u80fd\u5920\u6eff\u8db3\u57fa\u672c\u7684\u90f5\u4ef6\u767c\u9001\u548c\u63a5\u6536\u9700\u6c42\uff0c\u9084\u80fd\u5728\u5c40\u57df\u7db2\u5167\u90e8\u63d0\u4f9b\u7a69\u5b9a\u7684\u90f5\u4ef6\u670d\u52d9\u3002<\/p>\n<h2 id=\"%e7%92%b0%e5%a2%83%e6%ba%96%e5%82%99-tmfybMdxFD\">\u74b0\u5883\u6e96\u5099<\/h2>\n<p>\u5728\u958b\u59cb\u4e4b\u524d\uff0c\u78ba\u4fdd\u4f60\u7684 CentOS \u7cfb\u7d71\u5df2\u7d93\u66f4\u65b0\u5230\u6700\u65b0\u7248\u672c\u3002\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u9032\u884c\u66f4\u65b0\uff1a<\/p>\n<pre><code>sudo yum update -y<\/code><\/pre>\n<p>\u63a5\u4e0b\u4f86\uff0c\u5b89\u88dd\u5fc5\u8981\u7684\u8edf\u4ef6\u5305\uff1a<\/p>\n<pre><code>sudo yum install postfix dovecot dnsmasq -y<\/code><\/pre>\n<h2 id=\"%e9%85%8d%e7%bd%ae-dnsmasq-tmfybMdxFD\">\u914d\u7f6e Dnsmasq<\/h2>\n<p>Dnsmasq \u662f\u4e00\u500b\u8f15\u91cf\u7d1a\u7684 DNS \u548c DHCP \u670d\u52d9\u5668\uff0c\u9069\u5408\u5c0f\u578b\u7db2\u7d61\u4f7f\u7528\u3002\u9996\u5148\uff0c\u7de8\u8f2f Dnsmasq \u7684\u914d\u7f6e\u6587\u4ef6\uff1a<\/p>\n<pre><code>sudo vi \/etc\/dnsmasq.conf<\/code><\/pre>\n<p>\u5728\u6587\u4ef6\u4e2d\u6dfb\u52a0\u4ee5\u4e0b\u5167\u5bb9\uff1a<\/p>\n<pre><code>domain-needed\nbogus-priv\ninterface=eth0\ndhcp-range=192.168.1.10,192.168.1.100,12h\naddress=\/mail.local\/192.168.1.2<\/code><\/pre>\n<p>\u9019\u88e1\u7684 `interface` \u662f\u4f60\u7684\u7db2\u7d61\u63a5\u53e3\uff0c`dhcp-range` \u662f\u5206\u914d\u7684 IP \u7bc4\u570d\uff0c`address` \u5247\u662f\u5c07\u90f5\u4ef6\u57df\u540d\u6307\u5411\u90f5\u4ef6\u670d\u52d9\u5668\u7684 IP \u5730\u5740\u3002\u4fdd\u5b58\u4e26\u9000\u51fa\u5f8c\uff0c\u555f\u52d5 Dnsmasq \u670d\u52d9\uff1a<\/p>\n<pre><code>sudo systemctl start dnsmasq\nsudo systemctl enable dnsmasq<\/code><\/pre>\n<h2 id=\"%e9%85%8d%e7%bd%ae-postfix-tmfybMdxFD\">\u914d\u7f6e Postfix<\/h2>\n<p>\u63a5\u4e0b\u4f86\uff0c\u6211\u5011\u9700\u8981\u914d\u7f6e Postfix\u3002\u7de8\u8f2f Postfix \u7684\u4e3b\u914d\u7f6e\u6587\u4ef6\uff1a<\/p>\n<pre><code>sudo vi \/etc\/postfix\/main.cf<\/code><\/pre>\n<p>\u5728\u6587\u4ef6\u4e2d\u6dfb\u52a0\u6216\u4fee\u6539\u4ee5\u4e0b\u914d\u7f6e\uff1a<\/p>\n<pre><code>myhostname = mail.local\nmydomain = local\nmyorigin = $mydomain\ninet_interfaces = all\ninet_protocols = ipv4\nmydestination = $myhostname, localhost.$mydomain, localhost, $mydomain\nrelayhost =\nmynetworks = 192.168.1.0\/24\nhome_mailbox = Maildir\/<\/code><\/pre>\n<p>\u9019\u4e9b\u8a2d\u7f6e\u78ba\u4fdd\u4e86 Postfix \u80fd\u5920\u5728\u5c40\u57df\u7db2\u5167\u90e8\u6b63\u5e38\u904b\u884c\u3002\u5b8c\u6210\u5f8c\uff0c\u91cd\u555f Postfix \u670d\u52d9\uff1a<\/p>\n<pre><code>sudo systemctl restart postfix<\/code><\/pre>\n<h2 id=\"%e9%85%8d%e7%bd%ae-dovecot-tmfybMdxFD\">\u914d\u7f6e Dovecot<\/h2>\n<p>Dovecot \u662f\u4e00\u500b\u6d41\u884c\u7684 IMAP \u548c POP3 \u4f3a\u670d\u5668\uff0c\u8ca0\u8cac\u8655\u7406\u90f5\u4ef6\u7684\u63a5\u6536\u3002\u7de8\u8f2f Dovecot \u7684\u4e3b\u914d\u7f6e\u6587\u4ef6\uff1a<\/p>\n<pre><code>sudo vi \/etc\/dovecot\/dovecot.conf<\/code><\/pre>\n<p>\u6dfb\u52a0\u4ee5\u4e0b\u5167\u5bb9\uff1a<\/p>\n<pre><code>mail_location = maildir:~\/Maildir\nservice imap {\n  inet_listener imap {\n    port = 0\n  }\n  inet_listener imaps {\n    port = 993\n    ssl = yes\n  }\n}\nssl_cert = \nssl_key = <\/code><\/pre>\n<p>\u78ba\u4fdd\u66ff\u63db `your_cert.pem` \u548c `your_key.pem` \u70ba\u4f60\u7684 SSL \u8b49\u66f8\u548c\u5bc6\u9470\u7684\u5be6\u969b\u8def\u5f91\u3002\u7136\u5f8c\uff0c\u555f\u52d5 Dovecot \u670d\u52d9\uff1a<\/p>\n<pre><code>sudo systemctl start dovecot\nsudo systemctl enable dovecot<\/code><\/pre>\n<h2 id=\"%e6%b8%ac%e8%a9%a6%e9%83%b5%e4%bb%b6%e7%b3%bb%e7%b5%b1-tmfybMdxFD\">\u6e2c\u8a66\u90f5\u4ef6\u7cfb\u7d71<\/h2>\n<p>\u5b8c\u6210\u4ee5\u4e0a\u914d\u7f6e\u5f8c\uff0c\u53ef\u4ee5\u4f7f\u7528\u90f5\u4ef6\u5ba2\u6236\u7aef\uff08\u5982 Thunderbird \u6216 Outlook\uff09\u4f86\u6e2c\u8a66\u90f5\u4ef6\u7cfb\u7d71\u3002\u8a2d\u7f6e\u90f5\u4ef6\u5e33\u6236\u6642\uff0c\u4f7f\u7528\u4ee5\u4e0b\u53c3\u6578\uff1a<\/p>\n<ul>\n<li>\u90f5\u4ef6\u4f3a\u670d\u5668\uff1amail.local<\/li>\n<li>\u7528\u6236\u540d\uff1a\u4f60\u7684\u7528\u6236\u540d<\/li>\n<li>\u5bc6\u78bc\uff1a\u4f60\u7684\u5bc6\u78bc<\/li>\n<li>IMAP \u7aef\u53e3\uff1a993<\/li>\n<\/ul>\n<p>\u5982\u679c\u4e00\u5207\u914d\u7f6e\u6b63\u78ba\uff0c\u4f60\u61c9\u8a72\u80fd\u5920\u6210\u529f\u767c\u9001\u548c\u63a5\u6536\u90f5\u4ef6\u3002<\/p>\n<h2 id=\"%e7%b8%bd%e7%b5%90-tmfybMdxFD\">\u7e3d\u7d50<\/h2>\n<p>\u901a\u904e\u4ee5\u4e0a\u6b65\u9a5f\uff0c\u6211\u5011\u6210\u529f\u5728 CentOS \u74b0\u5883\u4e0b\u642d\u5efa\u4e86\u4e00\u500b\u7c21\u6613\u7684\u5c40\u57df\u7db2\u90f5\u4ef6\u7cfb\u7d71\uff0c\u4f7f\u7528\u4e86 Postfix\u3001Dovecot \u548c Dnsmasq\u3002\u9019\u6a23\u7684\u7cfb\u7d71\u4e0d\u50c5\u80fd\u5920\u6eff\u8db3\u57fa\u672c\u7684\u90f5\u4ef6\u9700\u6c42\uff0c\u9084\u80fd\u5728\u5c40\u57df\u7db2\u5167\u90e8\u63d0\u4f9b\u7a69\u5b9a\u7684\u90f5\u4ef6\u670d\u52d9\u3002\u5982\u679c\u4f60\u9700\u8981\u66f4\u9ad8\u6548\u7684\u90f5\u4ef6\u89e3\u6c7a\u65b9\u6848\uff0c\u53ef\u4ee5\u8003\u616e\u4f7f\u7528 <a href=\"https:\/\/server.hk\">\u9999\u6e2fVPS<\/a> \u4f86\u9032\u884c\u90e8\u7f72\uff0c\u9019\u6a23\u80fd\u5920\u7372\u5f97\u66f4\u597d\u7684\u6027\u80fd\u548c\u7a69\u5b9a\u6027\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u642d\u5efa\u7c21\u6613\u5c40\u57df\u7db2\u90f5\u4ef6\u7cfb\u7d71\uff0c\u4f7f\u7528 CentOS\u3001Postfix\u3001Dovecot \u548c Dnsmasq\uff0c\u5be6\u73fe\u9ad8\u6548\u90f5\u4ef6\u7ba1\u7406\u8207\u767c\u9001\u3002<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4924],"tags":[],"class_list":["post-44236","post","type-post","status-publish","format-standard","hentry","category-setup-tutorials"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/44236","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=44236"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/44236\/revisions"}],"predecessor-version":[{"id":44237,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/44236\/revisions\/44237"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=44236"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=44236"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=44236"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}