search this site
sponsored links

sponsored links
store
category archive
monthly archive
powered by

最新エントリ5件

CentOS 5のiptablesでポートフィルタリングを行う

CentOS

2010/08/05 13:58

概要

iptablesの設定は再起動で消えてしまう為、設定用シェルスクリプトを作成してシステム起動時に実行する。ただし、今回はサーバ運用を想定しての設定。

iptablesの設定

  1. iptablesはインストール済
  2. 自動起動の設定

    # /sbin/chkconfig --level 2345 iptables on
  3. iptables設定用シェルスクリプトの作成

    # vi /root/iptables.sh
    #!/bin/bash
    
    # 設定をクリア
    iptables -F
    
    # 受信を全て破棄
    iptables -P INPUT DROP
    
    # 送信を全て許可
    iptables -P OUTPUT ACCEPT
    
    # 通過を全て破棄
    iptables -P FORWARD DROP
    
    # ICMPを許可
    iptables -A INPUT -p icmp -j ACCEPT
    
    # ローカルホストからの通信を許可
    iptables -A INPUT -i lo -j ACCEPT
    
    # ローカルエリアからの通信を許可
    iptables -A INPUT -s (ローカルエリアのアドレス) -j ACCEPT
    
    # 自分が出したリクエストに対して戻ってきた通信は許可
    iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
    
    # ブロードキャストアドレス,マルチキャストアドレス宛のパケットを破棄
    iptables -A INPUT -d 255.255.255.255 -j DROP
    iptables -A INPUT -d 224.0.0.1 -j DROP
    
    # SSHの許可
    iptables -A INPUT -p tcp --dport 22 -j ACCEPT
    
    # ローカルエリアからのNetBIOS(Samba)の許可
    iptables -A INPUT -d (ローカルエリアのアドレス) -p tcp --dport 139 -j ACCEPT
    iptables -A INPUT -d (ローカルエリアのアドレス) -p udp --dport 137 -j ACCEPT
    iptables -A INPUT -d (ローカルエリアのアドレス) -p udp --dport 138 -j ACCEPT
    
    # HTTPの許可
    iptables -A INPUT -p tcp --dport 80 -j ACCEPT
    
    # HTTPSの許可
    iptables -A INPUT -p tcp --dport 443 -j ACCEPT
    
    # 上記のルールにマッチしなかったパケットをログに記録して破棄
    iptables -A INPUT -m limit --limit 1/s -j LOG --log-prefix "[IPTABLES INPUT] : "
    iptables -A INPUT -j DROP
    iptables -A FORWARD -m limit --limit 1/s -j LOG --log-prefix "[IPTABLES FORWARD] : "
    iptables -A FORWARD -j DROP
    
    # 設定の保存
    service iptables save
    
    # iptablesの再起動
    service iptables restart
    
  4. 所有権の変更

    # chmod 700 /root/iptables.sh
  5. iptables設定用シェルスクリプトをシステム起動時に実行

    # vi /etc/rc.d/rc.local
    #起動時に iptables を設定
    sh /root/iptables.sh
    

解説サイト

CentOS 5のOpenSSLでApeche用の自己署名証明書を作成する

CentOS

2010/08/05 13:11

自己署名証明書の作成

  1. OpenSSLはインストール済
  2. 作業用ディレクトリの作成

    # mkdir /ssl
  3. 鍵生成時に使用する乱数データ(rand.dat)の作成

    # cd /etc
    # openssl md5 * > /ssl/rand.dat
    

    ※ここでは/etcのmd5ハッシュ値付きファイル一覧を乱数データとして使用

  4. サーバ鍵(server.key)の作成

    # openssl genrsa -des3 -out /ssl/server.key -rand /ssl/rand.dat 1024
    Generating RSA private key, 1024 bit long modulus
    ........++++++
    ......++++++
    e is 65537 (0x10001)
    Enter pass phrase for /ssl/server.key:(サーバ鍵用のパスフレーズを入力)
    Verifying - Enter pass phrase for /ssl/server.key:(サーバ鍵用のパスフレーズを入力)
    

    ※CA鍵(ca.key)作成時のパスワードとは異なるものにする

  5. サーバー証明書(server.csr)の作成

    # openssl req -new -key /ssl/server.key -out /ssl/server.csr
    Enter pass phrase for /etc/httpd/conf/ssl/server.key:(サーバ鍵用のパスフレーズを入力)
    You are about to be asked to enter information that will be incorporated
    into your certificate request.
    What you are about to enter is what is called a Distinguished Name or a DN.
    There are quite a few fields but you can leave some blank
    For some fields there will be a default value,
    If you enter '.', the field will be left blank.
    -----
    Country Name (2 letter code) [GB]:(国コード)
    State or Province Name (full name) [Berkshire]:(都道府県名)
    Locality Name (eg, city) [Newbury]:(市町村名)
    Organization Name (eg, company) [My Company Ltd]:(組織名)
    Organizational Unit Name (eg, section) []:(組織でのユニット名)
    Common Name (eg, your name or your server's hostname) []:(ドメイン名またはIPアドレス)
    Email Address []:(管理者のメールアドレス)
    
    Please enter the following 'extra' attributes
    to be sent with your certificate request
    A challenge password []:(入力せずEnter)
    An optional company name []:(入力せずEnter)
    
  6. ■CA鍵(ca.key)の作成

    # openssl genrsa -des3 -out /ssl/ca.key -rand /ssl/rand.dat 1024
    Generating RSA private key, 1024 bit long modulus
    ........++++++
    ......++++++
    e is 65537 (0x10001)
    Enter pass phrase for /ssl/ca.key:(CA鍵用のパスフレーズを入力)
    Verifying - Enter pass phrase for /ssl/ca.key:(CA鍵用のパスフレーズを入力)
    

    ※サーバ鍵(server.key)作成時のパスワードとは異なるものにする

  7. ■CA証明書(ca.crt)の作成

    # openssl req -new -x509 -days 365 -key /ssl/ca.key -out /ssl/ca.crt
    Enter pass phrase for ca.key:(CA鍵用のパスフレーズを入力)
    You are about to be asked to enter information that will be incorporated
    into your certificate request.
    What you are about to enter is what is called a Distinguished Name or a DN.
    There are quite a few fields but you can leave some blank
    For some fields there will be a default value,
    If you enter '.', the field will be left blank.
    -----
    Country Name (2 letter code) [GB]:(国コード)
    State or Province Name (full name) [Berkshire]:(都道府県名)
    Locality Name (eg, city) [Newbury]:(市町村名)
    Organization Name (eg, company) [My Company Ltd]:(組織名)
    Organizational Unit Name (eg, section) []:(組織でのユニット名)
    Common Name (eg, your name or your server's hostname) []:(ドメイン名またはIPアドレス)
    Email Address []:(管理者のメールアドレス)
    
  8. 署名用のシェルスクリプトの入手

    1. mod_ssl: The Apache Interface to OpenSSLからmod_sslの最新版を入手

      wget (mod_sslのURL)
    2. 解凍してsign.shを取り出し、元ファイルを削除

      # tar xvzf mod_ssl-(バージョン).tar.gz
      # cp /ssl/mod_ssl-(バージョン)/pkg.contrib/sign.sh /ssl
      # rm -rf /ssl/mod_ssl-(バージョン)
      # rm -rf /ssl/mod_ssl-(バージョン).tar.gz
      
  9. CAとしてサーバー証明書(server.csr)に署名

    # sh /ssl/sign.sh /ssl/server.csr
    CA signing: server.csr -> server.crt:
    Using configuration from ca.config
    Enter pass phrase for ./ca.key:(CA鍵用のパスフレーズを入力)
    Check that the request matches the signature
    Signature ok
    The Subject's Distinguished Name is as follows
    countryName           :PRINTABLE:'(国コード)'
    stateOrProvinceName   :PRINTABLE:'(都道府県名)'
    localityName          :PRINTABLE:'(市町村名)'
    organizationName      :PRINTABLE:'(組織名)'
    organizationalUnitName:ASN.1 12:'(組織でのユニット名)'
    commonName            :PRINTABLE:'(ドメイン名またはIPアドレス)'
    emailAddress          :IA5STRING:'(管理者のメールアドレス)'
    Certificate is to be certified until (有効期限の日時) GMT (365 days)
    Sign the certificate? [y/n]:(y)
    
    1 out of 1 certificate requests certified, commit? [y/n](y)
    Write out database with 1 new entries
    Data Base Updated
    CA verifying: server.crt <-> CA cert
    server.crt: OK
    
  10. 証明書一式の所有権の変更

    # cd /ssl
    # chmod -c -R 400 server.* ca.* rand.dat
    
  11. Apacheへの組み込みの為に証明書一式のコピー

    # mkdir /etc/httpd/ssl.key
    # cp -r /ssl/* /etc/httpd/ssl.key
    
  12. Apacheへの組み込み

    # yum -y install mod_ssl
    # vi /etc/httpd/conf.d/ssl.conf
    
    SSLCertificateFile /etc/httpd/ssl.key/server.crt
    SSLCertificateKeyFile /etc/httpd/ssl.key/server.key
    
  13. Apache自動起動の為にサーバ鍵(server.key)のパスフレーズ解除

    # cp /ssl/server.key /ssl/server.key.org
    # openssl rsa -in /ssl/server.key.org -out /ssl/server.key
    
  14. Apacheを再起動

    # /sbin/service httpd restart

※今回の作成方法では有効期限はそれぞれ1年間であり、1年後に同様の作業を行う必要がある

解説サイト

CentOS 5にyumでClamAVをインストールする

CentOS

2010/08/05 09:46

前準備

標準のリポトロジにはClamAVのrpmが用意されていないので、

を参考にしてDAG(rpmforge)リポトロジを追加しておく。

ClamAVのインストールと設定

  1. ClamAVのインストール

    yum --enablerepo=dag -y install clamd
  2. clamd.confを編集

    vi /etc/clamd.conf

    ClamAVをroot権限で実行,ウイルス定義ファイルを日本のサーバから入手

    #User clamav
    DatabaseMirror db.jp.clamav.net
    
  3. 手動起動

    /etc/rc.d/init.d/clamd start
  4. 自動起動の設定

    chkconfig clamd on
  5. ウイルス定義ファイルの更新を有効

    sed -i 's/Example/#Example/g' /etc/freshclam.conf
  6. ウイルス定義ファイル手動更新

    freshclam
  7. 定期スキャンの設定(加筆中)

備考

解説サイト

CentOS 5のyumにDAG(rpmforge)リポトロジを追加

CentOS

2010/08/05 09:41

サードパーティリポトロジ(DAG: RPM packages for Red Hat, RHEL, CentOS and Fedora)の追加手順

  1. GPG-KEYの取得

    wget http://dag.wieers.com/rpm/packages/RPM-GPG-KEY.dag.txt
  2. GPG-KEYの取り込み

    rpm --import RPM-GPG-KEY.dag.txt
  3. 取得したGPG-KEYの削除

    rm -f RPM-GPG-KEY.dag.txt
  4. DAG用リポトロジ設定ファイルの作成

    vi /etc/yum.repos.d/dag.repo
  5. /etc/yum.repos.d/dag.repoの内容

    [dag]
    name=Dag RPM Repository for Red Hat Enterprise Linux
    baseurl=http://apt.sw.be/redhat/el5/en/i386/dag/
    gpgcheck=1
    enabled=0
    
  6. DAGからのインストールの際には明示的にDAGを指定して行う。

    yum --enablerepo=dag install (パッケージ名)

FPSプレイ環境の設定(USBマウスレート変更と3フレーム遅延の解消)

Windows

2010/05/04 18:58

Windows XP SP3でのUSBマウスレートの変更

  1. SP3 用usbport.sys書き換え対応パッチを入手
  2. 入手したusb_patch_no_CRC_check.zipを解凍
  3. 解凍時に作成されたフォルダ内にC:\WINDOWS\system32\drivers\usbport.sysをコピー
  4. patch_vol_en.exeを起動してStartボタンをクリック
  5. 実行後のフォルダ内にはusbport.sys.bak(コピーしたusbport.sysのまま),usbport.sys(パッチ適用後)ができる
  6. Windowsをセーフモードで再起動
  7. 解凍時に作成されたフォルダ内のusbport.sysをC:\WINDOWS\system32\driversに上書きコピー
  8. Windowsを通常再起動

3フレーム遅延を解消する

  1. ATi Tray ToolsをRay の SkyDrive – Windows Liveから入手(Public → attsetup)
  2. ATi Tray Toolsのインストール
  3. ATi Tray Tools右クリック
  4. Tools&Options → General Options
  5. Generalタブ → GUI Language → JAPANESEに変更
  6. Advancedタブ → Enable ATT Shared Memoryのチェックを外す
  7. ATi Tray Toolsを再起動
  8. ATi Tray Tools右クリック → 3D → フリップ キューのサイズ
  9. 0に変更