Postfix to achieve mutual mail between different network segments

  
        

Foreword: Humans communicated in different regions by writing letters very early. After entering the 21st century, the role of mail is more important. The emergence of the Internet has greatly reduced the time for receiving letters. Let people almost reach a real-time dialogue, then how to build a mail server for people to use it in Linux is implemented by postfix

Experimental preparation: Shut down SELinux, configure yum source configuration IP address

Experimental environment: RHEL5.5

At least three of the machines used in the experiment are used as routers to forward packets of different network segments.

The experimental topology is as follows


The IP configuration of the router is as follows


echo 1 > /proc/sys/net/ipv4/ip_forward Enable NIC forwarding

Configure DNS< Br>

Install DNS Service

yum –y install bind-*

echo “” > /etc/resolv.conf DNS pointer is empty

vim /var/named/chroot/etc/named.conf Create a new configuration file

options { directory &qu Ot;/var/named"; }; zone "sina.com" { type master; file "sina.com.zone";

}; zone "yahoo.com" { type master; File "yahoo.com.zone"; };

cp /usr/share/doc/bind-9.3.6/sample/var/named/localhost.zone /var/named/chroot/var/Named/yahoo.com.zone

cp /usr/share/doc/bind-9.3.6/sample/var/named/localhost.zone /var/named/chroot/var/named/sina.com .zone copy template file to zone file

cd /var/named/chroot/var/named/

vim yahoo.com.zone


Vim sina.com.zone


Restart service service named restart

Test


OK Parse success

sina configuration on the machine

1.Set up the parsing file

vi /etc/resolv.conf

nameserver 192.168.1.1

host mail.sina .com Resolving Host Addresses


Adding a Route Record If Resolution Is Unsuccessful

route add -net 192.168.2.0/24 gw 192.168.1.1 Destination address gateway

2. Close the sendmial service

service sendmail stop

chkconfig sendmail off

3. Install postfix to send mail

yum –y install postfix

vim /etc/postfix/main.cf

myhostname = mail.sina.com mydomain = sina.com myorigin = $mydomain inet_interfaces = all mydestination = $myhostname, $mydomain mynetworks = 192.168.1.0/24, 192.168.2.0, 127.0.0.0/8 The network segment of the mail server relay domains = sina.com, yahoo.com Set which domains can be forwarded to the mail at the end of the configuration file plus

smtpd_sasl_auth_enable = yes smtpd_sasl_local_domain = '' smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination broken_sasl_auth_clients = yes smtpd_client_restrictions = permit_sasl_authenticated smtpd_sasl_security_options = noanonymous

save and exit

vim /etc /sysconfig /saslauthd Modify the configuration file of the saslauthd service Modify MECH=shadow

Exit Create a user s Ina then sets the password for the user

useradd sina

passwd sina starts the saslauthd service /etc/init.d/saslauthd restart chkconfig saslauthd on test command testsaslauthd -u sina -p 'abc-123'

If OK Success is returned, the saslauthd service has been working successfully

service postfix restart Restart postfix service

Test postfix


Back The 250 code indicates that postfix has been configured successfully

4 Installing the dovecot service to receive mail

yum -y install dovecot Modifying the configuration file vi /etc/dovecot.conf

To be modified There are two places


The protocol set in line 20 is pop3 and pop3s protocol

In the 35th line, remove the comment and listen to the POP3 port. Note that this must be written in the top. 38 lines of } is also a fixed line write or linux read here will read the space and then read other configurations

service dovecot restart restart service

chkconfig dovecot on

Modify postfix master file

Found in about 456 lines

mailbox_transport = lmtp:unix:/var/lib/imap/socke t/lmtp removes the comment from this line to associate it with

yum -y install cyrus-imapd cyrus-imapd-devel

cat /etc/passwd file



cyrus can see there is a user

set cyrus password

passwd cyrus

restart service /etc/init.d /cyrus-imapd restart chkconfig cyrus-imapd on

Link to the background cyradm -u cyrus localhost


Create a sina mailbox user

Then quit Exit

5 Install webmail

yum -y install squirrelmail

Run the PHP Settings Tool /usr/share/squirrelmail/config/conf.pl

1 Enter 2 server settings in command

Enter the characters in sequence 1 3 Modify the configuration


rReturn and enter A-------8 to Cyrus


r return and enter 4 General Options and then select 5 to change the value to true #ignoring the case


r returning and then entering D Set pre-defined se Tittings for specific IMAP server






IMAP Server is : cyrus


s save q and then start httpd service service httpd restart

If not installed, install httpd service yum –y install http-*

Open your browser and enter http://mail.sina.com/webmail/


After logging in




Send yourself a mail test


OK test success

Then configure yahoo this machine

1.Set up Parsing files

vi /etc/resolv.conf

nameserver 192.168.2.1

The only difference between the second step and the sina machine configuration is the established mailbox user. Here we configure a yahoo mailbox user on the yahoo machine


After logging in, send an email to the user sina





Then look at sina this email has received the mail


sina and then give yahoo a try


Checking mail at yahoo


Received back The experiment is successful. There is a drawback here. Every new mailbox user will create a new user name on the server. Next time, you need to improve the virtual users. Please enlighten me. Source: http://yushantao.blog.51cto.com/975462/1220927#560270

Copyright © Windows knowledge All Rights Reserved