Sendmail簡單配置(2)

Sendmail 簡單配置(2)
RHEL5.3 基本網絡配置
公司採用兩個網段和兩個域來分別管理內部員工
team1.benet.com 域採用192.168.2.0/24網段
team2.benet.com 域採用192.168.3.0/24網段
DNS 及Sendmail服務器地址:192.168.1.200
要求:
(1)員工能夠自由收發內部郵件而且可以經過郵件服務器往外網發信。
(2)設置兩個郵件羣組team1和team2,確保發送給team1的郵件「team1.benet.com」域成員均可以收到,同理哈,發送給team2的郵件「team2.benet.com」域成員均可以收到。
(3)禁止待客室的主機192.168.2.100使用Sendmail服務器。
1、
1 、RHEL5 U3:如圖1
clip_p_w_picpath002
(如圖1)
2 、#hostname //查看當前主機的主機名:如圖2
clip_p_w_picpath003
(如圖2)
3 、#vi /etc/sysconfig/network-scripts/ifcfg-eth0 編輯指定網絡接口配置文件:如圖3
clip_p_w_picpath005
(如圖3)
4 、#vi /etc/sysconfig/network 經過配置文件修改主機名:如圖4
clip_p_w_picpath007
(如圖4)
5 、在終端字符界面修改其字體和中文字體大小:如圖5
clip_p_w_picpath009
(如圖5)
6 、掛載光盤:如圖6
clip_p_w_picpath011
(如圖6)
7 、查看OpenSSH是否安裝:如圖7
clip_p_w_picpath013
(如圖7)
8 #vi /etc/hosts 設置本地 DNS 解析文件: 如圖8
clip_p_w_picpath015
(如圖8)
9 #vi /etc/resolv.conf 指定當前主機的 DNS 服務器,最多可指定三個: 如圖9
clip_p_w_picpath017
(如圖9)
10 、關閉iptables防火牆:如圖10
clip_p_w_picpath018
clip_p_w_picpath020
clip_p_w_picpath022
clip_p_w_picpath024
(如圖10)
2、IP地址設置
[root@dns Server]# ifconfig
eth0 Link encap:Ethernet HWaddr 00:0C:29:DF:45:1A
inet addr:192.168.1.200 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fedf:451a/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:219 errors:0 dropped:0 overruns:0 frame:0
TX packets:149 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:35389 (34.5 KiB) TX bytes:19083 (18.6 KiB)
Interrupt:169 Base address:0x2000
eth1 Link encap:Ethernet HWaddr 00:0C:29:DF:45:24
inet addr:192.168.1.101 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fedf:4524/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:83 errors:0 dropped:0 overruns:0 frame:0
TX packets:49 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:17404 (16.9 KiB) TX bytes:8944 (8.7 KiB)
Interrupt:185 Base address:0x2080
eth2 Link encap:Ethernet HWaddr 00:0C:29:DF:45:2E
inet addr:192.168.1.102 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fedf:452e/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:78 errors:0 dropped:0 overruns:0 frame:0
TX packets:51 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:16574 (16.1 KiB) TX bytes:9072 (8.8 KiB)
Interrupt:177 Base address:0x2400
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:8 errors:0 dropped:0 overruns:0 frame:0
TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:560 (560.0 b) TX bytes:560 (560.0 b)
[root@dns Server]# vim /etc/sysconfig/network-scripts/ifcfg-eth1
# Advanced Micro Devices [AMD] 79c970 [PCnet32 LANCE]
DEVICE=eth1
BOOTPROTO=static
IPADDR=192.168.2.200
NETMASK=255.255.255.0
GATEWAY=192.168.2.1
ONBOOT=yes
HWADDR=00:0c:29:df:45:24
~
"/etc/sysconfig/network-scripts/ifcfg-eth1" 8L, 182C 已寫入
[root@dns Server]# ifdown eth1
[root@dns Server]# ifup eth1
[root@dns Server]# vim /etc/sysconfig/network-scripts/ifcfg-eth2
# Advanced Micro Devices [AMD] 79c970 [PCnet32 LANCE]
DEVICE=eth2
BOOTPROTO=static
IPADDR=192.168.3.200
NETMASK=255.255.255.0
GATEWAY=192.168.3.1
ONBOOT=yes
HWADDR=00:0c:29:df:45:2e
~
~
"/etc/sysconfig/network-scripts/ifcfg-eth2" 8L, 182C 已寫入
[root@dns Server]# ifdown eth2
[root@dns Server]# ifup eth2
[root@dns Server]# ifconfig
eth0 Link encap:Ethernet HWaddr 00:0C:29:DF:45:1A
inet addr:192.168.1.200 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fedf:451a/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:1008 errors:0 dropped:0 overruns:0 frame:0
TX packets:626 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:124798 (121.8 KiB) TX bytes:76300 (74.5 KiB)
Interrupt:169 Base address:0x2000
eth1 Link encap:Ethernet HWaddr 00:0C:29:DF:45:24
inet addr:192.168.2.200 Bcast:192.168.2.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fedf:4524/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:114 errors:0 dropped:0 overruns:0 frame:0
TX packets:87 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:25638 (25.0 KiB) TX bytes:17436 (17.0 KiB)
Interrupt:185 Base address:0x2080
eth2 Link encap:Ethernet HWaddr 00:0C:29:DF:45:2E
inet addr:192.168.3.200 Bcast:192.168.3.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fedf:452e/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:111 errors:0 dropped:0 overruns:0 frame:0
TX packets:86 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:25318 (24.7 KiB) TX bytes:16975 (16.5 KiB)
Interrupt:177 Base address:0x2400
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:8 errors:0 dropped:0 overruns:0 frame:0
TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:560 (560.0 b) TX bytes:560 (560.0 b)
[root@dns Server]# service network restart
正在關閉接口 eth0: [肯定]
正在關閉接口 eth1: [肯定]
正在關閉接口 eth2: [肯定]
關閉環回接口: [肯定]
彈出環回接口: [肯定]
彈出界面 eth0: [肯定]
彈出界面 eth1: [肯定]
彈出界面 eth2: [肯定]
[root@dns Server]#
clip_p_w_picpath026
clip_p_w_picpath028
clip_p_w_picpath030
3、DNS簡單配置
1 、vim  /etc/named.conf
clip_p_w_picpath032
named-conf-2
2 、vim  /var/named/benet.com.zone
clip_p_w_picpath036
3 、vim  /var/named/1.168.192.in-addr.arpa.zone
clip_p_w_picpath038
4 、vim  /var/named/team1.benet.com.zone
clip_p_w_picpath040
5 、vim  /var/named/2.168.192.in-addr.arpa.zone
clip_p_w_picpath042
6 、vim  /var/named/team2.benet.com.zone
clip_p_w_picpath044
7 、vim  /var/named/3.168.192.in-addr.arpa.zone
clip_p_w_picpath046
8 、nslookup查看
clip_p_w_picpath047
9 、複製named.root到/var/named/目錄下
[root@dns Server]# cd /usr/share/doc/bind-9.3.4/sample/var/named/
[root@dns named]# ls
data my.external.zone.db named.ip6.local named.zero
localdomain.zone my.internal.zone.db named.local slaves
localhost.zone named.broadcast named.root
[root@dns named]# cp named.root /var/named/
[root@dns named]# cd /var/named/
[root@dns named]# ls
1.168.192.in-addr.arpa.zone benet.com.zone slaves
2.168.192.in-addr.arpa.zone data team1.benet.com.zone
3.168.192.in-addr.arpa.zone named.root team2.benet.com.zone
clip_p_w_picpath048
10 、啓動named服務
[root@dns Server]# chkconfig --list named
named 0: 關閉 1: 關閉 2: 關閉 3: 關閉 4: 關閉 5: 關閉 6: 關閉
[root@dns Server]# chkconfig --level 2345 named on
[root@dns Server]# chkconfig --list named
named 0: 關閉 1: 關閉 2: 啓用 3: 啓用 4: 啓用 5: 啓用 6: 關閉
[root@dns Server]# tail var/log/messages
Oct 18 06:07:20 dns named[5204]: zone benet.com/IN: loaded serial 20091017
Oct 18 06:07:20 dns named[5204]: zone team1.benet.com/IN: loaded serial 20091017
Oct 18 06:07:20 dns named[5204]: zone team2.benet.com/IN: loaded serial 20091017
Oct 18 06:07:20 dns named[5204]: running
Oct 18 06:07:20 dns named[5204]: zone 3.168.192.in-addr.arpa/IN: sending notifies (serial
20091017)
Oct 18 06:07:20 dns named[5204]: zone 1.168.192.in-addr.arpa/IN: sending notifies (serial
20091017)
Oct 18 06:07:20 dns named[5204]: zone 2.168.192.in-addr.arpa/IN: sending notifies (serial
20091017)
Oct 18 06:07:20 dns named[5204]: client 192.168.1.200#42561: received notify for zone
'3.168.192.in-addr.arpa'
Oct 18 06:07:21 dns named[5204]: client 192.168.1.200#42561: received notify for zone
'1.168.192.in-addr.arpa'
Oct 18 06:07:21 dns named[5204]: client 192.168.1.200#42561: received notify for zone
'2.168.192.in-addr.arpa'
clip_p_w_picpath050
4、sendmail簡單配置
1 、安裝sendmail
[root@dns Server]# rpm -qa | grep sendmail
sendmail-8.13.8-2.el5
[root@dns Server]# ls sendmail*
sendmail-8.13.8-2.el5.i386.rpm sendmail-devel-8.13.8-2.el5.i386.rpm
sendmail-cf-8.13.8-2.el5.i386.rpm sendmail-doc-8.13.8-2.el5.i386.rpm
[root@dns Server]# rpm -ivh --aid sendmail-cf-8.13.8-2.el5.i386.rpm
warning: sendmail-cf-8.13.8-2.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
Preparing... ########################################### [100%]
1:sendmail-cf ########################################### [100%]
[root@dns Server]# rpm -ivh --aid sendmail-devel-8.13.8-2.el5.i386.rpm
warning: sendmail-devel-8.13.8-2.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
Preparing... ########################################### [100%]
1:sendmail-devel ########################################### [100%]
[root@dns Server]# rpm -ivh --aid sendmail-doc-8.13.8-2.el5.i386.rpm
warning: sendmail-doc-8.13.8-2.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
Preparing... ########################################### [100%]
1:sendmail-doc ########################################### [100%]
[root@dns Server]#
[root@dns Server]# rpm -qa | grep sendmail
sendmail-devel-8.13.8-2.el5
sendmail-doc-8.13.8-2.el5
sendmail-cf-8.13.8-2.el5
sendmail-8.13.8-2.el5
[root@dns Server]# rpm -qa | grep m4
m4-1.4.5-3.el5.1
clip_p_w_picpath052
2 、修改vim /etc/mail/sendmail.mc
第116行 將smtp偵聽範圍從 127.0.0.1 改成0.0.0.0
clip_p_w_picpath054
第155行修改爲本身域: LOCAL_DOMAIN(`benet.com')dnl
clip_p_w_picpath056
3 、使用m4命令生成sendmail.cf文件
m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf
4 、修改local-host-names文件添加域名及主機名
vim /etc/mail/local-host-names
[root@dns Server]# m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf
[root@dns Server]# vim /etc/mail/local-host-names
# local-host-names - include all aliases for your machine here.
benet.com.
mail.benet.com.
team1.benet.com.
mail.team1.benet.com.
team2.benet.com.
mail.team2.benet.com.
~
"/etc/mail/local-host-names" 7L, 169C 已寫入
clip_p_w_picpath057
五、 實現郵局aliases別名功能
vim /etc/aliases
aliases 文件語法格式:
真實用戶賬號:別名1,別名2
例如:
增長:team1: client1,client2,client3
Team2: clienta,clientb,clientc
clip_p_w_picpath059
六、 運行newaliases命令,生成aliases庫
clip_p_w_picpath060
7 配置訪問控制的access文件, 生成access數據庫文件(makemap hash /etc/mail/access.db < /etc/mail/access)
clip_p_w_picpath062
5、安裝 Dovecot 軟件包( POP3 IMAP
1 、安裝dovecot
[root@dns Server]# rpm -ivh --aid perl-DBI-1.52-2.el5.i386.rpm
warning: perl-DBI-1.52-2.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
Preparing... ########################################### [100%]
1:perl-DBI ########################################### [100%]
[root@dns Server]# rpm -ivh --aid mysql-5.0.45-7.el5.i386.rpm
warning: mysql-5.0.45-7.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
Preparing... ########################################### [100%]
1:mysql ########################################### [100%]
[root@dns Server]# rpm -ivh --aid dovecot-1.0.7-7.el5.i386.rpm
warning: dovecot-1.0.7-7.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
Preparing... ########################################### [100%]
1:dovecot ########################################### [100%]
clip_p_w_picpath064
2 、啓動sendmail和dovecot服務
[root@dns Server]# service sendmail restart
關閉 sm-client: [肯定]
關閉 sendmail: [肯定]
啓動 sendmail: [肯定]
啓動 sm-client: [肯定]
[root@dns Server]# service dovecot restart
中止 Dovecot Imap: [失敗]
啓動 Dovecot Imap: [肯定]
[root@dns Server]# chkconfig --list dovecot
dovecot 0:關閉 1:關閉 2:關閉 3:關閉 4:關閉 5:關閉 6:關閉
[root@dns Server]# chkconfig --level 2345 dovecot on
[root@dns Server]# chkconfig --list dovecot
dovecot 0:關閉 1:關閉 2:啓用 3:啓用 4:啓用 5:啓用 6:關閉
clip_p_w_picpath065
3 、查看端口netstat
[root@dns Server]# netstat -ntl
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 127.0.0.1:2208 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:688 0.0.0.0:* LISTEN
tcp 0 0 192.168.1.200:53 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:53 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:25 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:953 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:2207 0.0.0.0:* LISTEN
tcp 0 0 :::993 :::* LISTEN
tcp 0 0 :::995 :::* LISTEN
tcp 0 0 :::110 LISTEN
tcp 0 0 :::143 :::* LISTEN
tcp 0 0 :::22 :::* LISTEN
tcp 0 0 ::1:953 :::* LISTEN
[root@dns Server]# netstat -an | grep 25
tcp 0 0 0.0.0.0:25 0.0.0.0:* LISTEN
udp 0 0 0.0.0.0:52546 0.0.0.0:*
unix 2 [ ] DGRAM 8925
[root@dns Server]# netstat -an | grep 110
tcp 0 0 :::110 LISTEN
[root@dns Server]# netstat -an | grep 143
tcp 0 0 :::143 :::* LISTEN
unix 2 [ ] STREAM CONNECTED 10143 /var/run/setrans/.setrans-unix
clip_p_w_picpath067
4 、驗證Sendmail的SMTP認證功能telnet localhost 25
[root@dns Server]# telnet localhost 25
Trying 127.0.0.1...
Connected to localhost.localdomain (127.0.0.1).
Escape character is '^]'.
220 dns.benet.com ESMTP Sendmail 8.13.8/8.13.8; Sat, 10 Oct 2009 22:15:28 +0800
ehlo localhost
250-dns.benet.com Hello localhost.localdomain [127.0.0.1], pleased to meet you
250-ENHANCEDSTATUSCODES
250-PIPELINING
250-8BITMIME
250-SIZE
250-DSN
250-ETRN
250-DELIVERBY
250 HELP
quit
221 2.0.0 dns.benet.com closing connection
Connection closed by foreign host.
[root@dns Server]# telnet localhost 110
Trying 127.0.0.1...
Connected to localhost.localdomain (127.0.0.1).
Escape character is '^]'.
+OK Dovecot ready.
quit
+OK Logging out
Connection closed by foreign host.
[root@dns Server]#
clip_p_w_picpath069
telnet mail.benet.com 25
clip_p_w_picpath071
telnet mail.benet.com 110
clip_p_w_picpath073
5 、創建用戶
[root@dns Server]# useradd zhangsan
[root@dns Server]# passwd zhangsan
Changing password for user zhangsan.
New UNIX password:
BAD PASSWORD: it is based on a dictionary word
Retype new UNIX password:
passwd: all authentication tokens updated successfully.
[root@dns Server]# useradd lisi
[root@dns Server]# passwd lisi
Changing password for user lisi.
New UNIX password:
BAD PASSWORD: it is based on a dictionary word
Retype new UNIX password:
passwd: all authentication tokens updated successfully.
[root@dns Server]# groupadd team1
[root@dns Server]# groupadd team2
[root@dns Server]# useradd -g team1 -s /sbin/nologin client1
[root@dns Server]# useradd -g team1 -s /sbin/nologin client2
[root@dns Server]# useradd -g team1 -s /sbin/nologin client3
[root@dns Server]# useradd -g team2 -s /sbin/nologin clienta
[root@dns Server]# useradd -g team2 -s /sbin/nologin clientb
[root@dns Server]# useradd -g team2 -s /sbin/nologin clientc
[root@dns Server]# passwd client1
Changing password for user client1.
New UNIX password:
BAD PASSWORD: it is based on a dictionary word
Retype new UNIX password:
passwd: all authentication tokens updated successfully.
[root@dns Server]# passwd client2
Changing password for user client2.
New UNIX password:
BAD PASSWORD: it is based on a dictionary word
Retype new UNIX password:
passwd: all authentication tokens updated successfully.
[root@dns Server]# passwd client3
Changing password for user client3.
New UNIX password:
BAD PASSWORD: it is based on a dictionary word
Retype new UNIX password:
passwd: all authentication tokens updated successfully.
[root@dns Server]# passwd clienta
Changing password for user clienta.
New UNIX password:
BAD PASSWORD: it is based on a dictionary word
Retype new UNIX password:
passwd: all authentication tokens updated successfully.
[root@dns Server]# passwd clientb
Changing password for user clientb.
New UNIX password:
BAD PASSWORD: it is based on a dictionary word
Retype new UNIX password:
passwd: all authentication tokens updated successfully.
[root@dns Server]# passwd clientc
Changing password for user clientc.
New UNIX password:
BAD PASSWORD: it is based on a dictionary word
Retype new UNIX password:
passwd: all authentication tokens updated successfully.
[root@dns Server]#
clip_p_w_picpath074
6 、客戶端測試
1 )192.168.1.0/24網段測試
clip_p_w_picpath075
clip_p_w_picpath077
clip_p_w_picpath079
2 )別名測試
clip_p_w_picpath081
clip_p_w_picpath083
3 )192.168.2.0/24網段測試
clip_p_w_picpath084
clip_p_w_picpath086
clip_p_w_picpath088
4 )192.168.3.0/24網段測試
clip_p_w_picpath089
clip_p_w_picpath091
clip_p_w_picpath093
5)禁止192.168.2.100發送和接收郵件
clip_p_w_picpath094
clip_p_w_picpath096
clip_p_w_picpath098
配置文件在附件裏面:
若有不懂的地方,請call我!qq:357714938 mail:hongwish8es@126.com
相關文章
相關標籤/搜索