Friday, February 17, 2012

Configuring sendmail


Files and Directories
Explanation
/ Usr / sbin / sendmail
Sendmail daemon
/ Usr / bin / makemap
Map generation files (access, virtususer registration)
/ Usr / bin / nealiases
alias file to create the DB
/ Usr / lib / sendmail
Sendmail daemon (/ usr / sbin / sendmail and link)
/ Var / spool / mqueue
Kyudirektori (mail temporary storage directory)
/ Var / spool / mail
-
/ Etc / mail / access
Relay restrictions and configuration files
/ Etc / mail / aliases
alias configuration file
/ Etc / mail / domaintable
Domain registration file table
/ Etc / mail / local-host-names
JS ChoiShinji configuration file
/ Etc / mail / sendmail.cf
-
/ Etc / mail / sendmail.cw
JS ChoiShinji configuration file (old version)
/ Etc / mail / virtusertable
Virtual-mail address, the register file
/ Etc / rc.d / init.d / sendmail
Sendmail startup and shutdown scripts (rpm installation)
/ Etc / sysconfig / sendmail
Sendmail configuration files at runtime execution options
/ Var / log / sendmail.st
Sendmail executable file, the situation



# Rpm installation è sendmail, sendmail-CF, m4 Verifying the Installation
# Chkconfig sendmail on
# Service sendmail restart
# Pgrep sendmail

# Vi post-edit-sendmail -> things need to change the configuration of sendmail script
#! / Bin / bash
cd / etc / mail
make
newaliases
/ Etc / init.d / sendmail restart è put up for practice. Sednmail.mc usually does not change the file does not need to be restarted.  service is not a good idea in your server
  Nowadays simple / etc / mail / directory, run "make" when you access and changes, including the virtusertable file allows all of the applicable. And if it does not generate sendmail.cf restart sendmail daemon does not need to.
# Chmod 700 post-edit-sendmail

# Vi / etc / resolv.conf
domain my-site.com -> Make sure that your mail server matches the domain of
nameserver 192.168.1.100 -> Mail Server acts as a DNS client, so make sure

# Vi / etc / hosts
Bigboy.my-site.com 127.0.0.1 localhost.localdomain localhost bigboy è / etc / hosts file, so make sure the DNS client settings in

# Vi / etc / mail / sendmail.mc
-          dnl DAEMON_OPTIONS ('Port = SMTP, Addr = 127.0.0.1, Name = MTA') è rokeolhoseuteuman rather than listen to listen on all interfaces are commented out.

-          FEATURE ('accept_unresolvable_domains') dnl è does not exist in order to block spam mail coming from the domain will be accepted (553 error) to handle the comment. If you do not uncomment the sender's domain without checking mail Relay permits.

    Note that with multiple NIC and accept a specific NIC, if ten thousand local interface settings as shown below, without commenting further stated the address of the NIC to accept a row is added.
DAEMON_OPTIONS ('Port = smtp, Addr = 127.0.0.1, Name = MTA')
DAEMON_OPTIONS ('Port = smtp, Addr = 192.168.1.100, Name = MTA')

-            dnl define ('SMART_HOST', 'mail.my-site.com') -> This is not necessary.

※ Anti-Spam SMTP authentication settings for
: Access the DRAC IP address based on the other hand, this configuration allowed RELAY ID / PASS to allow RELAY. Only use this configuration file, RELAY to allow access to the IP address is deleted.

# Vi / etc / mail / sendmail.mc
dnl TRUST_AUTH_MECH (`EXTERNAL DIGEST-MD5 CRAM-MD5 LOGIN PLAIN ') dnl
dnl define (`confAUTH_MECHANISMS ',` EXTERNAL GSSAPI DIGEST-MD5 CRAM-MD5 LOGIN PLAIN ') dnl
-> In the above "TRUST_AUTH_MECH" remove the comment lines that begin with the following makes.
TRUST_AUTH_MECH (`EXTERNAL DIGEST-MD5 CRAM-MD5 LOGIN PLAIN ') dnl
define (`confAUTH_MECHANISMS ',` EXTERNAL GSSAPI DIGEST-MD5 CRAM-MD5 LOGIN PLAIN ') dnl
# M4. / Sendmail.mc>. / Sendmail.cf
# / Etc / rc.d / init.d / sendmail restart

"Client Settings>
client1.JPG


# M4 / etc / mail / sendmail.mc> / etc / mail / sendmail.cf
# Service sendmail restart
    Check the sendmail.cf configuration file - after checking to change the settings that you change mc file instead of cf
# Vi / etc / mail / sendmail.cf
AliasFile = / etc / aliases è file path "/ etc / mail / aliases" If you modify a
MaxMessageSize = ten million è maximum mail size 10000000bytes (10MB) is limited to
Sendmail SmtpGreetingMessage = $ J $ v / $ Z; $ b è twenty-five welcome message when connecting to port. $ V / $ Z REQUIREMENTS


# Vi / etc / mail / Relay-Domains  ->This is not generated by default, must be created manually. This file specifies the domain to allow relay for spammers to fake the source domain, because the possibility. Than this, but usually / etc / mail / access is commonly used.

# Vi / etc / mail / access -> REJECT match, where things are not.
localhost.localdomain        RELAY
localhost                                RELAY
127.0.0.1                                RELAY
192.168.1.16                         RELAY
192.168.2                               RELAY
My-site.com                          RELAY
spam.com REJECT                         -> Incoming / outgoing rejected
spamuser@spam.com             DISCARD  ->Discarded after they received mail. Do not dispose of the sender notification

-> If the access file and smtp authentication when used as hosts access files in a separate setting in Outlook smtp authentication is not required. Host names are also used here in / etc / hosts that uses / etc / hosts will be set well in advance.

# Cd / etc / mail
# Make -> / Etc / mail / access.db apply

Or

# Makemap hash / etc / mail / access.db
# Strings / etc / mail / access.db -> Confirmation

Reference
Domain Check and check all the access is set to determine if the first domain and sends an error code 553 does not exist. Check the domain is not set or if the next access.db be either present a list of domains to check if it is set to be rejected on the list, or 550 (relaying denied), and sends an error.

# Vi / etc / maill / local-host-names -> Domain and receive mail settings (if your old / etc / sendmail.cw used)
my-site.com
another-site.com
-> Note that this file name in the sendmail.cf file "Fw / etc / mail / local-host-names" reference

※ The procedure for the mail server to handle mail
A. / Etc / mail / local-host-names to make sure, if in receipt of a domain
Two. suryeongdoen mail forwarding in virtusertable
Three. Get on top of the alias or aliases if you are explicitly handled in
Four. As a local account set up forwarding all mail processing presence in the local reporting process

# Vi / etc / mail / virtusertable è suryeongdoen specify what to do with mail
@ My-site webmater                             Paul
webmater@another-site.com            Peter -> webmaster-mail accounts are available in two domains
@ Another-site.com                              Marc
sales@my-site.com                             sales@another-site.com
paul@my-site.com                              Paul
finance@my-site.com                         Paul
@ My-site.com                                      Error: User Unknown nouser
-> E-mail address of the destination, the first column, the second a local user mailboxes, remote mail box, / etc / aliases file, mailing lists can be. In other words, when the second column and match the destination e-mail is forwarded to the address.

# Cd / etc / mail
# Make

# Vi / etc / aliases  ->The first, called a virtual meilbakseura mailing list, and the second, separated by commas, are members of the mailing list. (Comma separated space shall be free at)
Mailer-daemon:                    postmaster
postmaster:                           root
Directors:                               Peter, Paul, Mary è there should be no spaces
Admin-list:                             ": include :/ Home / Mailings / Admin-list" -> Can be explicitly specified as

# Vi / home / mailings / admin-list
user1@my-site.com
user2@my-site.com
    aliases are handled in the order
       Check here first that sendmail sendmail mail without thinking of the local user's address is stored in the local user's mailbox.
       Check the mail in the first column of the second column the second column aliases Meant to be the first column of the second column, so be sure to first column that you are.
       Sendmail duplicate (first column, second column) confirmed that there is nothing, the local user sends e-mail.
# Newaliases

# Tail-f / var / log / maillog -> View Log

# Vi / etc / mail / sendmail.mc -> Public use spam blacklists
FEATURE ('dnsbl', 'ipwhois.rfc-ignorant.org', '"550 Mail from" $ & {client_addr} "ref .....
FEATURE ('... see the site
-> See the list of spam by various agencies that match will reject mail.

# M4 / etc / mail / sendmail.mc> / etc / mail / sendmail.cf
# Service sendmail restart

# Telnet 10.123.38.200 25
MAIL From: test@test.comRCPT To: recp@test.com
DATA
Test email
.
QUIT


<-To-use Spam Assassin>
: Sendmail receives mail messages in the mailbox of the user account that is actually placing the message is processed eungyongin procmail. Control of two procmail spam filter temporarily to other applications, such as to enable filtering can neomgieo. Spam Assassin Spam not erasing the 'smap' put the phrase in the title. Then, the mail client to see this phrase to suit the user's intent is to be configured to handle.

# Rpm-Uvh samassassin-2.60-2.i386.rpm
# Chkconfig - level 345 spamassassin on
# Service spamassassin start

# Cp / etc / mail / SpamAssassin / SpamAssassin-spamc.rc / etc / procmailrc  ->/ Etc / procmailrc file procmail procmail helper programs used to say what is the file. By default, the file is not generated automatically.

# Vi / etc / mail / SpamAssassin / local.cf  ->Spam Assassin configuration file. Local.cf file from the website that you can create a menu format. Find related websites.

# Spamassassin-d - lint ->Check local.cf file. If there is no more than the output
# Service spamassassin restart

- dovecot IMAP / POP server
# Chkconfig dovecot on
# Service dovecot restart
# Pgrep dovecot
# Vi / etc / dovecot.conf è By default, IMAP, IMAPS, POP, POPS uses both. A good idea to limit the protocol to use.
# Protocols = POP3 IMAP IMAPS POP3S -> commented out
POP3 protocols = è only explicit use
# Netstat-a | egrep-i 'pop | imap'
-> If you use pop3s 995 times in Outlook using the settings in order to use the Encrypted POP should be separate. Do not forget the firewall must be set.

"Change-mail source>
DMkldp.org   ☞ test@test.com mail is sent from. 
Note that if you send mail, if it does not recognize your own domain
# Dj $ w.Foo.COM the "Djtest.com" less as its domain, then rerun the daemon

Linux log file management (logrotate)

 A. Introduction to logrotate
As we repeatedly emphasized in advanced courses, as well as Linux operating systems, almost all of the log file
What kind of storage and management of its size and for what has been considered as very important.
 The answer is that logrotate utility can be said.
In other words, logrotate log files in the system can manage all of these logs, cut them (rotate),
Store, delete, compress, and send e-mail allows you to perform such tasks as the.
Concrete, for example, the Apache Web server that stores the history in the weblog file is access_log.
(Of course, the name and location of this file, how much time can be used interchangeably.)
This file is saved in a day capacity is enormous. (Of course, there are some visitors from the condition).
I even managed super wepseobeoman of Korea with a capacity of about 33MB per day will be saved.
Then about one month is 990MB, so you need about 1GB of some degree would be useful.
When I put these files on the partition assigned pailsiseutempul pretty soon thereafter (Filesystem Full) after two
The system can not be down.
In particular, such as Web hosting server on one server to multiple servers running the website very
That can be serious.

Furthermore, the server is not in the weprogeuman in advanced courses, as I explained the basics of Linux
Log file is over more than 10,010.
These log files to the appropriate size cut (rotate), by compressing, archiving, or deleting tasks, such as
Will be required periodically.

logrotate cron periodically by this brilliantly played this work produces.
The role of logrotate need right here and you can see that there is one of the main reasons why logrotate was developed.
Two. Configure logrotate file
Most of the Linux logrotate installed by default as the package is installed as.
logrotate daemon and configuration files are as follows.
Nine minutes
Where and how to run
Description
Daemon (location)
/ Usr / sbin / logrotate
The location of the daemon and the daemon program
Daemon configuration file
/ Etc / logrotate.conf
Configuration file
Set the directory
/ Etc / logrotate.d
applied to the various log files logrotate to keep the directory
Situation, the file
/ Var / lib / logrotate.status
a job history files stored logrotate
cron (daily)
/ Etc / cron.daily / logrotate
logrotate is run periodically by cron daily, so be run as a becomes
First, / usr / sbin / logrotate logrotate daemon is a program that. by crond is a program that runs periodically.
/ Etc / logrotate.conf files logrotate runs as a separate log file for loading the throat of this file by setting a cut or (rotate), deleted, or will be extracted.
/ Etc / logrotate.d file, the log file for each individual configuration files and directories that exist, apply additional settings for log files is that here. For example, if you chose to install tripwire for a security check log files of the program will exist. Thus, for the management of the log file name in the appropriate directory, create a file with the settings that you want, you doegekkeum is managed by logrotate.
Finally, the / etc / cron.daily / logrotate logrotate file to be run periodically and will be placed in the cron.
In other words, this setting causes the logrotate cron once a day, which can be run periodically. 
Three. installations and upgrades and removal of logrotate
Logrotate is installed on your system before, let's check the version of the rpm package.
How to check are as follows:

In the example above, that are currently installed on your system's package logrotate logrotate-3.5.2-1 version that can be seen.

Now, using the information obtained so logrotate, let's look at the package configuration.
How to check are as follows:
Juguseong logrotate files and directories in the example above the
  • / Etc / cron.daily / logrotate
  • / Etc / logrotate.conf
  • / Etc / logrotate.d
  • / Usr / sbin / logrotate
As.
For a description of these files has been covered already in Section 2 will be omitted.

Finally, reinstall the rpm logrotate and let's look at how to upgrade.
 
How to reinstall or upgrade rpm, the example above, give the package name followed by _Uvh option is

About the configuration file for logrotate over looked.
Four. logrotate.conf sample
of logrotate configuration directory / etc / logrotate.d / syslog file in the files found are part of several.
Of course, these settings / etc / logrotate.conf even within a file can get the same results.
 
The above settings are described as follows.
/ Var / log / messages  
log file destination, ie, logrotate programs work by the absolute path specified in the log file will haedun.
And then the "{" from "}," Until the log file is set for the individual.
monthly
target log file (/ var / log / messages) is a cycle to cycle, monthly cycle, so once a month, this file (rotate) will be.
cycle Note that you'll be explained later, the daily, weekly, monthly, etc. are . For a description of this will be covered in detail later.
compress
cycle (rotate) the file is compressed by gzip. Compression is the opposite of the options nocompress is not.
(cant know, is circulating in the newly created log files are stored and not compressed.)
rotate 2 
specifies the number of files that are circulating. Will start from zero because of the example above, specifies monthly log files are stored will be able two months.
mail  
has been circulating for a specified number of log files that are passing through the mail is sent to the specified email address.
If you do not want to send mail if that is nomail.
errors
of the specified log file for logrotate task when an error occurs during the specified mail address will be sent an email to.
 
postrotate / endscript
logrotate working on it at the end of the specified log file after I have set up operations will be run.
Most work in this part are set to rotate the log files, restart the daemon operation that is
working to reverse that, logrotate If there is work to be executed before work
postrotate / endscript instead prerotate / endscript to be used.

Four. The main options logrotate
 (Note: "man logrotate" If you look logrotate option for very many. Below introduce offering options frequently used options, or my opinion, as seen think it's important that the options I've described it, so other than for options If you want to know Please refer to the man page.)

-F, - force   

force circulates. This option adds a new item after the circular log file, or already deleted the old log file is created, a new log file if logging continues, and is a useful option.

-S, - state
Wave falls on the basic situation / var / lib / logrotate.status file instead of the specified state file is used.

- Usage
simply shows the basic use of logrotate.

compress
Circular log file is compressed with gzip. nocompress opposed.

nocompress
Circulation of the log file does not extract. Compress the opposite

create mode owner group
Are rotated in the file permissions of the log file is generated (mode) and the owner (owner), and the group owner (group) is specified.
(eg, create root 600 wheel)

daily
Cycle circulates daily log file.

weekly
Circulates log files weekly intervals.

monthly
Period of one month to the log file circulates.

address errors
If an error occurs during logrotate task given is to send mail to e-mail address.

extension ext
The files generated after running logrotate rotated and attached to the extension after the name of the extension shall specify the person.
you compress with gzip compression as an option if the camera is gz extension is attached behind.
For example, the option to compress with "extension ext" If given the option file that is generated after running logrotate messages.0.ext.gz and you'll have the same look and feel

ifempty
Even if the log file is empty rotate (circular) and will be. This is the default.

notifempty
ifempty as opposed to the log file is empty, if you do not cycle.

mail address
After the old log files logrotate work with the specified email address sends mail. (In certain cases, you can not send the log file.)

postrotate / endscript
Since the action specified in logrotate task (script) is run.

prerotate / endscript
logrotate task previously assigned task (script) is run.

 rotate count
logrotate file that is circulating the results of running Let's understand that the total number of. 
ie, logrotate result of the deletion or mailed to the address specified mechanism to understand the total number of files that are 
set to rotate 0 after the previous file with the circulation deleted and discarded.

size size
The results of logrotate rotated the resulting file size should not exceed a specified size.
on how to specify the 100k, 100M, etc. If you specify capacity units are attaching. (Ie, the file size stated capacity is exceeded, rotate).
-----------------
Based on the above information was to create some logrotate. Of course, confirmed by the results.

ejabbered

/ Var / log / ejabberd / *. Log {
    Daily
    Rotate 30
    COMPRESS
    missingok
    notifempty
    sharedscripts
}

pureftpd

/ Var / log / pure-ftpd.log { 
    Daily 
    Rotate 30 
    copytruncate 
    COMPRESS 
    notifempty 
    missingok 
}