はじめに
squeezeをインストールして最初に以下のアプリケーションの導入・設定を一気に行いました。
当面はsqueezeを監視系サーバ(主にSNMPやnetflowの検証)として利用予定のため、各アプリケーションについて基本的な設定しか行っていません。
squeezeの設定はlennyと大きく変わらないので、細かいパラメータの説明やチューニング方法等はDebian 5.0(Lenny)の設定を参照して下さい。
目次
- リゾルバの設定
- aptitudeの設定
- sudoの設定
- telnetdの設定
- ntp-dateの設定
- ntpの設定
- rsyslogの設定
- vsftpdの設定
- SAMBAの設定
- Apache2.2の設定
サーバ環境
製品名 | Dell OPTIPLEX SX280 |
CPU | Intel Pentium4 CPU 2.8GHz |
メモリ | 3GB(PC2-5300U(1GB) x 1枚、PC2-5300U(2G) x 1枚) |
ストレージ | IBM SATA 160GB |
1. リゾルバの設定
root@labo:/var/www/rrdtools# vi /etc/resolv.conf search localdomain nameserver xx.xx.xx.xx nameserver xx.xx.xx.xx
インストール時にはnameserverを1つしか設定しなかったので、2つ以上設定する場合は追加しておきます。
2. aptitudeの設定
root@labo:~# vi /etc/apt/sources.list deb http://ftp.jp.debian.org/debian/ squeeze main contrib non-free deb-src http://ftp.jp.debian.org/debian/ squeeze main contrib non-free deb http://security.debian.org/ squeeze/updates main contrib non-free deb-src http://security.debian.org/ squeeze/updates main contrib non-free # squeeze-updates, previously known as 'volatile' deb http://ftp.jp.debian.org/debian/ squeeze-updates main contrib deb-src http://ftp.jp.debian.org/debian/ squeeze-updates main contrib
cdromを削除し、contrib/non-freeを追加しました。
root@labo:~# aptitude update root@labo:~# aptitude safe-upgrade
3. sudoの設定
root@labo:~# update-alternatives --config editor alternative editor (/usr/bin/editor を提供) には 2 個の選択肢があります。 選択肢 パス 優先度 状態 ------------------------------------------------------------ * 0 /bin/nano 40 自動モード 1 /bin/nano 40 手動モード 2 /usr/bin/vim.tiny 10 手動モード 現在の選択 [*] を保持するには Enter、さもなければ選択肢の番号のキーを押してください: 2
visudoでviが使用できるように2を選択します。
root@labo:~# visudo # /etc/sudoers # # This file MUST be edited with the 'visudo' command as root. # # See the man page for details on how to write a sudoers file. # Defaults env_reset # Host alias specification # User alias specification # Cmnd alias specification # User privilege specification root ALL=(ALL) ALL # Allow members of group sudo to execute any command # (Note that later entries override this, so you might need to move # it further down) %sudo ALL=(ALL) ALL user01 ALL=(ALL) ALL
一番下の行を追加しました。lennyではgroup名 ALL=(ALL) ALLで設定していましたが、squeezeではうまく動作しませんでしたので、ユーザ名で設定しました。
4. telnetdの設定
root@labo:~# aptitude install xinetd root@labo:~# aptitude install telnetd
xinetdだけでなくtelnetdも必要です。
root@labo:~# vi /etc/xinetd.d/telnet service telnet { disable = no socket_type = stream wait = no nice = 10 user = root server = /usr/sbin/in.telnetd log_type = FILE /var/log/telnet.log log_on_success += HOST PID EXIT DURATION log_on_failure += HOST USERID ATTEMPT only_from = 192.168.0.0/24 }
上記ファイルを新規作成します。
root@labo:~# /etc/init.d/xinetd restart Stopping internet superserver: xinetd. Starting internet superserver: xinetd.
xinetdの再起動後、外部からログインできることを確認します。
5. ntp-dateの設定
ntp-dateはNTPクライアントです。今回、本サーバはNTPサーバにしようと考えていますのでntp-dateは不要ですが、NTPサーバを入れる前に一度時刻を同期させるために設定します。
root@labo:~# aptitude install ntpdate ... root@labo:~# vi /etc/default/ntpdate # The settings in this file are used by the program ntpdate-debian, but not # by the upstream program ntpdate. # Set to "yes" to take the server list from /etc/ntp.conf, from package ntp, # so you only have to keep it in one place. #NTPDATE_USE_NTP_CONF=yes NTPDATE_USE_NTP_CONF=no # List of NTP servers to use (Separate multiple servers with spaces.) # Not used if NTPDATE_USE_NTP_CONF is yes. #NTPSERVERS="0.debian.pool.ntp.org 1.debian.pool.ntp.org 2.debian.pool.ntp.org 3.debian.pool.ntp.org" NTPSERVERS="ntp.jst.mfeed.ad.jp ntp.nict.jp ntp.ring.gr.jp" # Additional options to pass to ntpdate NTPOPTIONS=""
NTPDATE_USE_NTP_CONFをyesからnoに変更しました。また、NTPSERVERSを既存とは別サーバに修正しました。
root@labo:~# ntpdate-debian 26 Jun 00:34:02 ntpdate[4033]: adjust time server 133.243.238.243 offset 0.428031 sec
うまく同期されていることが確認できました。
root@labo:~# crontab -e no crontab for root - using an empty one # Edit this file to introduce tasks to be run by cron. # # Each task to run has to be defined through a single line # indicating with different fields when the task will be run # and what command to run for the task # # To define the time you can provide concrete values for # minute (m), hour (h), day of month (dom), month (mon), # and day of week (dow) or use '*' in these fields (for 'any').# # Notice that tasks will be started based on the cron's system # daemon's notion of time and timezones. # # Output of the crontab jobs (including errors) is sent through # email to the user the crontab file belongs to (unless redirected). # # For example, you can run a backup of all your user accounts # at 5 a.m every week with: # 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/ # # For more information see the manual pages of crontab(5) and cron(8) # # m h dom mon dow command 0 6 * * * /usr/sbin/ntpdate-debian -s >/dev/null 2>&1
末尾の行を追加しました。
うまく動かなかった場合、ntp-dateについてはlennyのntpdate-debianの設定にも詳しく記載していますので参照してみて下さい。
6. NTPサーバの設定
root@labo:~# aptitude install ntp 以下の新規パッケージがインストールされます: libopts25{a} ntp 更新: 0 個、新規インストール: 2 個、削除: 0 個、保留: 0 個。 509 kB のアーカイブを取得する必要があります。展開後に 1,290 kB のディスク領域が新たに消費されます。 先に進みますか? [Y/n/?] Y 取得:1 http://ftp.jp.debian.org/debian/ squeeze/main libopts25 i386 1:5.10-1.1 [62.6 kB] 取得:2 http://ftp.jp.debian.org/debian/ squeeze/main ntp i386 1:4.2.6.p2+dfsg-1+b1 [447 kB] 509 kB を 5秒 秒でダウンロードしました (97.7 kB/s) 未選択パッケージ libopts25 を選択しています。 (データベースを読み込んでいます ... 現在 125882 個のファイルとディレクトリがインストールされています。) (.../libopts25_1%3a5.10-1.1_i386.deb から) libopts25 を展開しています... 未選択パッケージ ntp を選択しています。 (.../ntp_1%3a4.2.6.p2+dfsg-1+b1_i386.deb から) ntp を展開しています... man-db のトリガを処理しています ... libopts25 (1:5.10-1.1) を設定しています ... ntp (1:4.2.6.p2+dfsg-1+b1) を設定しています ... Starting NTP server: ntpd.
NTPサーバがインストールされました。
この時点でntpdate-debianは実行できなくなります。
root@labo:~# ntpdate-debian 26 Jun 20:17:49 ntpdate[2663]: the NTP socket is in use, exiting
デフォルトでは以下のNTPサーバを参照しています。
root@labo:~# ntpq -p remote refid st t when poll reach delay offset jitter ============================================================================== *sylph.white-voi 150.26.2.66 2 u 16 64 1 8.063 -67.241 1.133 doga.jp 133.243.238.164 2 u 15 64 1 14.652 -72.209 17.370 suisho.attritio 133.100.9.2 2 u 14 64 1 6.382 -66.908 1.244 mx.tokyo.fatema 69.25.96.13 2 u 13 64 1 7.524 -68.964 1.325
以下に修正します。
root@labo:~# vi /etc/ntp.conf 省略 #server 0.debian.pool.ntp.org iburst #server 1.debian.pool.ntp.org iburst #server 2.debian.pool.ntp.org iburst #server 3.debian.pool.ntp.org iburst server ntp.jst.mfeed.ad.jp iburst server ntp.nict.jp iburst server ntp.ring.gr.jp iburst 省略
サーバだけ修正しました。
root@labo:~# /etc/init.d/ntp restart Stopping NTP server: ntpd. Starting NTP server: ntpd. root@labo:~# ntpq -p remote refid st t when poll reach delay offset jitter ============================================================================== *ntp3.jst.mfeed. 210.173.160.86 2 u 1 64 1 4.649 -14.716 0.785 ntp-a2.nict.go. .NICT. 1 u 2 64 1 4.525 -15.635 0.365 ring.nict.go.jp 79.185.31.198 2 u 1 64 1 6.035 -16.689 1.676 root@labo:~# ntpq -p remote refid st t when poll reach delay offset jitter ============================================================================== *ntp3.jst.mfeed. 210.173.160.86 2 u 48 64 3 4.649 -14.716 0.862 +ntp-a2.nict.go. .NICT. 1 u 47 64 3 4.525 -15.635 1.507 +ring.nict.go.jp 79.185.31.198 2 u 46 64 3 4.209 -15.685 0.985
*(参照同期中サーバ) と +(利用可能なサーバ)がつくまで少し時間がかかります。
最後にntpdate-debianをcronからはずしておきます。
root@labo:~# crontab -e # m h dom mon dow command #0 */1 * * * /usr/sbin/ntpdate-debian > /dev/null 2>1&
7. rsyslogの設定
rsyslogについてもlennyの記事rsyslog設定に詳細を記載しているので、細かいパラメータ等についてはそちらを参照して下さい。
本記事では最低限動作させる設定のみ記載します。
root@labo:~# vi /etc/rsyslog.conf # provides UDP syslog reception #$ModLoad imudp #$UDPServerRun 514 $ModLoad imudp $UDPServerRun 514 *.=info;*.=notice;*.=warn;\ auth,authpriv.none;\ cron,daemon.none;\ mail,news.none local6.none -/var/log/messages local6.* /var/log/router.log "/etc/rsyslog.conf" 118 lines, 2646 characters written
上記の強調箇所を修正しました。routerからsyslogファシリティ=local6で飛ばすため、local6の受信設定をしています。
root@labo:~# /etc/init.d/rsyslog restart Stopping enhanced syslogd: rsyslogd. Starting enhanced syslogd: rsyslogd. root@labo:~# netstat -an | grep :514 udp 0 0 0.0.0.0:514 0.0.0.0:* udp6 0 0 :::514 :::*
8. vsftpdの設定
vsftpdについてもlennyの記事vsftpdの設定に詳細を記載しているので、細かいパラメータ等についてはそちらを参照して下さい。
root@labo:~# aptitude install vsftpd root@labo:~# vi /etc/vsftpd.conf listen_address=192.168.0.121 tcp_wrappers=YES anonymous_enable=NO local_enable=YES write_enable=YES local_umask=022 xferlog_file=/var/log/vsftpd.log ascii_upload_enable=YES ascii_download_enable=YES
上記を追加 or コメントアウトをはずします。
root@labo:~# vi /etc/hosts.allow vsftpd: 127.0.0.1 192.168.0.0/24 root@labo:~# /etc/init.d/vsftpd restart Stopping FTP server: vsftpd. Starting FTP server: vsftpd. root@labo:~# netstat -an | less 稼働中のインターネット接続 (サーバと確立) Proto 受信-Q 送信-Q 内部アドレス 外部アドレス 状態 tcp 0 0 192.168.0.121:21 0.0.0.0:* LISTEN
21番ポートで待ち受けています。外部からFTP接続できるか試して終了です。
9. SAMBAの設定
LAN内で限られたメンバーでの利用用途のため、動けば良いというレベルの設定です。ご了承下さい。
インストール
root@labo:~# aptitude install samba 以下の新規パッケージがインストールされます: samba samba-common{a} samba-common-bin{a} 更新: 0 個、新規インストール: 3 個、削除: 0 個、保留: 0 個。 13.9 MB のアーカイブを取得する必要があります。展開後に 39.5 MB のディスク領域が新たに消費されます。 先に進みますか? [Y/n/?] Y 取得:1 http://ftp.jp.debian.org/debian/ squeeze/main samba-common all 2:3.5.6~dfsg-3squeeze2 [387 kB] 取得:2 http://ftp.jp.debian.org/debian/ squeeze/main samba i386 2:3.5.6~dfsg-3squeeze2 [7,636 kB] 取得:3 http://ftp.jp.debian.org/debian/ squeeze/main samba-common-bin i386 2:3.5.6~dfsg-3squeeze2 [5,844 kB] 13.9 MB を 11秒 秒でダウンロードしました (1,221 kB/s) パッケージを事前設定しています ... パッケージの設定 lqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqu Samba Server tqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqk x このシステムのワークグループを指定してください。この設定は、システムがサーバとして使われるときにどのワークグループとして現れるか、いくつかのフロントエンドでブラウジング x x されたときに使われるデフォルトのワークグループ、そして"security=domain" 設定が使われたときのドメイン名を制御します。 x x x x ワークグループ/ドメイン名: x x x x ABCDOMAIN________________________________________________________________________________________________________________________________________________________________ x x x x <了解> x x x mqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqj 未選択パッケージ samba-common を選択しています。 省略
途中でワークグループ/ドメイン名を聞かれます。本サイトではABCDOMAINとします。
設定
root@labo:~# cp /etc/samba/smb.conf /etc/samba/smb.conf.orig root@labo:~# vi /etc/samba/smb.conf [homes] comment = Home Directories # browseable = no browseable = yes # By default, the home directories are exported read-only. Change the # next parameter to 'no' if you want to be able to write to them. # read only = yes read only = no root@labo:~# /etc/init.d/samba restart Stopping Samba daemons: nmbd smbd. Starting Samba daemons: nmbd smbd.
上記2箇所(homesのbrowseableとread only)のみ修正して再起動します。
次に、Windowsから本サーバにアクセスする際に使用するユーザのパスワードを定義します。
root@labo:~# smbpasswd user01 New SMB password:PWを入力 Retype new SMB password:PWを入力
ちなみに/etc/samba/smb.confには載ってこないデフォルト設定は「testparm -v」コマンドで確認できます。
次に、本サーバからWindowsにアクセスできるようにsmbclientをインストールします。
root@labo:~# aptitude install smbclient 以下の新規パッケージがインストールされます: smbclient 更新: 0 個、新規インストール: 1 個、削除: 0 個、保留: 0 個。 13.8 MB のアーカイブを取得する必要があります。展開後に 43.0 MB のディスク領域が新たに消費されます。 取得:1 http://ftp.jp.debian.org/debian/ squeeze/main smbclient i386 2:3.5.6~dfsg-3squeeze2 [13.8 MB] 13.8 MB を 9秒 秒でダウンロードしました (1,476 kB/s) 未選択パッケージ smbclient を選択しています。 (データベースを読み込んでいます ... 現在 125857 個のファイルとディレクトリがインストールされています。) (.../smbclient_2%3a3.5.6~dfsg-3squeeze2_i386.deb から) smbclient を展開しています... man-db のトリガを処理しています ... smbclient (2:3.5.6~dfsg-3squeeze2) を設定しています ...
Windows側にフォルダ共有設定を行い、192.168.0.2がアクセス先のWindowsだと仮定して、以下のコマンドで接続できることを確認します。
user01@labo:~$ smbclient //192.168.0.2/[共有フォルダ名]
10. apache2.2の設定
詳細設定についてはApache2.2の設定にまとめていますので参考にして下さい。本記事ではsqueezeでMRTGやrrdtools、cactiなど動かす予定ですので、動作すればよいレベルの設定を行います。
root@labo:~# aptitude install apache2 以下の新規パッケージがインストールされます: apache2 apache2-mpm-worker{a} apache2-utils{a} apache2.2-common{a} 更新: 0 個、新規インストール: 4 個、削除: 0 個、保留: 0 個。 475 kB のアーカイブを取得する必要があります。展開後に 2,683 kB のディスク領域が新たに消費されます。 先に進みますか? [Y/n/?] Y 省略
インストールが完了したら、接続確認を行います。
root@labo:~# telnet 127.0.0.1 80 Trying 127.0.0.1... Connected to 127.0.0.1. Escape character is '^]'. GET / <html><body><h1>It works!</h1> <p>This is the default web page for this server.</p> <p>The web server software is running but no content has been added, yet.</p> </body></html> Connection closed by foreign host.
ローカルで接続できることを確認しました。
root@labo:~# ls -al /etc/apache2/sites-enabled/ 合計 2 drwxr-xr-x 2 root root 1024 2011-06-26 21:42 . drwxr-xr-x 7 root root 1024 2011-06-26 21:42 .. lrwxrwxrwx 1 root root 26 2011-06-26 21:42 000-default -> ../sites-available/default root@labo:~# ls -al /etc/apache2/sites-available/ 合計 11 drwxr-xr-x 2 root root 1024 2011-06-26 21:42 . drwxr-xr-x 7 root root 1024 2011-06-26 21:42 .. -rw-r--r-- 1 root root 950 2011-03-23 05:56 default -rw-r--r-- 1 root root 7469 2011-03-23 05:56 default-ssl
設定ファイルの場所はlennyと変更無さそうです。
とりあえず一度apacheを止めて、基本のセキュリティ設定を修正します。
root@labo:~# /etc/init.d/apache2 stop Stopping web server: apache2 ... waiting . root@labo:~# root@labo:~# cd /etc/apache2/ root@labo:/etc/apache2# vi conf.d/security #ServerTokens OS #ServerTokens Full ServerTokens Prod ServerSignature Off #ServerSignature On TraceEnable Off #TraceEnable On
ServerTokensをOSからProdに、ServerSignatureをOffからOnに変更しました。
TraceEnableはSqueezeではデフォルトOffのためそのままにしておきます。
最後にapacheを上げて終了します。
root@labo:~# /etc/init.d/apache2 start Starting web server: apache2.