centos configure postfix mail service

1. environment initialization

[root @ mail ~] # rpm -q centos-release // Display system version
centos-release-7-5.1804.el7.centos.x86_64

[Root @ localhost ~] # vi / etc / hostname // change the host name for the mail server domain name mail.test.com

[Root @ localhost ~] # systemctl disable firewalld // disable the firewall boot from the start

[Root @ localhost ~] # vi / etc / sysconfig / selinux // value unannotated line to disabled SELINUX

[Root @ localhost ~] # vi / etc / fstab // edit fstab configuration file, add the following line at the end:

/ Dev / cdrom / mnt iso9660 ro 0 0 // vmware boot disc image mounted read only connected automatically to the directory / mnt

[Root @ localhost ~] # vi /etc/yum.repos.d/CentOS-Base.repo // edit yum configuration files to facilitate subsequent installation, configuration as follows, delete or other comments:

[Base]
name = CentOS- $ releasever - Base
baseurl = File: /// mnt
Enabled = 1
gpgcheck = 0
//////////// did not understand what it meant, why do
[root @ localhost ~] # reboot // restart to take effect so that improve the environment

2. set up DNS name resolution environment for parsing postfix address

[Root @ mail ~] # yum install -y bind // DNS server installed

[Root @ mail ~] # vi /etc/named.conf // modify the DNS master configuration file

listen-on port 53 { 192.168.49.129; };

allow-query {any;}; // the content of the two lines

[Root @ mail ~] # vi /etc/named.rfc1912.zones // sub modify configuration files

zone “test.com” IN {

    type master;

    file "test.com.zone";

};

zone “49.168.192.in-addr.arpa” {

    type master;

    file "test.com.local";

}; // add the last one forward and one reverse analysis region

[Root @ mail ~] # cd / var / named / // DNS server into the zone configuration file directory

[root@mail named]# cp -p named.localhost test.com.zone

[Root @ mail named] # cp -p named.localhost test.com.local // copy area profiles for specific template zone configuration file. Retain the source file permissions to determine is a group named

[root @ mail named] # vi test.com.zone // edit configuration files forward zone
$ TTL 1D
@ the IN SOA @ rname.invalid. (

                                    0       ; serial
                                    1D      ; refresh
                                    1H      ; retry
                                    1W      ; expire
                                    3H )    ; minimum
    NS      @
    A       192.168.49.129
    mail      A       192.168.49.129
    MX 10   mail.test.com.

[root @ mail named] # vi test.com.local // Edit reverse zone configuration file
$ the TTL 1D
@ the IN test.com the SOA. rname.invalid. (

                                    0       ; serial
                                    1D      ; refresh
                                    1H      ; retry
                                    1W      ; expire
                                    3H )    ; minimum
    NS      mail.test.com.
    A       192.168.49.129
    MX 10   mail.test.com.
    129     PTR     mail.test.com.

[Root @ mail named] # systemctl start named // Start the DNS domain name server

[Root @ mail named] # yum install -y bind-utils // install dns nslookup command to test whether the resolution succeeds

[Root @ mail named] # vi /etc/resolv.conf // DNS to point to the machine's own dns server

nameserver 192.168.49.129

[root @ mail named] # nslookup mail.test.com // // forward resolution to resolve the server address
Server: 192.168.49.129
Address: 192.168.49.129 # 53

Name: mail.test.com
Address: 192.168.49.129

// reverse analysis
[root @ mail named] # nslookup 192.168.49.129
Server: 192.168.49.129
Address: 192.168.49.129 # 53

Name = mail.test.com 129.49.168.192.in-addr.arpa.
// success

3. Install and configure the server postfix

Usually installed automatically by default postfix server.

[Root @ mail named] # rpm -q postfix // check whether the system is already installed postfix server

postfix-2.10.1-6.el7.x86_64

[Root @ mail named] # postconf -a // check whether to support cyrus dovecot postfix function, if you do not support the need to re-install the updated version

[Root @ mail named] # vi /etc/postfix/main.cf // postfix edit the configuration file, find and modify the corresponding configuration item

myhostname = mail.test.com // local host name

mydomain = test.com // server domain name

myorigin = $ mydomain // initial domain name

inet_interfaces = 192.168.80.181, 127.0.0.1 // listener interfaces

inet_protocols = ipv4 // listening on the network version, you can not change

mydestination = myhostname,

mydomain // target domain

home_mailbox = Maildir / // e-mail directory, in the user's home directory

[Root @ mail named] # postfix check // check the configuration file for syntax errors

[Root @ mail named] # systemctl start postfix // start postfix server

                                         //postconf -n该命令可查看postfix非默认配置
  • 1

4. Test the mail server simple letter

[Root @ mail named] # groupadd mailusers // add mail accounts group

[Root @ mail named] # useradd -g mailusers -s / sbin / nologin jack // user is not allowed to log jack (can connect mailusers)

[root@mail named]# passwd jack

[root@mail named]# useradd -g mailusers -s /sbin/nologin tom

[Root @ mail named] # passwd tom // add jack, tom mail service test account

[Root @ mail named] # yum install -y telnet // remote login plug-in installation, test port used to log 25

[Root @ mail named] # telnet mail.test.com 25 // Telnet port 25, as the error can not connect, restart postfix

Figure indicate the correct
Enter the following command to test:
Write pictures described here

[Root @ mail named] # ls / home / tom / Maildir / new / // tom view the message received at the mail directory

Write pictures described here
The super administrator can only view the message

Guess you like

Origin www.cnblogs.com/duanlinxiao/p/10945202.html