1.1.1. THIẾT LẬP KIỂM SOÁT MAIL CỦA NGƯỜI DÙNG
MÔ HÌNH VÀ YÊU CẦU CẤU HÌNH
HƯỚNG DẪN CẤU HÌNH
- Cấm email
- Chỉ định kích thước
CÁC BƯỚC THỰC HIỆN
a) Kiểm tra cài đặt sendmail
[root@localhost named]# rpm -qa sendmail
sendmail-8.14.4-8.el6.i686
[root@localhost named]# host dns1.serverlinux.vn
dns1.serverlinux.vn has address 192.168.1.17
[root@localhost named]# host 192.168.1.17
17.1.168.192.in-addr.arpa domain name pointer dns1.serverlinux.vn.
[root@localhost named]# host mail.serverlinux.vn
mail.serverlinux.vn is an alias for dns1.serverlinux.vn.
dns1.serverlinux.vn has address 192.168.1.17
b) Cấu hình host name
[root@linux ~]# vi /etc/hosts
127.0.0.1 localhost.localdomain serverlinux.vn
::1 localhost6.localdomain6 localhost6
192.168.1.17 Linux serverlinx.vn
c) Cấu hình /etc/mail/sendmail.cf
81 # my LDAP cluster
82 # need to set this before any LDAP lookups are done (including classes)
83 #D{sendmailMTACluster}$m
84
85 Cwlocalhost serverlinux.vn
86 # file containing names of hosts for which we receive email
87 Fw/etc/mail/local-host-names
88
89 # my official domain name
90 # ... define this only if sendmail cannot automatically determine your domain
91 #Dj$w.Foo.COM
……
259 # SMTP daemon options
260
261 #O DaemonPortOptions=Port=smtp,Addr=127.0.0.1, Name=MTA
262 O DaemonPortOptions=Name=MTA
263 # SMTP client options
264 #O ClientPortOptions=Family=inet, Address=0.0.0.0
d) Cấu hình cấm truy cập /etc/mail/access
[root@localhost mail]# vi access
# Check the /usr/share/doc/sendmail/README.cf file for a description
# of the format of this file. (search for access_db in that file)
# The /usr/share/doc/sendmail/README.cf is part of the sendmail-doc
# package.
#
# If you want to use AuthInfo with "M:PLAIN LOGIN", make sure to have the
# cyrus-sasl-plain package installed.
#
# By default we allow relaying from localhost...
Connect:localhost.localdomain RELAY
Connect:localhost RELAY
Connect:127.0.0.1 RELAY
Connect:serverlinux.vn RELAY
Connect:192.168.1.18 RELAY
u2@serverlinux.vn REJECT
e) Khởi động sendmail
[root@localhost mail]# makemap hash access < access
[root@localhost mail]# /etc/init.d/sendmail restart
Shutting down sendmail: [ OK ]
Starting sendmail: [ OK ]
Starting sm-client: [ OK ]
f) Kiểm tra hoạt động của sendmail port 25
[root@localhost mail]# netstat -an|grep 25
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN
udp 0 0 192.168.1.255:137 0.0.0.0:*
udp 0 0 172.16.29.255:137 0.0.0.0:*
udp 112592 0 172.16.29.255:137 0.0.0.0:*
udp 0 0 192.168.1.255:138 0.0.0.0:*
udp 0 0 172.16.29.255:138 0.0.0.0:*
udp 59104 0 172.16.29.255:138 0.0.0.0:*
unix 2 [ ACC ] STREAM LISTENING 13525 /var/lib/mysql/mysql.sock
unix 2 [ ACC ] STREAM LISTENING 17538 /tmp/.ICE-unix/2513
…………………………………………………………………….
unix 3 [ ] STREAM CONNECTED 15925
unix 3 [ ] STREAM CONNECTED 12530
unix 3 [ ] STREAM CONNECTED 12529
g) kiểm tra tài khoản trong /etc/passwd
[root@localhost named]# vi /etc/passwd
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
……………………………………………………………………….
named:x:25:25:Named:/var/named:/sbin/nologin
hv1:x:503:503::/home/hv1:/bin/bash
squid:x:23:23::/var/spool/squid:/sbin/nologin
mailnull:x:47:47::/var/spool/mqueue:/sbin/nologin
smmsp:x:51:51::/var/spool/mqueue:/sbin/nologin
Từ root gửi mail đến user hv1
[root@localhost mail]# mail -v hv1@serverlinux.vn
Subject: test
test
.
EOT
hv1@serverlinux.vn... Connecting to [127.0.0.1] via relay...
220 localhost.localdomain ESMTP Sendmail 8.14.4/8.14.4; Thu, 22 Dec 2011 13:59:10 -0500
……………………………..
root... Sent (pBMIxA8F003194 Message accepted for delivery)
Closing connection to [127.0.0.1]
>>> QUIT
221 2.0.0 localhost.localdomain closing connection
h) Đăng nhập vào user hv1 và kiểm tra mail
[root@dns1 mail]# su - hv1
[hv1@dns1 ~]$ mail
Mail version 8.1 6/6/93. Type ? for help.
"/var/spool/mail/hv1": 1 message 1 new
>N 1 root@dns1.serverlinu Mon Nov 7 03:16 16/632 "test"
& 1 [ENTER]
root@dns1.serverlinu Mon Nov 7 03:16 16/632 "test"
& 1
Message 1:
From root@dns1.serverlinux.vn Mon Nov 7 03:16:21 2011
Date: Mon, 7 Nov 2011 03:16:21 +0700
From: root <root@dns1.serverlinux.vn>
To: hv1@serverlinux.vn
Subject: test
test hv1
&quit [ENTER]
i) Từ user hv1 gửi mail cho user hv2
[hv1@dns1 ~]$ mail -v hv2@serverlinux.vn
Subject: chao
chao^@^@hv2
.
Cc:
hv2@serverlinux.vn... Connecting to [127.0.0.1] via relay...
220 dns1.serverlinux.vn ESMTP Sendmail 8.13.8/8.13.8; Mon, 7 Nov 2011 03:21:52 +0700
…………………………………………….
250 2.1.5 <hv2@serverlinux.vn>... Recipient ok
354 Enter mail, end with "." on a line by itself
>>> .
250 2.0.0 pA6KLqI2007640 Message accepted for delivery
hv2@serverlinux.vn... Sent (pA6KLqI2007640 Message accepted for delivery)
Closing connection to [127.0.0.1]
>>> QUIT
j) Đăng nhập vào user hv2 và kiểm tra mail
[hv1@dns1 ~]$ su - hv2
Password:
[hv2@dns1 ~]$ mail
Mail version 8.1 6/6/93. Type ? for help.
"/var/spool/mail/hv2": 1 message 1 new
>N 1 hv1@dns1.serverlinux Mon Nov 7 03:21 16/617 "chao"
& 1
Message 1:
From hv1@dns1.serverlinux.vn Mon Nov 7 03:21:52 2011
Date: Mon, 7 Nov 2011 03:21:52 +0700
From: hv1@dns1.serverlinux.vn
To: hv2@serverlinux.vn
Subject: chao
chao
& quit
Saved 1 message in mbox
k) Từ user hv2 gửi mail cho root
[hv2@dns1 ~]$ mail -v root@serverlinux.vn
Subject: chao root
chao root
.
Cc:
root@serverlinux.vn... Connecting to [127.0.0.1] via relay...
220 dns1.serverlinux.vn ESMTP Sendmail 8.13.8/8.13.8; Mon, 7 Nov 2011 03:26:32 +0700
……………………………………………….
root@serverlinux.vn... Sent (pA6KQWNo007678 Message accepted for delivery)
Closing connection to [127.0.0.1]
>>> QUIT
221 2.0.0 dns1.serverlinux.vn closing connection
[hv2@dns1 ~]$
l) Đăng nhập trở lại root và kiểm tra mail
[root@dns1 mail]# mail
Mail version 8.1 6/6/93. Type ? for help.
"/var/spool/mail/root": 6 messages 6 new
>N 1 logwatch@localhost.l Wed Oct 19 07:21 45/1748 "Logwatch for localhost.localdoma"
……………………………………………
N 6 hv2@dns1.serverlinux Mon Nov 7 03:26 16/630 "chao root"
& 6
Message 6: <Nhập vào mail cần xem>
From hv2@dns1.serverlinux.vn Mon Nov 7 03:26:32 2011
Date: Mon, 7 Nov 2011 03:26:32 +0700
From: hv2@dns1.serverlinux.vn
To: root@serverlinux.vn
Subject: chao root
chao root
& quit
Saved 1 message in mbox
Held 5 messages in /var/spool/mail/root
m)Giới hạn dụng lượng gửi mail
#Thay đổi dòng 183
180
181 # maximum message size
182 #O MaxMessageSize=0
183 O MaxMessageSize=5000000
184
185 # substitution for space (blank) characters
186 O BlankSub=.
187
188 # avoid connecting to "expensive" mailers on initial submission?
189 O HoldExpensive=False