Debian(lenny)の初期設定

投稿者: | 2010年8月7日
Pocket

目次

  1. IPアドレスとデフォルトルートの設定
  2. リゾルバの設定
  3. aptitudeの設定
  4. 新規ユーザの追加
  5. rootパスワード変更
  6. TCP Wrapperの設定
  7. PAMの設定
  8. sudoの設定
  9. hostnameの変更
  10. localeの日本語化

対象サーバについて

製品名 OpenBlockS 600
OS(kernel ver) Debian lenny(2.6.29)
CPU 600MHz(AMCC PowerPC 405EX)
メモリ 1GB(DDR2 SDRAM)
ストレージ 8GB(Compact Flash)

1. IPアドレスとデフォルトルートの設定

コンフィグ設定

編集するファイル:/etc/network/interfaces

# Used by ifup(8) and ifdown(8). See the interfaces(5) manpage or
# /usr/share/doc/ifupdown/examples for more information.
auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static
        address 192.168.253.254
        address 172.0.0.2
        netmask 255.255.255.0
        gateway 192.168.253.194
        gateway 172.0.0.1

→ addressとgatewayを初期状態から修正

疎通確認

# /etc/init.d/networking restart
Reconfiguring network interfaces...Ignoring unknown interface eth1=eth1.
done.
#

→リンクアップさせます。

# ping 192.168.0.4
PING 192.168.0.4 (192.168.0.4) 56(84) bytes of data.
64 bytes from 192.168.0.4: icmp_seq=1 ttl=64 time=3.78 ms
64 bytes from 192.168.0.4: icmp_seq=2 ttl=64 time=0.182 ms
64 bytes from 192.168.0.4: icmp_seq=3 ttl=64 time=0.168 ms
64 bytes from 192.168.0.4: icmp_seq=4 ttl=64 time=0.183 ms
^C
--- 192.168.0.4 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3003ms
rtt min/avg/max/mdev = 0.168/1.080/3.789/1.564 ms

→Connectedへの疎通性を確認します。

2. リゾルバの設定

コンフィグ設定 その1

編集するファイル:/etc/resolv.conf

nameserver XXX.XXX.XXX.XXX
nameserver YYY.YYY.YYY.YYY

→DNSサーバ構築前のため、とりあえずISPのDNSサーバを指定します。

確認

# traceroute www.yahoo.co.jp
traceroute to www.yahoo.co.jp (203.216.227.176), 30 hops max, 40 byte packets
 1  192.168.0.1 (192.168.0.1)  0.765 ms  0.998 ms  1.322 ms
 2  tkynifi.asahi-net.or.jp (124.155.68.2)  8.140 ms  7.952 ms  7.713 ms
 3  tkynird-ge0.asahi-net.or.jp (124.155.68.30)  16.058 ms  16.475 ms  16.266 ms
 4  tkybi4-v15.asahi-net.or.jp (202.224.37.81)  6.701 ms  7.011 ms  6.794 ms
 5  tkyni2.asahi-net.or.jp (202.224.32.89)  7.990 ms  9.321 ms  9.146 ms
 6  210.173.176.241 (210.173.176.241)  12.585 ms  4.693 ms  4.493 ms
 7  202.93.74.229 (202.93.74.229)  5.850 ms  5.725 ms  6.133 ms
 8  203.216.238.250 (203.216.238.250)  6.000 ms  5.721 ms  6.803 ms^C

→traceついでに名前解決できることを確認します。

コンフィグ設定 その2

※BIND設定後は以下のようにします。詳細はBIND9の設定に記載しています。

編集するファイル:/etc/resolv.conf

nameserver 127.0.0.1
search example.jp

→BIND側の設定にもよりますが、search を設定すると、www.example.jpをwwwで名前解決可能となります。

domain と同じ機能ですが searchだと空白区切りでいくつも設定可能です。

3. aptitudeの設定

aptitudeでダウンロード対象のPKGを増やします。

コンフィグ設定

編集するファイル:/etc/apt/sources.list

デフォルトでは以下のようになっています。

deb http://ftp.jp.debian.org/debian lenny main
deb http://ftp.jp.debian.org/debian lenny main contrib non-free
deb http://security.debian.org/ lenny/updates main contrib non-free

調べていくと、lennyのところがstableだったり、mainのところがサイトによってまちまちだったりして混乱しましたのでまとめておきます。

こちらよりMain、contrib、non-freeの違いを引用します。

Main: Debian フリーソフトウェアガイドライン にしたがい、パッケージとそのソースコードの自由な利用および再配布が保証されています。 Contrib: このディレクトリにあるパッケージは、著作権所有者によってフリーに ライセンスされていますが、他のフリーではないソフトウェアに依存します。 Non-Free: このディレクトリにあるパッケージは、 そのソフトウェアの利用や再配布になんらかの煩わしい制限があるものです。

また、lennyとstableについて、こちらより引用します。

今度はlennyの箇所をstableに書き変えました。現在(2009-12-05)のDebian/GNU Linuxの安定版のコードネームはlennyです。最初の表記の通りにlennyとコードネームを指定しておくと、lennyに関するソフトウェアの更新情報は取得しますが、後々の新しい安定版が出てきてコードネームもlennyではない名前に変わると、新しい安定版のソフトウェアを取得出来なくなります。 もちろん、lennyと書かれた箇所を、新しく出た安定版のコードネームに書き変えることで新しい安定版のソフトウェアが取得出来るようになるのですが、新しい安定版が出る度にコードネームの箇所を書き変えるのは面倒ですね。そこで安定版であればコードネームが変わっても自動的にその新しく出た安定版のDebianのソフトウェアを使えるようにする、と言うのが今回の方法です。 stableとは「安定版」という意味を持ち、例え将来どのような名前のバージョンの安定版が出てきても、自動的にそれに追随する、つまり使えるようになるというものです。これなら、一度書き変えるだけで、後はDebianプロジェクトが崩壊でもしない限り、最新の安定版を永遠に使うことが出来ます。

他に、テスト版、不安定版も含めることも可能なようですが、安定版のみの方針で行きます。

編集するファイル:/etc/apt/sources.list

deb http://ftp.jp.debian.org/debian stable main contrib non-free
deb-src http://ftp.jp.debian.org/debian stable main contrib non-free
deb http://security.debian.org stable/updates main contrib non-free
deb-src http://security.debian.org stable/updates main contrib non-free
deb http://ftp.jp.debian.org/debian-volatile stable/volatile main contrib non-free
deb-src http://ftp.jp.debian.org/debian-volatile stable/volatile main contrib non-free

パッケージの最新化

以下のコマンドを実施します。

# aptitude update
→パッケージリストの更新

# aptitude safe-upgrade
→パッケージリストの方がインストール済みパッケージよりも新しければ更新

lenny では aptitude を使うことが推奨されています。(※ここに以下の記載がありました。)

aptitude は、コマンドラインでのパッケージ管理の推奨プログラムであり、apt-get と同様のパッケージ管理機能を持ち、apt-get よりも依存関係の解決の面で優れていることが判っています。まだ dselect を使用しているのであれば、公式のパッケージ管理用フロントエンドとして aptitude に移行すべきでしょう。 lenny では、衝突を解決するための先進的な仕組みが aptitude で実装されました。この仕組みは、衝突が検出された原因がパッケージ間の依存関係の変化にある場合に、競合に対する最善の解決方法を見つけようとします。

ログファイルについて

aptitudeでもdpkgが後ろで動いていますが、dpkg.logとは別に/var/log/aptitudeというファイルを管理しています。

もし一度もaptitudeコマンドを使ったことがないのなら、ファイル自体が存在しません。

ちなみにaptitudeした際にファイルが保存されるディレクトリは/var/cache/apt/archives/です。

4. 新規ユーザの追加

ユーザ追加コマンドの投入

# useradd -u 1000 -g 4 -d /home/user001 -s /bin/bash -m user001

オプションについて

-u UIDの指定
-g GIDの指定
-d homeディレクトリの指定(これだけだとhomeディレクトリは自動作成されません)
-s シェルの指定
-m homeディレクトリを自動作成する。

確認

# more /etc/passwd
user001:x:1000:4::/home/user001:/bin/bash

# ls /home
user001

→オプション通りに設定されていることを確認

Adminグループへの追加

# usermod -G adm user001

→グループ名:admにユーザ名:user001を追加

確認

# more /etc/group
adm:x:4:user001

→追加された

初期パスワード投入

# passwd user001
Enter new UNIX password:[パスワードを投入]
Retype new UNIX password:[パスワードを投入]
passwd: password updated successfully

→別terminalを立ち上げてログインできることを確認

5. rootのパスワードを変更する

passwdコマンド投入

# passwd root
Enter new UNIX password:[パスワードを投入]
Retype new UNIX password:[パスワードを投入]
passwd: password updated successfully

→ su状態のセッションを残したまま別terminalにて確認

6. TCP Wrapperの設定

TCP Wrapperに対応したサービスへのアクセス制御を行います。

初期設定の確認

ファイル:/etc/hosts.allow

# /etc/hosts.allow: list of hosts that are allowed to access the system.
#                   See the manual pages hosts_access(5) and hosts_options(5).
#
# Example:    ALL: LOCAL @some_netgroup
#             ALL: .foobar.edu EXCEPT terminalserver.foobar.edu
#
# If you're going to protect the portmapper use the name "portmap" for the
# daemon name. Remember that you can only use the keyword "ALL" and IP
# addresses (NOT host or domain names) for the portmapper, as well as for
# rpc.mountd (the NFS mount daemon). See portmap(8) and rpc.mountd(8)
# for further information.

ファイル:/etc/hosts.deny

# /etc/hosts.deny: list of hosts that are _not_ allowed to access the system.
#                  See the manual pages hosts_access(5) and hosts_options(5).
#
# Example:    ALL: some.host.name, .some.domain
#             ALL EXCEPT in.fingerd: other.host.name, .other.domain
#
# If you're going to protect the portmapper use the name "portmap" for the
# daemon name. Remember that you can only use the keyword "ALL" and IP
# addresses (NOT host or domain names) for the portmapper, as well as for
# rpc.mountd (the NFS mount daemon). See portmap(8) and rpc.mountd(8)
# for further information.
#
# The PARANOID wildcard matches any host whose name does not match its
# address.

# You may wish to enable this to ensure any programs that don't
# validate looked up hostnames still leave understandable logs. In past
# versions of Debian this has been the default.
# ALL: PARANOID

バックアップ取得

# cp /etc/hosts.allow /etc/hosts.allow.default
# cp /etc/hosts.deny /etc/hosts.deny.default

コンフィグ設定

編集するファイル:/etc/hosts.deny

all: all

→/etc/hosts.allowはアプリケーションを追加するごとに開放する方針とし、現段階ではいじらないでおきます。

7. PAMの設定

一般ユーザからsuper userになれるようにします。

コンフィグ設定

admに属するユーザのみsuできるようにします。

編集するファイル:/etc/pam.d/su

# Uncomment this to force users to be a member of group root
# before they can use `su'. You can also add "group=foo"
# to the end of this line if you want to use a group other
# than the default "root" (but this may have side effect of
# denying "root" user, unless she's a member of "foo" or explicitly
# permitted earlier by e.g. "sufficient pam_rootok.so").
# (Replaces the `SU_WHEEL_ONLY' option from login.defs)
# auth       required   pam_wheel.so
auth       required   pam_wheel.so  group=adm

→group=admを追加

8. sudoの設定

新規ユーザがsudoできるようにします。

インストール

# aptitude install sudo

visudoのeditor変更

# update-alternatives --config editor

There are 3 alternatives which provide `editor'.

  Selection    Alternative
-----------------------------------------------
          1    /bin/ed
*+        2    /bin/nano
          3    /usr/bin/vim.tiny

Press enter to keep the default[*], or type selection number: 3
Using '/usr/bin/vim.tiny' to provide 'editor'.

→VIMに変更するため、3を入力する。

admに属するユーザがsudoを使用できるように設定

# visudo

# User privilege specification
root    ALL=(ALL) ALL
%adm    ALL=(ALL) ALL

→%adm ALL=(ALL) ALL を追加

9. hostnameの変更

コンフィグ設定

編集するファイル:/etc/hostname

LinuxServer
www

OpenBlockS600の初期設定のLinuxServerからwwwに変更。

設定反映コマンドの投入

# /etc/init.d/hostname.sh

→1度ログアウトして、再度ログインするとプロンプトが変更される。

10. localeの日本語化

dpkg-reconfigure localesコマンドによりlocaleの日本語化を行います。

インストール

# aptitude install locales

localeをUTF-8に設定

# dpkg-reconfigure locales

Package configuration
 lqqqqqqqqqqqqqqqqqqqqqqqqqqu Configuring locales tqqqqqqqqqqqqqqqqqqqqqqqqqqk
 x Locales are a framework to switch between multiple languages and allow    x
 x users to use their language, country, characters, collation order, etc.   x
 x                                                                           x
 x Please choose which locales to generate. UTF-8 locales should be chosen   x
 x by default, particularly for new installations. Other character sets may  x
 x be useful for backwards compatibility with older systems and software.    x
 x                                                                           x
 x Locales to be generated:                                                  x
 x                                                                           x
 x    [ ] iw_IL.UTF-8 UTF-8                                                  x
 x    [ ] ja_JP.EUC-JP EUC-JP                                            a   x
 x    [*] ja_JP.UTF-8 UTF-8                                                  x
 x    [ ] ka_GE GEORGIAN-PS                                              a   x
 x    [ ] ka_GE.UTF-8 UTF-8                                              a   x
 x    [ ] kk_KZ PT154                                                        x
 x                                                                           x
 x                                                                           x
 x                                                               x
 x                                                                           x
 mqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqj

Package configuration

 lqqqqqqqqqqqqqqqqqqqqqqqqqqu Configuring locales tqqqqqqqqqqqqqqqqqqqqqqqqqqk
 x Many packages in Debian use locales to display text in the correct        x
 x language for the user. You can choose a default locale for the system     x
 x from the generated locales.                                               x
 x                                                                           x
 x This will select the default language for the entire system. If this      x
 x system is a multi-user system where not all users are able to speak the   x
 x default language, they will experience difficulties.                      x
 x                                                                           x
 x Default locale for the system environment:                                x
 x                                                                           x
 x                                None                                       x
 x                                ja_JP.UTF-8  ←これを選択                  x
 x                                                                           x
 x                                                                           x
 x                                                               x
 x                                                                           x
 mqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqj


Generating locales (this might take a while)...
  ja_JP.UTF-8... done
Generation complete.

ユーザのbashにて環境変数LANGをUTF-8に設定

編集するファイル:~.bashrc

...

# don't put duplicate lines in the history. See bash(1) for more options
# don't overwrite GNU Midnight Commander's setting of `ignorespace'.
export HISTCONTROL=$HISTCONTROL${HISTCONTROL+,}ignoredups
# ... or force ignoredups and ignorespace
export HISTCONTROL=ignoreboth
export LANG=ja_JP.UTF-8

...

→export LANG=ja_JP.UTF-8を追加

$ bash
$ man man

MAN(1)                                   Manual pager utils                                  MAN(1)

名前
       man - オンラインリファレンスマニュアルのインターフェース

書式
       man  [-c|-w|-tZT  device]  [-adhu7V] [-m system[,...]] [-L locale] [-p string] [-M path] [-P
       pager] [-r prompt] [-S list] [-e extension] [[section] page ...] ...
       man -l [-7] [-tZT device] [-p string] [-P pager] [-r prompt] file ...
       man -k [apropos options] regexp ...
       man -f [whatis options] page ...

説明

...

→日本語化されました。

Pocket

コメントを残す

メールアドレスが公開されることはありません。 * が付いている欄は必須項目です