Windows XP SP2のファイアウォール機能

メール送信に時間がかかるのは、Windowsファイアウォールのせいだった。
telnet 192.168.0.5 25 としても、やけに接続に時間がかかることから気づいた。
http://www.astec.co.jp/products/ASTECX/FAQ/xp_sp2_fw.html#problem
を参考に、IDENT(113)ポートを開けると、解決した。
他にも、参考になるページがあった。以後のトラブルシュートの備忘のために。
http://cyberwonk.org/ken/blog/archives/200411/001351.html

eximを使った送信のエラー

Thunderbirdで送信するとやけに時間がかかる。Wanderlustでは「No Authentificationなんとか」になるし…。
ログを漁ってみたら、
2004-12-29 22:26:58 1Cjdqs-0003u4-00 failed to open database lock file /var/spool/exim/db/wait-remote_smtp.lockfile: Permission denied (euid=8 egid=8)
というメッセージが多数。ググってみると、3件だけヒット(これだからマイナーMTAは困る)。
# cd /var/spool/exim/db
rick:/var/spool/exim/db# chown mail:mail wait-remote_smtp*
これで解決したはず。
参考
http://n9d.miyoshi.cx/wiki/exim
http://washitake.com/mail/exim

eximのリレー設定

SquirrelMailからはメール送信できるが、LANのクライアントからは送信できないことに気づいた。リレーの設定がまだだったのか…。
host_accept_relay = 127.0.0.1:192.168.0.0/24
http://washitake.com/mail/exim/install.php の通りに設定すればできた!
eximは情報が少ないから、助かった。

12月月24日と表示される

SquirrelMailの導入が完了したと喜んでいたら、
メッセージのヘッダ部分の日付が「月月」となってしまう。
これは、SquirrelMailのサイトでも報告されている。
さらに調べてみると、gettextが必要とのこと。

# apt-get gettext
# cd /usr/share/squirrelmail/po
# ./compilepo ja_JP
Compiling ../locale/ja_JP/LC_MESSAGES/squirrelmail.po
# apachectl restart
/usr/sbin/apachectl restart: httpd restarted

これで解決した。

SquirrelMail(Webメール)

どこからでもメールを送受信できるようにする。
http://everybody.good-day.net/~nsaito/squirrelmail/ からパッケージを入手。debianのapt lineで最新が公開されていた。

apt-get install squirrelmail
/usr/sbin/squirrelmail-configure
SquirrelMail Configuration : Read: config.php (1.4.0)
———————————————————
Main Menu —
1. Organization Preferences
2. Server Settings
3. Folder Defaults
4. General Options
5. Themes
6. Address Books
7. Message of the Day (MOTD)
8. Plugins
9. Database
10. Languages
D. Set pre-defined settings for specific IMAP servers
C Turn color on
S Save data
Q Quit
Command >>

– D. で courier を選択
– 10. Language で、ja_JP を選択
– 1. Organization Preferences は表示のための設定のため、趣味で設定
この設定は、/etc/squirrelmail/config.php に保存される。
/etc/httpd.conf に以下を追加

Include /etc/squirrelmail/apache.conf

apache.confへ以下のようなものを追加

Alias /squirrelmail /usr/share/squirrelmail
<Directory /usr/share/squirrelmail>
php_flag register_globals off
Options Indexes FollowSymLinks
<IfModule mod_dir.c>
DirectoryIndex index.php
</IfModule>
order deny,allow
deny from all
allow from all
# access to configtest is limited by default to prevent information leak
<Files configtest.php>
order deny,allow
deny from all
allow from 127.0.0.1
</Files>
</Directory>
# users will prefer a simple URL like http://webmail.example.com
<VirtualHost *:80>
DocumentRoot /usr/share/squirrelmail
ServerName webmail.dokka.wakaran.com
</VirtualHost>

courier-imap

モバイル用途と、Webメールの導入を意識しimapを導入する。

apt-get install courier-imap

これで終わり。
と思ったら、courierはmboxに対応していないので、local配送をMaildir形式にする必要があった。
http://www.mkusunoki.net/z-gypsy/linux/courier-imap

exim

自宅サーバでメールも運用することにする。
Debianでは、eximというMTAが標準で導入されているが…。
http://www.pen-chan.jp/net/set/exim.html
とほぼ同じに設定を進める。

rick:/etc/exim# eximconfig
I can do some automatic configuration of your mail system, by asking
you a number of questions. Later you may have to confirm and/or correct
your answers. In any case, comprehensive information on configuring exim is
in the eximdoc package and in /usr/share/doc/exim/spec.txt
[—Press return—]
==============================================================================
You must choose one of the options below:
(1) Internet site; mail is sent and received directly using SMTP. If your
needs don’t fit neatly into any category, you probably want to start
with this one and then edit the config file by hand.
(2) Internet site using smarthost: You receive Internet mail on this
machine, either directly by SMTP or by running a utility such as
fetchmail. Outgoing mail is sent using a smarthost. optionally with
addresses rewritten. This is probably what you want for a dialup
system.
(3) Satellite system: All mail is sent to another machine, called a “smart
host” for delivery. root and postmaster mail is delivered according
to /etc/aliases. No mail is received locally.
(4) Local delivery only: You are not on a network. Mail for local users
is delivered.
(5) No configuration: No configuration will be done now; your mail system
will be broken and should not be used. You must then do the
configuration yourself later or run this script, /usr/sbin/eximconfig,
as root. Look in /usr/share/doc/exim/example.conf.gz
Select a number from 1 to 5, from the list above.
Enter value (default=`1′, `x’ to restart): 1
==============================================================================
What is the `visible’ mail name of your system? This will appear on
From: lines of outgoing messages.
Enter value (default=`rick’, `x’ to restart): hayate.mine.nu
==============================================================================
Does this system have any other names which may appear on incoming
mail messages, apart from the visible name above (hayate.mine.nu) and
localhost?
By default all domains will be treated the same; if you want different
domain names to be treated differently, you will need to edit the config
file afterwards: see the documentation for the “domains” director
option.
If there are any more, enter them here, separated with spaces or commas.
If there are none, say `none’.
Enter value (default=`none’, `x’ to restart): komachi.mine.nu
==============================================================================
All mail from here or specified other local machines to anywhere on
the internet will be accepted, as will mail from anywhere on the
internet to here.
Are there any domains you want to relay mail for—that is, you are
prepared to accept mail for them from anywhere on the internet, but
they are not local domains.
If there are any, enter them here, separated with spaces or commas. You
can use wildcards. If there are none, say `none’. If you want to relay
mail for all domains that specify you as an MX, then say `mx’
Enter value (default=`none’, `x’ to restart):
==============================================================================
Obviously, any machines that use us as a smarthost have to be excluded
from the relaying controls, as using us to relay mail for them is the
whole point.
Are there any networks of local machines you want to relay mail for?
If there are any, enter them here, separated with spaces or commas. You
should use the standard address/length format (e.g. 194.222.242.0/24)
If there are none, say `none’.
You need to double the colons in IPv6 addreses (e.g. 5f03::1200::836f::::/48)
Enter value (default=`none’, `x’ to restart):
Names are localhost:hayate.mine.nu:komachi.mine.nu!
==============================================================================
Mail for the `postmaster’ and `root’ accounts is usually redirected
to one or more user accounts, of the actual system administrators.
By default, I’ll set things up so that mail for `postmaster’ and for
various system accounts is redirected to `root’, and mail for `root’
is redirected to a real user. This can be changed by editing /etc/aliases.
Note that postmaster-mail should usually be read on the system it is
directed to, rather than being forwarded elsewhere, so (at least one of)
the users you choose should not redirect their mail off this machine.
Which user account(s) should system administrator mail go to ?
Enter one or more usernames separated by spaces or commas . Enter
`none’ if you want to leave this mail in `root’s mailbox – NB this
is strongly discouraged. Also, note that usernames should be lowercase!
Enter value (`x’ to restart): uep
==============================================================================
You already have an /etc/aliases file. Do you want to replace this with
a new one (the old one will be kept and renamed to aliases.O)? (y/n)
Enter value (default=`y’, `x’ to restart): y
==============================================================================
You already have an /etc/aliases file. Do you want to replace this with
a new one (the old one will be kept and renamed to aliases.O)? (y/n)
Enter value (default=`y’, `x’ to restart): y
The following configuration has been entered:
==============================================================================
Mail generated on this system will have `hayate.mine.nu’ used
as the domain part (after the @) in the From: field and similar places.
The following domain(s) will be recognised as referring to this system:
localhost, hayate.mine.nu, komachi.mine.nu
Mail for postmaster, root, etc. will be sent to uep.
Local mail is delivered.
Outbound remote mail is looked up in the Internet DNS, and delivered
using that data if any is found; otherwise such messages are bounced.
Note that you can set email addresses used for outgoing mail by editing
/etc/email-addresses.
Is this OK ? Hit Return or type `y’ to confirm it and install,
or `n’ to make changes (in which case we’ll go round again, giving you
your previous answers as defaults. (Y/n)
Keeping previous /etc/aliases as /etc/aliases.O
Configuration installed.

一応テスト

rick:/etc/exim# mail uep
Subject: TEST
.
Cc:
Null message body; hope that’s ok
rick:/etc/exim# exit
exit
You have mail in /var/mail/uep
uep@rick:/etc/exim$ mail
Mail version 8.1.2 01/15/2001. Type ? for help.
“/var/mail/uep”: 1 messages 1 new
>N 1 root@hayate.mine. Thu Dec 23 12:26 13/402 TEST
N 2 Mailer-Daemon@hay Thu Dec 23 12:26 34/1176 Mail delivery failed: retu
& 1
Message 1:
From root@hayate.mine.nu Thu Dec 23 12:26:56 2004
Envelope-to: uep@hayate.mine.nu
To: uep@hayate.mine.nu
Subject: TEST
From: root
Date: Thu, 23 Dec 2004 12:26:56 +0900
& q
Saved 1 message in /home/uep/mbox

ルータの25番を空けるのを忘れずに。外部とのやりとりもできるか確認しておく。
open relayのテストも行なっておく。
http://www.abuse.net/relay.html

Apacheのログ設定

mod_setenvifを使って、ディスクにやさしいログ記録にする
ぺんぎんさんのシッポを参照しました。

LoadModule setenvif_module /usr/lib/apache/1.3/mod_setenvif.so
LogFormat "%h %l %u %t \"%!414r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined

SetEnvIf Request_URI "\.(gif)|(jpg)|(png)$" no_log
SetEnvIf Remote_Addr 192.168.0. no_log
SetEnvIf Request_URI "^/_mem_bin/" no_log
SetEnvIf Request_URI "^/_vti_bin/" no_log
SetEnvIf Request_URI "^/c/" no_log
SetEnvIf Request_URI "^/d/" no_log
SetEnvIf Request_URI "^/msadc/" no_log
SetEnvIf Request_URI "^/MSADC/" no_log
SetEnvIf Request_URI "^/scripts/" no_log
SetEnvIf Request_URI "^/default.ida" no_log
SetEnvIf Request_URI "root\.exe" no_log
SetEnvIf Request_URI "cmd\.exe" no_log
SetEnvIf Request_URI "NULL\.IDA" no_log

CustomLog /var/log/apache/access.log combined env=!no_log