Previous |
Home | Next |
Versions: | - sendmail 8.13.6 |
- dovecot 1.0 | |
- clamav 0.88.2 | |
- clamav-milter 0.88.2 | |
- spamassassin 3.1.3 |
MUA: Mail User Agent | The
email application that a user
sends/receives (thunderbird,pine,outlook) |
MTA:
Mail Transport Agent |
The
server agent responsible for
sending the emails (sendmail,postfix,qmail) |
MDA:
Mail Delivery Agent |
The
server agent that accepts email
from MTA, and places into users mailbox (procmail) |
SMTP:
Simple Mail Transport Protocol |
MUAs
and MTAs use this protocol for
sending emails |
POP3:
Post Office Protocol (Ver 3) |
MUAs
use this protocol for receiving
their emails from the final server |
IMAP: Internet Message Access Protocol | MUAs
can use this protocol to send and
receive emails on the servers |
The preferred email protocol for this
configuration is IMAPS as all emails are stored on the main server and
then replicated through to your MUA client when it connects. Because
the mail files on the server and client are synchronised, the webmail
application will have all the emails contained on your local
workstation and vice versa, including sent emails. |
[bash]# cp
/etc/mail/sendmail.cf
/etc/mail/sendmail.cf.original |
Do not edit sendmail's
"cf" file, use the "mc" macro file to
make the changes. This backup is only a precautionary measure in case
everything goes bad. |
[bash]# cp
/etc/mail/sendmail.mc
/etc/mail/sendmail.mc.original [bash]# vi /etc/mail/sendmail.mc |
define(`confDOMAIN_NAME',
`example.com')dnl FEATURE(`relay_entire_domain')dnl |
dnl
define(`SMART_HOST',`smtp.your.provider')dnl |
DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1, Name=MTA')dnl | Only
local server can send email |
DAEMON_OPTIONS(`Port=smtp, Name=MTA')dnl | Users
can now connect to send email |
define(`ALIAS_FILE', `/etc/aliases')dnl |
FEATURE(`virtusertable',`hash -o /etc/mail/virtusertable.db')dnl |
If alias file (/etc/aliases)
is adjusted, it needs to be updated with the "newaliases"
command before
settings are implemented. |
FEATURE(`access_db',`hash -T<TMPF> -o /etc/mail/access.db')dnl |
# Example of
/etc/mail/access localhost.localdomain RELAY localhost RELAY 127.0.0.1 RELAY 192.168.1 RELAY example.com RELAY |
dnl FEATURE(`accept_unresolvable_domains')dnl |
You should consult the
README file for further details on
available settings ("/usr/share/sendmail-cf/README"). |
[bash]# cp /etc/aliases /etc/aliases.original [bash]# vi /etc/aliases |
# Our Own Aliases www: root admin: root sysadmin: root webmaster: root support: helpdesk # Person who should get root's mail root: john <-- John will receive all system/security email alerts meant for root. # People who have left our organisation - Mail redirection... sarah: [email protected] tom: [email protected] |
[bash]# vi /etc/mail/mailing-list |
[email protected] [email protected] [email protected] |
[bash]# vi /etc/aliases |
# Our Own Aliases sysadmins: john,mark,lisa mailing-list: :include:/etc/mail/mailing-list |
[bash]# newaliases |
/etc/aliases: 97 aliases, longest 31 bytes, 998 bytes total |
[bash]# cp
/etc/dovecot.conf /etc/dovecot.conf.original [bash]# vi /etc/dovecot.conf |
protocols = imap pop3 login_dir = /var/run/dovecot/login login_chroot = yes login_user = dovecot protocol imap { login_executable = /usr/libexec/dovecot/imap-login mail_executable = /usr/libexec/dovecot/imap login_greeting_capability = yes } protocol pop3 { login_executable = /usr/libexec/dovecot/pop3-login mail_executable = /usr/libexec/dovecot/pop3 pop3_enable_last = no } auth_executable = /usr/libexec/dovecot/dovecot-auth auth_process_size = 256 auth_cache_ttl = 3600 auth default { mechanisms = plain user = root ssl_require_client_cert = no passdb pam { } userdb passwd { } } |
If you plan on setting
up SquirrelMail for your webmail requirements, you will need to have the IMAP
protocol enabled. |
[bash]# useradd -c "Alice Jones" -s
/sbin/nologin alice |
[bash]# make -C /etc/mail |
[bash]# chkconfig
--level 2345 sendmail on [bash]# chkconfig --level 2345 dovecot on [bash]# chkconfig --list sendmail [bash]# chkconfig --list dovecot |
[bash]# /etc/init.d/sendmail
restart [bash]# /etc/init.d/dovecot restart |
[bash]# grep sendmail /var/log/maillog [bash]# grep dovecot /var/log/maillog |
[bash]# telnet localhost 25 |
(CUT AND PASTE BELOW TEXT) (Change "RCPT To:" email address) HELO example.com MAIL From: [email protected] RCPT To: [email protected] <-- Change this to your own email to see results. DATA Subject: Think we're insecure... I have a feeling our mail server is being abused... . QUIT |
[bash]# telnet relay-test.mail-abuse.org |
If any of the open relay tests return
serious warnings, you should seriously check your systems configuration
- guaranteed your system will be exploited. |
[bash]# vi /etc/mail/sendmail.mc |
define(`confMAX_MESSAGE_SIZE',`52428800')dnl |
## ONLY NEEDED TO SUPPORT PHP WEBMAIL
## [bash]# vi /etc/php.ini post_max_size = 50M upload_max_filesize = 50M memory_limit = 64M |
define(`confMAX_DAEMON_CHILDREN',`5')dnl define(`confCONNECTION_RATE_THROTTLE',`3')dnl define(`confMAX_RCPTS_PER_MESSAGE',`50')dnl |
[bash]# vi /etc/mail/sendmail.mc |
define(`confAUTH_OPTIONS', `A p')dnl |
TRUST_AUTH_MECH(`EXTERNAL DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl define(`confAUTH_MECHANISMS', `EXTERNAL GSSAPI DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl |
define(`confCACERT_PATH',`/etc/pki/tls/certs')dnl define(`confCACERT',`/etc/pki/tls/certs/ca-bundle.crt')dnl define(`confSERVER_CERT',`/etc/pki/tls/certs/sendmail.pem')dnl define(`confSERVER_KEY',`/etc/pki/tls/certs/sendmail.pem')dnl |
DAEMON_OPTIONS(`Port=smtps, Name=TLSMTA, M=s')dnl |
The bottom option causes sendmail to
additionally listen for secure connections on port 465 through enforced
SSL. Basic SMTP is still configured through port 25 for remote MTA
connections and TLS. |
Change This: DAEMON_OPTIONS(`Port=smtp, Name=MTA')dnl |
Back To: DAEMON_OPTIONS(`Port=smtp, Addr=127.0.0.1, Name=MTA')dnl |
[bash]# cd /etc/pki/tls/certs [bash]# make sendmail.pem |
Country Name (2 letter code) [GB]:AU State or Province Name (full name) [Berkshire]:QLD Locality Name (eg, city) [Newbury]:Brisbane Organization Name (eg, company) [My Company Ltd]:Miles Brennan Organizational Unit Name (eg, section) []:Home Linux Server Common Name (eg, your name or your server's hostname) []:galaxy.example.com Email Address []:[email protected] |
[bash]# vi /etc/dovecot.conf |
ssl_disable = no ssl_verify_client_cert = no ssl_parameters_regenerate = 168 ssl_cipher_list = ALL:!LOW ssl_cert_file = /etc/pki/tls/certs/sendmail.pem <-- NOTE: Can use same certificate as Sendmail ssl_key_file = /etc/pki/tls/certs/sendmail.pem <-- NOTE: Can use same certificate as Sendmail disable_plaintext_auth = yes |
Change This: protocols = imap pop3 |
To This: protocols = imaps pop3s |
[bash]# /etc/init.d/sendmail
restart [bash]# /etc/init.d/dovecot restart |
[bash]# vi /root/firewall.sh |
# New INBOUND Connection: SMTP and SMTPS (over SSL) iptables -A INPUT -i $EXT_DEV -m state --state NEW -m tcp -p tcp --syn --dport 25 -j ACCEPT <-- for TLS encryption (and basic SMTP) iptables -A INPUT -i $EXT_DEV -m state --state NEW -m tcp -p tcp --syn --dport 465 -j ACCEPT <-- for SSL encryption # New INBOUND Connection: IMAPS Email Clients (Secure Link - In and Out) iptables -A INPUT -i $EXT_DEV -m state --state NEW -m tcp -p tcp --syn --dport 993 -j ACCEPT <-- for SSL encryption |
[bash]# /root/firewall.sh |
[bash]# vi /etc/dovecot.conf |
protocols = imap imaps pop3s protocol imap { listen = 127.0.0.1 ssl_listen = * ssl_disable = no } |
The above Dovecot settings allow for
the IMAP based SquirrelMail application to work on the local server
without requiring TLS/SSL encryption. A remote user will still
interface the HTTPS web interface through SSL, ensuring secure access
through a web browser. |
[bash]# yum install clamav* |
[bash]# cp /etc/clamd.d/milter.conf /etc/clamd.d/milter.conf.original [bash]# vi /etc/clamd.d/milter.conf |
#Example <-- This must be commented out before the daemon will function LogFile /var/log/clamd.milter LogFileMaxSize 5M LogTime DatabaseDirectory /var/lib/clamav LocalSocket /var/run/clamd.milter/clamd.sock FixStaleSocket #TCPAddr 127.0.0.1 #TCPSocket 3310 User clamilt ScanMail ScanHTML DetectBrokenExecutables ArchiveBlockEncrypted |
[bash]# cp
/etc/sysconfig/clamav-milter
/etc/sysconfig/clamav-milter.original [bash]# vi /etc/sysconfig/clamav-milter |
CLAMAV_FLAGS="--local \ --bounce \ --advisory \ --force-scan \ --dont-wait \ --dont-log-clean \ --max-children=2 \ --server=localhost \ [email protected] \ --config-file=/etc/clamd.d/milter.conf \ --pidfile=/var/run/clamav-milter/milter.pid \ --signature-file=/etc/mail/clamav-email-signature \ local:/var/run/clamav-milter/clamav.sock " CLAMAV_USER='clamilt' |
[bash]# vi /etc/mail/clamav-email-signature |
_________________________________ This email has been ClamScanned ! www.clamav.net |
[bash]# chkconfig
--level 2345 clamav-milter on [bash]# chkconfig --list clamav-milter |
[bash]# /etc/init.d/clamav-milter restart |
[bash]# vi /etc/mail/sendmail.mc |
INPUT_MAIL_FILTER(`clamav-milter', `S=local:/var/run/clamav-milter/clamav.sock, F=T,T=S:4m;R:4m;E:10m') |
[bash]# make -C /etc/mail [bash]# /etc/init.d/sendmail restart |
[bash]# grep Milter /var/log/maillog |
sendmail: Milter add: header: X-Virus-Scanned: ClamAV version 0.88.2, clamav-milter version 0.88.2 on galaxy.example.com sendmail: Milter add: header: X-Virus-Status: Clean |
X-Virus-Scanned: ClamAV version 0.88.2, clamav-milter version 0.88.2 on galaxy.example.com X-Virus-Status: Clean |
[bash]# echo 'X5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*' | mail [email protected] |
To: [email protected] X-Virus-Scanned: ClamAV version 0.88.2, clamav-milter version 0.88.2 on galaxy.example.com X-Virus-Status: Infected with Eicar-Test-Signature Subject: [Virus] Eicar-Test-Signature |
More information about the EICAR test antivirus signature can be seen at this site: http://www.eicar.org/anti_virus_test_file.htm |
[bash]# vi /etc/sysconfig/freshclam |
FRESHCLAM_MOD=180 <-- Update interval in minutes #FRESHCLAM_DELAY=disabled-warn <-- Add "#" to activate (enable) clamav updates |
[bash]# cp
/etc/freshclam.conf /etc/freshclam.conf.original [bash]# vi /etc/freshclam.conf |
#Example DatabaseOwner clamav DatabaseDirectory /var/lib/clamav Checks 24 MaxAttempts 5 UpdateLogFile /var/log/freshclam.log DNSDatabaseInfo current.cvd.clamav.net DatabaseMirror db.??.clamav.net ### <-- See Note. DatabaseMirror database.clamav.net #HTTPProxyServer galaxy.example.com #HTTPProxyPort 3128 #HTTPProxyUsername username #HTTPProxyPassword password |
Replace "??"
(above) with
the two letter country code for your region, or remove line from configuration file if you are unsure. |
[bash]# freshclam |
ClamAV update process started at Sun May 21 12:01:57 2006 main.cvd is up to date (version: 38, sigs: 51206, f-level: 7, builder: tkojm) Downloading daily.cvd [*] daily.cvd updated (version: 1472, sigs: 4793, f-level: 8, builder: arnaud) Database updated (55999 signatures) from db.au.clamav.net (IP: 61.8.0.16) |
[bash]# tail /var/log/freshclam.log |
[bash]# yum install spamass-milter spamassassin |
[bash]# cp /etc/mail/spamassassin/v310.pre /etc/mail/spamassassin/v310.pre.original [bash]# vi /etc/mail/spamassassin/v310.pre |
loadplugin Mail::SpamAssassin::Plugin::DCC loadplugin Mail::SpamAssassin::Plugin::Pyzor loadplugin Mail::SpamAssassin::Plugin::Razor2 loadplugin Mail::SpamAssassin::Plugin::SpamCop loadplugin Mail::SpamAssassin::Plugin::AWL loadplugin Mail::SpamAssassin::Plugin::AutoLearnThreshold loadplugin Mail::SpamAssassin::Plugin::WhiteListSubject loadplugin Mail::SpamAssassin::Plugin::MIMEHeader loadplugin Mail::SpamAssassin::Plugin::ReplaceTags |
[bash]# cp /etc/mail/spamassassin/local.cf /etc/mail/spamassassin/local.cf.original [bash]# vi /etc/mail/spamassassin/local.cf |
required_score 5.0 rewrite_header subject [SPAM] report_safe 1 use_bayes 1 use_bayes_rules 1 bayes_auto_learn 1 skip_rbl_checks 0 use_razor2 1 use_dcc 1 use_pyzor 1 trusted_networks 192.168.1/24 127/8 internal_networks 192.168.1/24 127/8 |
If you need assistance in determining which configuration options are the best for your system, you can use the online "SpamAssassin Configuration Generator" located at: "http://www.yrex.com/spam/spamconfig.php". your customised online configuration can then be downloaded into your /etc/mail/spamassassin/local.cf file. |
[bash]# cp /etc/sysconfig/spamassassin /etc/sysconfig/spamassassin.original [bash]# vi /etc/sysconfig/spamassassin |
SPAMDOPTIONS="-d -c -l -m5 -H" |
[/home/miles]$ vi ~/.spamassassin/user_prefs <-- executed as basic user |
[bash]# cp /etc/sysconfig/spamass-milter /etc/sysconfig/spamass-milter.original [bash]# vi /etc/sysconfig/spamass-milter |
SOCKET=/var/run/spamass-milter/spamass-milter.sock EXTRA_FLAGS="-r 15" |
[bash]# chkconfig
--level 2345 spamassassin on [bash]# chkconfig --level 2345 spamass-milter on [bash]# chkconfig --list spamassassin [bash]# chkconfig --list spamass-milter |
[bash]# /etc/init.d/spamassassin restart [bash]# /etc/init.d/spamass-milter restart |
[bash]# spamassassin -t < /usr/share/doc/spamassassin-3*/sample-nonspam.txt | grep X-Spam |
X-Spam-Checker-Version: SpamAssassin 3.1.1 (2006-03-10) on galaxy.example.com X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=unavailable |
[bash]# spamassassin -t < /usr/share/doc/spamassassin-3*/sample-spam.txt | grep X-Spam |
X-Spam-Flag: YES X-Spam-Checker-Version: SpamAssassin 3.1.1 (2006-03-10) on galaxy.example.com X-Spam-Level: ************************************************** X-Spam-Status: Yes, score=1000.0 required=5.0 tests=GTUBE,NO_RECEIVED, |
[bash]# vi /etc/mail/sendmail.mc |
INPUT_MAIL_FILTER(`spamassassin', `S=unix:/var/run/spamass-milter/spamass-milter.sock, F=, T=C:15m;S:4m;R:4m;E:10m')dnl define(`confMILTER_MACROS_CONNECT',`t, b, j, _, {daemon_name}, {if_name}, {if_addr}')dnl define(`confMILTER_MACROS_HELO',`s, {tls_version}, {cipher}, {cipher_bits}, {cert_subject}, {cert_issuer}')dnl |
[bash]# make -C /etc/mail [bash]# /etc/init.d/sendmail restart |
Previous |
Home | Next |