2013年4月21日日曜日

Postfwdでmynetworksからの接続情報をログに出力

postfwdを使ってもう※ひとねた※書いてみます。

postfixの場合、mynetwoksからの接続は、基本的にpermit_mynetwoksで無条件にリレーを許可されます。
mynetwoksに記述されているネットワークあるいはIPアドレスが少ないなら、mynetwoksからの接続である事を判断出来ますが、その数が非常に多くなった時はログを見てもmynetworksからの接続だとすぐに判断がつかないケースが出てきます(扱うドメインが多ければさらに判断が難しくなります)。

前置きが長くなりなしたが、今回は通常ログに出力されないそれらの情報を一手間かけてログに出してみます。



postfwdのルールセット


itemのclient_addressに、postfixのmynetworksパラメータで指定している値を指定します。
※ネットワークアドレス、IPアドレスはご自身の環境で読みかえてください

ログに出力するだけなので、actionには全てdunnoを指定しています。



 例1:カンマ区切りで複数指定する場合
id=MYNETWORKS
  action=dunno permit_mynetworks was matched
  protocol_state==RCPT
  client_address=192.168.0.0/24, 192.168.1.0/.24, 10.0.x.x


例2: リストを含むテキストを指定する場合
id=MYNETWORKS
  action=dunno permit_mynetworks was matched
  protocol_state==RCPT
  client_address==file:/etc/postfix/mynetworks.txt
  client_address==file:/etc/postfix/mynetworks2.txt
  …
/etc/postfix/mynetworks.txt:
192.168.0.0/24
192.168.1.0/24
10.0.x.x

 例3: key=value形式のリストを含むテキストを指定する場合
      ※postfixで既に利用しているマップテーブルを再利用するような場合に便利です
id=MYNETWORKS
  action=dunno permit_mynetworks was matched
  protocol_state==RCPT
  client_address==table:/etc/postfix/mynetworks.txt
  client_address==table:/etc/postfix/mynetworks2.txt
  …
/etc/postfix/mynetworks.txt:
192.168.0.0/24    OK
192.168.1.0/24    OK
10.0.x.x           OK


postfix側での設定

smtpd_client_restrictionsでposfwdでの評価を行うように設定します。

smtpd_client_restrictions = check_policy_service inet:127.0.0.1:10045
smtpd_recipient_restrictions = permit_mynetworks
                               reject_unauth_destination
                          …

(注意)以下のように指定した場合、permit_mynetwoksでpostfixでの評価が完了してしまうので、その下のpostfwdによる評価は行われず、ログが出力されません。

smtpd_recipient_restrictions = permit_mynetworks
                               reject_unauth_destination
                               check_policy_service inet:127.0.0.1:10045




動作確認

これで以下のようにログが出力されるようになります。
※青字の部分が新たに出力されるようになった部分です


Apr 21 16:37:00 cent6 postfix/smtpd[2279]: connect from unknown[192.168.0.11]
Apr 21 16:37:00 cent6 postfwd2/policy[2148]: [RULES] rule=0, id=MYNETWORKS, client=unknown[192.168.0.11], sender=<user01@example.com>, recipient=<testuser@example.net>, helo=<mail.example.com>, proto=SMTP, state=RCPT, delay=0s, hits=MYNETWORKS, action=dunno permit_mynetworks was matched
Apr 21 16:37:00 cent6 postfix/smtpd[2279]: 8A5A321A6E: client=unknown[192.168.0.11]
Apr 21 16:37:01 cent6 postfix/cleanup[2285]: 8A5A321A6E: message-id=<F2CE3E63028A7Buser01@example.com>
Apr 21 16:37:01 cent6 postfix/qmgr[1801]: 8A5A321A6E: from=<user01@example.com>, size=487, nrcpt=1 (queue active)
Apr 21 16:37:01 cent6 postfix/smtpd[2279]: disconnect from unknown[192.168.0.11]
Apr 21 16:37:02 cent6 postfix/smtp[2287]: 8A5A321A6E: to=<testuser@example.net>, relay=mail.example.net[xx.xx.xx.xx]:25, delay=1.5, delays=1.4/0.02/0.04/0.12, dsn=2.0.0, status=sent (250 2.0.0 r3L7b27w006351 Message accepted for delivery)
Apr 21 16:37:02 cent6 postfix/qmgr[1801]: 8A5A321A6E: removed




2013年4月17日水曜日

Postfwd(postfix用ポリシーサーバ) その他メモ


前回までにまとめられなかった事を追記します。


ルールセットの記述の方法について(補足)

前回、ルールセットは下記のように";"(セミコロン)で区切って記述すると書きましたが、
id=SIZE001; protocol_state==END-OF-MESSAGE; action=DUNNO; size<=1000000
id=SIZE100; protocol_state==END-OF-MESSAGE; action=HOLD message too large

これを下記のように記述する事もできます。
id=SIZE001
action=DUNNO
protocol_state==END-OF-MESSAGE
size<=1000000
id=SIZE100
action=HOLD message too large
protocol_state==END-OF-MESSAGE 

好みの問題だとは思いますが、ぱっと見てわかりやすい記述をルールセット毎に採用すれば良いと思います。



postfwd2コマンドのオプションについて


良く利用するオプションをあげてみます。

●マニュアルを表示させる

# postfwd2 -m


※その際にpostfwd2コマンド内部で指定されているpagerを変更しておくと便利だと思います
 (マニュアルが長いので、lessの方が使い勝手が良いと思います)

(変更前)
our($cmd_pager)     = "more";

(変更後)
our($cmd_pager)  = "less";


●postfwd2デーモンの停止

# postfwd2 -k


●設定ファイルの読み直し

# postfwd2 --reload


●統計情報を見る

※ログにも同じ情報が定期的に出力されています

# postfwd2 --dumpstats

[STATS] postfwd2::cache 1.34: 8 queries since 0 days, 00:25:18 hours
[STATS] Requests: 0.0/min last, 0.3/min overall, 6.2/min top
[STATS] Hitrates: 40.0% requests, 0.0% dns, 0.0% rates
[STATS] Contents: request=2

[STATS] postfwd2::policy 1.34: 6 requests since 0 days, 00:25:18 hours
[STATS] Requests: 0.00/min last, 0.24/min overall, 6.15/min top
[STATS] Dnsstats: 0.00/min last, 0.00/min overall, 0.00/min top
[STATS] Hitrates: 50.0% ruleset, 33.3% parent, 16.7% child, 0.0% rates
[STATS] Timeouts: 0.0% (0 of 0 dns queries)
[STATS]   4 matches for id:  SIZE001
[STATS]   2 matches for id:  SIZE100


2013年4月13日土曜日

Postfwd(postfix用ポリシーサーバ) ルールセットの作成

前回の続きで、ルールセットを実際に作成してみます。

オンラインドキュメントのEXAMPLEに設定例がたくさん載っているので、そちらも参考にされてください。

書式

[ <item1>=<value>; <item2>=<value>; ... ] action=<result>

  • item=値と指定し、1つのルールセットに複数の条件を※1行で※指定する場合はセミコロンで区切ります
  • 必ず、actionを一つ含む必要があります
  • itemとactionの記述の順番は特に決まりがありません(どのような順番で指定しても大丈夫です)

itemについて

itemとしてしては、以下のものが指定できます。



actionについて

actionとしては、以下のものが指定できます。





ルールセットの作成例

ここでは、メッセージサイズをトリガーにメールをHOLDする例をあげてみます。

  /etc/postfix/postfwd.conf:
# 1. 10MB以下だったら何もしない
# 2. 10MBを超えたら、HOLDする
id=SIZE001; protocol_state==END-OF-MESSAGE; action=DUNNO; size<=10000000
id=SIZE100; protocol_state==END-OF-MESSAGE; action=HOLD message too large

 設定を反映するには、次のように実行します。
/usr/local/sbin/postfwd2 --reload

 連携するpostfixでは以下のように設定を追加します。

  /etc/postfix/main.cf:
  ※メッセージサイズのルールのなので、smtpd_end_of_data_restrictionsで指定します
smtpd_end_of_data_restrictions = check_policy_service inet:127.0.0.1:10045



動作確認

実際にメールを配送して動作を確認します。

<id=SIZE001のルールが適用された場合: holdされずに配送された場合>
青字の箇所が実際の判定部分で、actionとしてDUNNOが適用されて、その後、配送処理が行われています。

Apr  8 00:40:32 cent6 postfix/smtpd[1731]: connect from unknown[192.168.0.11]
Apr  8 00:40:33 cent6 postfix/smtpd[1731]: 095AF2267C: client=unknown[192.168.0.11]
Apr  8 00:40:34 cent6 postfwd2/policy[1719]: [RULES] rule=0, id=SIZE001, queue=095AF2267C, client=unknown[192.168.0.11], sender=<user01@example.com>, recipient=<testuser@example.jp>, helo=<example.com>, proto=SMTP, state=END-OF-MESSAGE, delay=0s, hits=SIZE001, action=DUNNO
Apr  8 00:40:34 cent6 postfix/cleanup[1737]: 095AF2267C: message-id=<ACCE33A63DDA9Ftoshiaki@example.com>
Apr  8 00:40:34 cent6 postfix/qmgr[1671]: 095AF2267C: from=<user01@example.com>, size=475, nrcpt=1 (queue active)
Apr  8 00:40:34 cent6 postfix/smtpd[1731]: disconnect from unknown[192.168.0.11]
Apr  8 00:40:36 cent6 postfix/smtp[1740]: 095AF2267C: to=<testuser@example.jp>, relay=mail.example.jp[1xx.33.69.11]:25, delay=3.5, delays=1.4/0.01/2/0.03, dsn=2.0.0, status=sent (250 ok:  Message 12768477 accepted)
Apr  8 00:40:36 cent6 postfix/qmgr[1671]: 095AF2267C: removed



<id=SIZE100のルールが適用された場合: holdされた場合>
青字の最初の1行目が判定部分で、actionとしてHOLDが適用され、次の2行目でpostfixがHOLDの処理を実行しています(メールの配送は行われていません)。

Apr  8 00:41:14 cent6 postfix/smtpd[1731]: connect from unknown[192.168.0.11]
Apr  8 00:41:14 cent6 postfix/smtpd[1731]: 1F7262267C: client=unknown[192.168.0.11]
Apr  8 00:41:14 cent6 postfix/cleanup[1737]: 1F7262267C: message-id=<ADCE33A6566291toshiaki@example.com>
Apr  8 00:41:15 cent6 postfwd2/policy[1719]: [RULES] rule=1, id=SIZE100, queue=1F7262267C, client=unknown[192.168.0.11], sender=<user01@example.com>, recipient=<testuser@example.jp>, helo=<example.com>, proto=SMTP, state=END-OF-MESSAGE, delay=0s, hits=SIZE100, action=HOLD message too large
Apr  8 00:41:15 cent6 postfix/smtpd[1731]: 1F7262267C: hold: END-OF-MESSAGE from unknown[192.168.0.11]: <END-OF-MESSAGE>: End-of-data message too large; from=<user01@example.com> to=<testuser@example.jp> proto=SMTP helo=<example.com>

Apr  8 00:41:15 cent6 postfix/smtpd[1731]: disconnect from unknown[192.168.0.11]


2013年3月17日日曜日

rsyslog + MySQL

2014/11/07追記: ”データベースの作成の箇所”に赤字でコメントを追加


シスログをMySQLに書き出す方法です。

今回の環境はCentOS6.4+rsyslogのVer7.2.6になり、こちらの記事のようにリポジトリを用意してある前提で話を進めます。


rsyslog-mysqlパッケージの導入

リポジトリに用意されているパッケージをインストールします。

[root@cent6 ~]# yum install rsyslog-mysql


データベースの作成

インストールしたrsyslog-mysqlパッケージに、シスログをMySQLに書き出す為に必要なデータベースとテーブルを作成するSQL(青字の部分)が含まれているので、今回はそれをそのまま利用します。
(2014/11/07追記:)
・SystemEventsテーブルのIDはint型で定義されていますが、受け取るログが多いと直ぐにあふれます。最初からbigint型にしておいたほうが良いと思います。
・デフォルトのMyISAMで運用していたら、比較的簡単に壊れました。最初からInnoDBにしておいたほうが無難です。
[root@cent6 ~]# rpm -ql rsyslog-mysql
/lib64/rsyslog/ommysql.so
/usr/share/doc/rsyslog-mysql-7.2.6
/usr/share/doc/rsyslog-mysql-7.2.6/createDB.sql
[root@cent6 ~]#

以下のように実行(インポート)します。
※この作業で、「Syslog」データベース、その中に2つのテーブルが作成されます


[root@cent6 ~]# mysql -u root < /usr/share/doc/rsyslog-mysql-7.2.6/createDB.sql
[root@cent6 ~]# mysql
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| Syslog             |
| mysql              |
+--------------------+
3 rows in set (0.00 sec)
mysql> use Syslog;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> show tables;
+------------------------+
| Tables_in_Syslog       |
+------------------------+
| SystemEvents           |
| SystemEventsProperties |
+------------------------+
2 rows in set (0.00 sec)
mysql>




ログ出力用ユーザの作成

rsyslogからMySQLへアクセスする為のユーザを以下のように作成します。
※ここでは、ユーザ名をrsyslog、パスワードをpasswordとして作成しています

mysql> grant all privileges on Syslog.* to rsyslog@localhost identified by 'password';
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql>select host,user,password from mysql.user where user='rsyslog';
+-----------+---------+-------------------------------------------+
| host      | user    | password                                  |
+-----------+---------+-------------------------------------------+
| localhost | rsyslog | *2470C0C06DEE42FD1618BB99005ADCA2EC9D1E19 |
+-----------+---------+-------------------------------------------+
1 row in set (0.00 sec)
mysql>



rsyslogの設定

/etc/rsyslog.confにMySQLにシスログを出力する為の設定(以下の2行)を追記します。
※下記では、全てのログをMySQLに出力するよう設定しています
※MySQLに出力する為の書式は、:ommysql: / 接続ホスト / データベース名 / ユーザ名 / パスワード となります

module(load="ommysql")
*.*     :ommysql:localhost,Syslog,rsyslog,password

設定を追加したら、rsyslogを再起動します。



動作確認

rsyslogの再起動が完了すると、MySQLにログが格納されるようになります。
[root@cent6 ~]# mysql Syslog
mysql> show tables;
+------------------------+
| Tables_in_Syslog       |
+------------------------+
| SystemEvents           |
| SystemEventsProperties |
+------------------------+
2 rows in set (0.00 sec)
mysql> select * from SystemEvents \G
*************************** 1. row ***************************
                ID: 1
        CustomerID: NULL
        ReceivedAt: 2013-03-17 23:34:43
DeviceReportedTime: 2013-03-17 23:34:43
          Facility: 5
          Priority: 6
          FromHost: cent6
           Message:  [origin software="rsyslogd" swVersion="7.2.6" x-pid="18401" x-info="http://www.rsyslog.com"] start
        NTSeverity: NULL
        Importance: NULL
       EventSource: NULL
         EventUser: NULL
     EventCategory: NULL
           EventID: NULL
   EventBinaryData: NULL
      MaxAvailable: NULL
         CurrUsage: NULL
          MinUsage: NULL
          MaxUsage: NULL
        InfoUnitID: 1
         SysLogTag: rsyslogd:
      EventLogType: NULL
   GenericFileName: NULL
          SystemID: NULL
1 row in set (0.00 sec)
mysql>



2013年3月8日金曜日

SSH パスフレーズの変更

暗号鍵にアクセスする為のパスフレーズを変更する方法です。


元のパスフレーズがわかる場合

$ ssh-keygen -p
Enter file in which the key is (/home/user01/.ssh/id_rsa):   <-鍵の場所が聞かれる
Enter old passphrase:  <-古いパスフレーズを入力
Key has comment '/home/user01/.ssh/id_rsa'
Enter new passphrase (empty for no passphrase): <-新しいパスフレーズを入力
Enter same passphrase again:               <-新しいパスフレーズを入力
Your identification has been saved with the new passphrase.
$


元のパスフレーズがわからない場合

$ ssh-keygen -t rsa -f .ssh/id_rsa -N "新しいパスフレーズ"
Generating public/private rsa key pair.
.ssh/id_rsa already exists.
Overwrite (y/n)? y  <-上書きについて確認される
Your identification has been saved in .ssh/id_rsa.
Your public key has been saved in .ssh/id_rsa.pub.
The key fingerprint is:
b9:6e:a5:bc:6d:db:80:ed:56:cd:bb:d9:73:39:e4:c8 root@pm02
The key's randomart image is:
+--[ RSA 2048]----+
|                 |
|                 |
|                 |
|         .       |
|        S    o   |
|         +. . o. |
|       .ooo.. +..|
|       .+ooo E.B.|
|       .o++.. o.=|
+-----------------+
$

※こちらのケースでは、秘密鍵と共に公開鍵も更新されるので、..ssh/authorized_keysの更新も忘れずに。

2013年3月4日月曜日

postfwd (postfix用ポリシーサーバ)

2013/03/04: 初版
2013/04/07: 「起動スクリプト」の赤字部分の箇所を追加(というか修正)



postfwdは、perlで書かれたpostfix用ポリシーサーバーで、複数の条件を組み合わせたACLが作成可能なので、postfix単体では実現できなかったSPAM対策に利用する事ができます。

今回は、そのセットアップについて記載します(といっても難しいところはないのですが)。
#評価環境はCentOS6.3
#postfwdには、version1 と version2が存在しますが、今回はversion2を利用


事前準備

動作に必要な下記のperlモジュールをインストールしておく。
・Net::Server::Daemonize
・Net::Server::Multiplex
・Net::Server::PreFork
 →上記3つはEPELリポジトリのperl-Net-Server含まれるので、そちらをインストールした
・Net::DNS
 →Baseリポジトリからperl-Net-DNSをインストールした


インストール

tarボールの中に、version1とversion2の両方のものが含まれているが、今回はversion2用のものを任意のディレクトリにコピーする形でインストールを実施する。
※なお、設定ファイルpostfwd.cfはひとまず空ファイルで用意しています

[root@cent6 ~]# wget http://postfwd.org/postfwd.tar.gz
[root@cent6 ~]# tar zxf postfwd.tar.gz
[root@cent6 ~]# cd postfwd-1.34/
[root@cent6 postfwd-1.34]# cp sbin/postfwd2 /usr/local/sbin
[root@cent6 postfwd-1.34]# cp bin/postfwd-script.sh /etc/rc.d/init.d/postfwd2
[root@cent6 postfwd-1.34]# touch /etc/postfix/postfwd.cf


起動スクリプトの修正

インストールした状況に合わせて、以下のように修正する。
→修正後のdiff出力を参照ください

[root@cent6 postfwd-1.34]# vi /etc/rc.d/init.d/postfwd2
[root@cent6 postfwd-1.34]# diff -u bin/postfwd-script.sh /etc/rc.d/init.d/postfwd2
--- bin/postfwd-script.sh       2010-11-15 07:03:42.000000000 +0900
+++ /etc/rc.d/init.d/postfwd2   2013-04-07 21:45:26.224068602 +0900
@@ -3,22 +3,27 @@
 # Startscript for the postfwd daemon
 #
 # by JPK
+# chkconfig: 35 75 25
+# description: postfwd is written in perl to combine complex postfix restrictions
+#              in a ruleset similar to those of the most firewalls.
 PATH=/bin:/usr/bin:/usr/local/bin
 # path to program
-#PFWCMD=/usr/local/postfwd/sbin/postfwd2
-PFWCMD=/usr/local/postfwd/sbin/postfwd
+#PFWCMD=/usr/local/postfwd/sbin/postfwd
+PFWCMD=/usr/local/sbin/postfwd2
 # rulesetconfig file
 PFWCFG=/etc/postfix/postfwd.cf
 # pidfile
-PFWPID=/var/tmp/postfwd.pid
+#PFWPID=/var/tmp/postfwd.pid
+PFWPID=/var/tmp/postfwd2-master.pid
 # daemon settings
 PFWUSER=nobody
 PFWGROUP=nobody
 PFWINET=127.0.0.1
-PFWPORT=10040
+#PFWPORT=10040
+PFWPORT=10045
 # recommended extra arguments
 PFWARG="--shortlog --summary=600 --cache=600 --cache-rbl-timeout=3600 --cleanup-requests=1200 --cleanup-rbls=1800 --cleanup-rates=1200"
@@ -40,7 +45,7 @@
        stop*)          ${PFWCMD} --interface=${PFWINET} --port=${PFWPORT} --pidfile=${PFWPID} --kill;
                        ;;
-       reload*)        ${PFWCMD} --interface=${PFWINET} --port=${PFWPORT} --pidfile=${PFWPID} -- reload;
+       reload*)        ${PFWCMD} --interface=${PFWINET} --port=${PFWPORT} --pidfile=${PFWPID} --reload;
                        ;;
        restart*)       $0 stop;
[root@cent6 postfwd-1.34]#




自動起動の設定と起動

[root@cent6 postfwd-1.34]# chkconfig --add postfwd2
[root@cent6 postfwd-1.34]# chkconfig postfwd2 on
[root@cent6 postfwd-1.34]# /etc/rc.d/init.d/postfwd2 start
Starting postfwd2...
[root@cent6 postfwd-1.34]#



状態確認


[root@cent6 ~]# ps -fC postfwd2
UID        PID  PPID  C STIME TTY          TIME CMD
nobody    1201     1  0 23:51 ?        00:00:00 /usr/local/sbin/postfwd2 --shortlog --summary=600 --cache=600 --cache-rbl-timeout=3600
nobody    1202  1201  0 23:51 ?        00:00:00  postfwd2::cache
nobody    1203  1201  0 23:51 ?        00:00:00  postfwd2::policy
nobody    1204  1203  0 23:51 ?        00:00:00  postfwd2::policy::child
nobody    1205  1203  0 23:51 ?        00:00:00  postfwd2::policy::child
nobody    1206  1203  0 23:51 ?        00:00:00  postfwd2::policy::child
nobody    1207  1203  0 23:51 ?        00:00:00  postfwd2::policy::child
nobody    1208  1203  0 23:51 ?        00:00:00  postfwd2::policy::child
nobody    1209  1203  0 23:51 ?        00:00:00  postfwd2::policy::child
nobody    1210  1203  0 23:51 ?        00:00:00  postfwd2::policy::child
nobody    1211  1203  0 23:51 ?        00:00:00  postfwd2::policy::child
nobody    1212  1203  0 23:51 ?        00:00:00  postfwd2::policy::child
nobody    1213  1203  0 23:51 ?        00:00:00  postfwd2::policy::child
[root@cent6 ~]#

[root@cent6 postfwd-1.34]# netstat -antp | grep postfwd2
tcp        0      0 127.0.0.1:10045             0.0.0.0:*                   LISTEN      1288/ postfwd2:
[root@cent6 postfwd-1.34]#



また、メールログには以下のように出力されている。

Mar  3 23:51:13 cent6 postfwd2/master[1200]: postfwd2 1.34 starting
Mar  3 23:51:13 cent6 postfwd2/master[1201]: Started cache at pid 1202
Mar  3 23:51:13 cent6 postfwd2/master[1202]: 2013/03/03-23:51:13 postfwd2::cache (type Net::Server::Multiplex) starting! pid(1202)
Mar  3 23:51:13 cent6 postfwd2/master[1201]: Started server at pid 1203
Mar  3 23:51:13 cent6 postfwd2/master[1203]: 2013/03/03-23:51:13 postfwd2::server (type Net::Server::PreFork) starting! pid(1203)
Mar  3 23:51:13 cent6 postfwd2/master[1202]: Binding to UNIX socket file /var/tmp/postfwd2-cache.socket using SOCK_STREAM#012
Mar  3 23:51:13 cent6 postfwd2/cache[1202]: ready for input
Mar  3 23:51:13 cent6 postfwd2/master[1203]: Binding to TCP port 10045 on host 127.0.0.1#012
Mar  3 23:51:13 cent6 postfwd2/policy[1203]: critical: no rules found - i feel useless (have you set -f or -r?)
Mar  3 23:51:13 cent6 postfwd2/policy[1203]: ready for input



以上で、セットアップは完了です。
設定ファイルpostfwd.cfが空ファイルなので、実際は何の役にも立ってませんが.....
#設定は、次回書こうと思います。


2013年2月24日日曜日

yum リポジトリの保護(protect)


複数のリポジトリを併用する場合、同一パッケージがバージョン違いで複数用意されてしまう事があります。
→ 通常何も指定をしなければ、バージョンのより新しいものがインストールやアップデートの対象になってしまいます。

この状態を回避する為に、利用しないリポジトリ側でexcludeオプションを指定する事が多々あるかと思いますが、より運用しやすい方法として利用したいパッケージが含まれるリポジトリ側でprotectを設定する手もあります


以下、その手順です。

1.yumのプラグインパッケージをインストールする。

RHEL6系の場合 → yum-plugin-protectbase
RHEL5系の場合 → yum-protectbase


2.protectをかけたいrepoファイルに以下を追記する。

protect=1


以上で設定は完了です。
これで、protectをかけたリポジトリに含まれるパッケージは、他のリポジトリの状態に影響を受けなくなります。


また、protectをかけたリポジトリは、以下のようなメッセージ(青字の部分)が表示されるようになります。

[root@node01 ~]# yum update
Loaded plugins: fastestmirror, protectbase
Loading mirror speeds from cached hostfile
 * base: ftp.tsukuba.wide.ad.jp
 * extras: ftp.tsukuba.wide.ad.jp
 * updates: ftp.tsukuba.wide.ad.jp
27 packages excluded due to repository protections
Setting up Update Process
No Packages marked for Update
[root@node01 ~]#