Postfixを動かしてみる
Modified: 10 February 2004
Postfixのパッケージ
RedhatLinux7.3のCDに入っています。
ソースコードは、以下からダウンロードできます。
http://www.postfix.org
sendmailの削除
"postfix"をインストールする前に、"sendmail"を削除します。
# rpm -e mutt
# rpm -e fetchmail
# rpm -e sendmail
パッケージのインストール
# rpm -ivh postfix-1.1.7-2.i386.rpm
Preparing... ########################################### [100%]
1:postfix ########################################### [100%]
#
"/etc/postfix/main.cf"の基本設定
最低限、以下のように変更します。(変更箇所は、赤い色を付けています。)
最低限、以下の5つを指定します。
myhostname, mydomain, myorigin, inet_interfaces, mynetworks
# Global Postfix configuration file. This file lists only a subset
# of all 100+ parameters. See the sample-xxx.cf files for a full list.
#
# The general format is lines with parameter = value pairs. Lines
# that begin with whitespace continue the previous line. A value can
# contain references to other $names or ${name}s.
#
# NOTE - CHANGE NO MORE THAN 2-3 PARAMETERS AT A TIME, AND TEST IF
# POSTFIX STILL WORKS AFTER EVERY CHANGE.
:
:
:
# INTERNET HOST AND DOMAIN NAMES
#
# The myhostname parameter specifies the internet hostname of this
# mail system. The default is to use the fully-qualified domain name
# from gethostname(). $myhostname is used as a default value for many
# other configuration parameters.
#
myhostname = rh73-93-mail-postfix.tomo.ac
# The mydomain parameter specifies the local internet domain name.
# The default is to use $myhostname minus the first component.
# $mydomain is used as a default value for many other configuration
# parameters.
#
mydomain = tomo.ac
# SENDING MAIL
#
# The myorigin parameter specifies the domain that locally-posted
# mail appears to come from. The default is to append $myhostname,
# which is fine for small sites. If you run a domain with multiple
# machines, you should (1) change this to $mydomain and (2) set up
# a domain-wide alias database that aliases each user to
# user@that.users.mailhost.
#
#myorigin = $myhostname
myorigin = $mydomain
# RECEIVING MAIL
# The inet_interfaces parameter specifies the network interface
# addresses that this mail system receives mail on. By default,
# the software claims all active interfaces on the machine. The
# parameter also controls delivery of mail to user@[ip.address].
#
#inet_interfaces = localhost
inet_interfaces = all
#inet_interfaces = $myhostname
#inet_interfaces = $myhostname, localhost
:
:
:
# Specify a list of host or domain names, /file/name or type:table
# patterns, separated by commas and/or whitespace. A /file/name
# pattern is replaced by its contents; a type:table is matched when
# a name matches a lookup key. Continue long lines by starting the
# next line with whitespace.
#
mydestination = $myhostname, $mydomain
#mydestination = $myhostname, localhost.$mydomain $mydomain
#mydestination = $myhostname, localhost.$mydomain, $mydomain,
# mail.$mydomain, www.$mydomain, ftp.$mydomain
:
:
:
# Alternatively, you can specify the mynetworks list by hand, in
# which case Postfix ignores the mynetworks_style setting.
#
# Specify an explicit list of network/netmask patterns, where the
# mask specifies the number of bits in the network part of a host
# address.
#
# You can also specify the absolute pathname of a pattern file instead
# of listing the patterns here. Specify type:table for table-based lookups
# (the value on the table right-hand side is not used).
#
#mynetworks = 168.100.189.0/28, 127.0.0.0/8
#mynetworks = $config_directory/mynetworks
#mynetworks = hash:/etc/postfix/network_table
mynetworks = 192.168.0.0/24, 127.0.0.1/8
:
:
:
# readme_directory: The location of the Postfix README files.
#
readme_directory = /etc/postfix/README_FILES
alias_database = hash:/etc/postfix/aliases
"inet_interfaces = all"を指定しないと、postfixをインストールしているPCしか利用できません。つまり、他のPCから利用できません。
(つまり、"inet_interfaces = all"を指定しないと、ポート25が開きません。)
設定の確認
以下のコマンドで設定の確認をします。
# /usr/sbin/postfix check
#何も出ず、プロンプトが帰ってきたら設定はOKです。
起動する
コマンドでは、以下のように行います。
# /etc/init.d/postfix start 停止は、以下のコマンドで行います。
# /etc/init.d/postfix stop 再起動は、以下のコマンドで行います。
# /etc/init.d/postfix restart Webminでの起動は、Webminの「システム」から、「起動およびシャットダウン」の「Postfix」を選択した以下の画面で設定できます。
起動の確認
以下のプロセスが起動しておればOKです。
:
903 ? S 0:00 /usr/libexec/postfix/master
906 ? S 0:00 pickup -l -t fifo -u -c
907 ? S 0:00 nqmgr -l -n qmgr -t fifo -u -c
:また、ログは、以下のようにエラーが出ていなければOKです。
:
Nov 23 19:42:44 rh73-93-mail-postfix postfix/master[4575]: daemon startednmapで、ポート25を確認してみます。
# nmap 192.168.0.193
Starting nmap V. 2.54BETA31 ( www.insecure.org/nmap/ )
Interesting ports on rh73-93-mail-postfix.tomo.ac (192.168.0.193):
(The 1549 ports scanned but not shown below are in state: closed)
Port State Service
22/tcp open ssh
25/tcp open smtp
139/tcp open netbios-ssn
199/tcp open smux
10000/tcp open snet-sensor-mgmt
Nmap run completed -- 1 IP address (1 host up) scanned in 1 second
#
自動起動させる
自動起動は、Webminの「システム」から、「起動およびシャットダウン」の「Postfix」を選択した以下の画面で設定できます。
設定が完了すると、以下のように「はい」となります。