ラベル Linux の投稿を表示しています。 すべての投稿を表示
ラベル Linux の投稿を表示しています。 すべての投稿を表示

2011年1月14日金曜日

カーネル再構築

Ubuntu10.10でカーネル再構築の手順
(だいたい今までと同じ)

ソースのパッケージを入手
$ sudo aptitude install linux-source-2.6.xx
関連するパッケージをインストール(これだけかな?)
$ sudo aptitude install kernel-package
$ sudo aptitude install libncurses5-dev
$ sudo aptitude install build-essential
$ sudo aptitude install libqt3-mt-dev
ワークディレクトリに移動
$ cd /usr/src
ソースを展開
$ sudo tar jxvf linux-source-2.6.xx.tar.bz2
展開されたソースのディレクトリに移動
$ cd linux-source-2.6.xx
現在のコンフィグファイルをコピー
$ sudo cp /boot/config-2.6.xx-xx-generic .config
コンフィグファイルを初期設定に戻す(弄りすぎて元の設定がわからなくなった場合も使用)
$ sudo make oldconfig
コンフィグ設定
$ sudo make menuconfig
バージョンの変更
$ sudo vi Makefile
EXTRAVERSION=ここを変更
ビルドする
$ sudo make-kpkg clean
$ sudo make-kpkg --initrd --revision=YYYY kernel_image kernel_headers
ソースのディレクトリを抜ける
$ cd ..
カーネルをインストール~
XXXXがEXTRAVERSION=で指定したもの、YYYYが--revision=で指定したものになる。
$ sudo dpkg -i linux-image-2.6.xx.XXXX_YYYY_i386.deb
$ sudo dpkg -i linux-headers-2.6.xx.XXXX_YYYY_i386.deb
再起動
$ sudo shutdown -r 0

2010年11月19日金曜日

Ubuntu 10.04 Server でIPv6を停止するには

/etc/sysctl.conf に下記を追記
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
追記後に下記コマンド実行
# sudo sysctl -p

2009年3月23日月曜日

OpenBlockSでの設定保存

今更ですが、OpenBlockSの設定をフラッシュに保存するコマンドをメモ。

flashcfg -s /etc/flashcfg

今まではCFイメージで運用していたので必要なかった。

2008年9月18日木曜日

Postfixで重複したメールを削除するには (Procmail)

下記のようにエイリアスでメールアドレスをグループ化しています。

/etc/alias

hogehoge:hoge@fuga.com,foo@fuga.com,piyo@fuga.com

fugafuga:hoge@fuga.com,bar@fuga.com,baz@fuga.com

この場合、To:hogehoge,fugafugaでメールを送信すると、hoge@fuga.comに同じメールが2通届いてしまします。
sendmailを使用していた時は重複するメールが自動的に削除されていたようですが、Postfixでは動作が異なるようです。

そこでメールの振り分けや削除に使われるProcmailを使用してみました。
重複メールを削除する設定(全員)を/etc/procmailrcに記述します。
ちなみに個人単位で設定するには、/home/(ユーザ名)/.procmailrcに記述します。

/etc/procmailrc

PATH=/usr/bin
MAILDIR=$HOME/Maildir/
DEFAULT=$MAILDIR/
LOCKFILE=$MAILDIR/msgid.lock
:0 Wh:
| formail -D 8192 $MAILDIR/msgid.cache

各ユーザーの.forwardにprocmailを使用する設定を記述します。
これを記述しなければ通常の動作になります。

/home/(ユーザ名)/.forward

"| exec procmail" #ダブルクォーテーション「""」も含めて記述します。

動作としましては、受信したメールのメッセージIDをMaildir/msgid.cacheに保存しておき、同じメッセージIDを持つメールを受信した場合は削除します。
メッセージIDは常にユニークですので、誤って削除されることはありません。

.forwardは転送設定ですので、他のアドレスに転送する場合は"| exec procmail"の次の行から記述します。
この記述を行うと、転送時にローカルに残す為の「~/Maildir/」を記述しなくても強制的にローカルに残されました。
逆に「~/Maildir/」を記述すると、ローカルに2通届いてしまいます。

※Postfix 重複でここに来る方々が多いです。みんな困っているんですね。

Maildir形式で転送設定 (Postfix)

PostfixでメールボックスをMaildir形式にした場合のメール転送方法です。

# vi /home/(ユーザ名)/.forward

~/Maildir/ #ローカルにも残す場合

#転送先は改行で区切って記述
hoge@fuga.com
foo@fuga.com

2008年8月12日火曜日

FedoraCore6 Postfix用ログ解析ツールの導入

パッケージのインストール
# yum -y install postfix-pflogsumm

深夜2時、管理者宛にレポートを送信されるようにcron記述
# crontab -e

0 2 * * * perl /usr/sbin/pflogsumm -e -d yesterday /var/log/maillog | mail -s 'Postfix log summaries' postmaster

以下のように前日分のレポートがメールで送られてくる。
Postfix log summaries for Aug 10

Grand Totals
------------
messages

0 received
0 delivered
0 forwarded
0 deferred
0 bounced
0 rejected (0%)
0 reject warnings
0 held
0 discarded (0%)

0 bytes received
0 bytes delivered
0 senders
0 sending hosts/domains
0 recipients
0 recipient hosts/domains

message deferral detail: none

message bounce detail (by relay): none

message reject detail: none

message reject warning detail: none

message hold detail: none

message discard detail: none

smtp delivery failures: none

Warnings: none

Fatal Errors: none

Panics: none

Master daemon messages: none

Per-Hour Traffic Summary
time received delivered deferred bounced rejected
--------------------------------------------------------------------
0000-0100 0 0 0 0 0
0100-0200 0 0 0 0 0
0200-0300 0 0 0 0 0
0300-0400 0 0 0 0 0
0400-0500 0 0 0 0 0
0500-0600 0 0 0 0 0
0600-0700 0 0 0 0 0
0700-0800 0 0 0 0 0
0800-0900 0 0 0 0 0
0900-1000 0 0 0 0 0
1000-1100 0 0 0 0 0
1100-1200 0 0 0 0 0
1200-1300 0 0 0 0 0
1300-1400 0 0 0 0 0
1400-1500 0 0 0 0 0
1500-1600 0 0 0 0 0
1600-1700 0 0 0 0 0
1700-1800 0 0 0 0 0
1800-1900 0 0 0 0 0
1900-2000 0 0 0 0 0
2000-2100 0 0 0 0 0
2100-2200 0 0 0 0 0
2200-2300 0 0 0 0 0
2300-2400 0 0 0 0 0

Host/Domain Summary: Message Delivery
sent cnt bytes defers avg dly max dly host/domain
-------- ------- ------- ------- ------- -----------

Host/Domain Summary: Messages Received
msg cnt bytes host/domain
-------- ------- -----------

Senders by message count: none

Recipients by message count: none

Senders by message size: none

Recipients by message size: none

Current Mail Queue
------------------
Mail queue is empty

2008年7月16日水曜日

LDAPサーバー及びLDAPクライアント設定ファイルについて

># vi /etc/openldap/slapd.conf

#######################################################################
# ldbm and/or bdb database definitions
#######################################################################


#database bdb
#suffix "dc=my-domain,dc=com" # コメントアウト

          ↓
suffix "dc=hoge,dc=fuga,dc=com" # 自ドメインに変更

#rootdn "cn=Manager,dc=my-domain,dc=com" # コメントアウト
          ↓
rootdn "cn=Manager,dc=hoge,dc=fuga,dc=com" # 自ドメインに変更

# Cleartext passwords, especially for the rootdn, should
# be avoided. See slappasswd(8) and slapd.conf(5) for details.
# Use of strong authentication encouraged.
# rootpw secret
# rootpw {crypt}ijFYNcSNctBYg

# 暗号化されたパスワードを設定します。

rootpw {MD5}xxxxxxxxxxxxxxxxxxxxxxxx # 後述のslappasswdにて説明

# The database directory MUST exist prior to running slapd AND
# should only be accessible by the slapd and slap tools.
# Mode 700 recommended.

directory /var/lib/ldap

# Indices to maintain for this database
index objectClass eq,pres
index ou,cn,mail,surname,givenname eq,pres,sub
index uidNumber,gidNumber,loginShell eq,pres
index uid,memberUid eq,pres,sub
index nisMapName,nisMapEntry eq,pres,sub

# Replicas of this database
#replogfile /var/lib/ldap/openldap-master-replog
#replica host=ldap-1.example.com:389 starttls=critical
# bindmethod=sasl saslmech=GSSAPI
# authcId=host/ldap-master.example.com@EXAMPLE.COM


# 以下を追加
access to attrs=userPassword
    by self write
    by dn="cn=Manager,dc=hoge,dc=fuga,dc=com" write
    by anonymous auth
    by * none

access to *
    by dn="cn=Manager,dc=hoge,dc=fuga,dc=com" write
    by self write
    by * read


予めslappasswdにて暗号化されたパスワードを生成しておきます。
secretの部分は任意のパスワードを指定します。

# slappasswd -s secret -h {MD5}
{MD5}xxxxxxxxxxxxxxxxxxxxxxxx

表示された{MD5}~の部分を前述のslapd.confのrootpw行に記述します。



LDAPクライアントの設定
># vi /etc/openldap/ldap.conf

# See ldap.conf(5) for details
# This file should be world readable but not world writable.

#BASE dc=example, dc=com

       ↓
BASE dc=hoge,dc=fuga,dc=com # 自ドメインに変更


nss_ldapの設定
># vi /etc/ldap.conf

# The distinguished name of the search base.
#base dc=example,dc=com

       ↓
base dc=hoge,dc=fuga,dc=com # 自ドメインに変更

2008年7月14日月曜日

FedoraCore6でメールサーバー構築

Fedora Core 6 でメールサーバーを構築してみました。
以下は私の覚え書きです。

Postfix + Dovecot インストール手順

Fedora Core 6 インストール時の前提条件
・インストールタイプの選択で、3つのチェックマークを全て外す。

Postfixのインストール
・パッケージのインストールにはyumを使用します。
# yum -y install postfix

・main.cf(Postfix設定ファイル)の編集
# vi /etc/postfix/main.cf

#myhostname = host.domain.tld
     ↓
myhostname = hoge.fuga.com # コメントを外し、自身のFQDNに変更

#mydomain = domain.tld
     ↓
mydomain = fuga.com # コメントを外し、自身のドメイン名に変更

#myorigin = $mydomain
     ↓
myorigin = $mydomain # コメントを外す

#inet_interface = all
     ↓
inet_interface = all # コメントを外す

inet_interface = localhost
     ↓
#inet_interface = localhost # コメントアウト

mydestination = $myhostname, localhost.$mydomain, localhost
     ↓
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain # 自身のドメインを追加

#home_mailbox = Maildir/
     ↓
home_mailbox = Maildir/ # コメントを外す

#smtpd_banner = $myhostname ESMTP $mail_name
#smtpd_banner = $myhostname ESMTP $mail_name ($mail_version)
     ↓
#smtpd_banner = $myhostname ESMTP $mail_name
#smtpd_banner = $myhostname ESMTP $mail_name ($mail_version)
smtpd_banner = $myhostname ESMTP unknown # メールサーバー名を隠す為、unknownを追加

・ホームディレクトリの雛形にMaildirを追加(新規ユーザー用)
# mkdir -p /etc/skel/Maildir/cur
# mkdir -p /etc/skel/Maildir/new
# mkdir -p /etc/skel/Maildir/tmp
# chmod -R 700 /etc/skel/Maildir/

・既存ユーザーのホームディレクトリにMaildirを追加
# mkdir -p /home/honda/Maildir/cur
# mkdir -p /home/honda/Maildir/new
# mkdir -p /home/honda/Maildir/tmp
# chown -R honda /home/honda/Maildir/
# chmod -R 700 /home/honda/Maildir/

root宛メールの代理受信
・rootはメールソフトで受信できない為、代理のユーザーで受信します。
# vi /etc/aliases

root: marc
     ↓
#root: marc # コメントアウト

root: honda # 代理ユーザーを指定

Postfixの起動
・デフォルトのsendmailを停止
# /etc/rc.d/init.d/sendmail stop

・デフォルトをpostfixに変更
# alternatives --config mta

2 プログラムがあり 'mta' を提供します。

選択 コマンド
-----------------------------------------------
*+ 1 /usr/sbin/sendmail.sendmail
  2 /usr/sbin/sendmail.postfix

Enter を押して現在の選択 [+] を保持するか、選択番号を入力します:2

ここでは2を選択します。

・Postfixを起動
# /etc/rc.d/init.d/postfix start

・Postfixの自動起動設定
# chkconfig sendmail off
# chkconfig postfix on

Dovecotのインストール
・パッケージのインストールにはyumを使用します。

# yum -y install dovecot

・dovecot.conf(Dovecot設定ファイル)の編集
# vi /etc/dovecot.conf

#protocols = imap imaps pop3 pop3s
     ↓
protocols = imap imaps pop3 pop3s # コメントを外す

#mail_location =
     ↓
mail_location = maildir:~/Maildir # メールボックスを指定

Dovecotの起動
・Dovecotを起動
# /etc/rc.d/init.d/dovecot start

・Dovecotの自動起動設定
# chkconfig dovecot on