| はじめての自宅サーバ構築 - Fedora/CentOS - | Last Update | 2008/05/16 | |
| It opened to 2004/09/19. 当サイトはFedora9で運用しています |
Visitors Pageviews Today(IP/PV) |
3,251,070 12,000,145 1,539/8,802 |
|
デルではおとくなキャンペーン実施中! |
レノボ Web 広告限定ストア(キャンペーン&新着情報) |
「ip-sentinel」のインストール # yum -y install ip-sentinel |
「ip-sentinel」を実行するユーザの作成 # useradd -s /sbin/nologin -d /usr/local/ip-sentinel ip-sentinel ※:「ip-sentinel」はログインを許さない。ホームディレクトリは「/usr/local/ip-sentinel」とする。 ホームディレクトリへ移動 # cd /usr/local/ip-sentinel/ 「ip-sentinel」の取得 ※:2008年04月01日時点での最新バージョンは「Version 0.12」となっています。 [root@centos ip-sentinel]# wget http://savannah.nongnu.org/download/ip-sentinel/ip-sentinel-0.12.tar.bz2 展開 [root@centos ip-sentinel]# bunzip2 ip-sentinel-0.12.tar.bz2 [root@centos ip-sentinel]# tar xvf ip-sentinel-0.12.tar 展開されたディレクトリへ移動 [root@centos ip-sentinel]# cd ip-sentinel-0.12 値の変更(実行ユーザ変更) [root@centos ip-sentinel-0.12]# vi configure : : **************************** Builds in non-GNU/Linux environments are not well tested and will fail probably. To have a minimal chance to succeed, make sure that a recent GNU 'make' will be used. ****************************" >&2;} fi username=nobody ↓ 「nobody」を「ip-sentinel」に変更 username=ip-sentinel configfile=ips.cfg コンパイルとインストール [root@centos ip-sentinel-0.12]# ./configure checking for a BSD-compatible install... /usr/bin/install -c checking whether build environment is sane... yes checking for gawk... gawk checking whether make sets $(MAKE)... yes checking whether to enable maintainer-specific portions of Makefiles... no : : [root@centos ip-sentinel-0.12]# make Making clean in src Making clean in . Making all in . Making all in src ensc_vector/vector-clear.c:1: 警告: -malign-loops is obsolete, use -falign-loops : : [root@centos ip-sentinel-0.12]# make install Making install in . make[1]: Entering directory `/usr/local/ip-sentinel/ip-sentinel-0.12' make[2]: Entering directory `/usr/local/ip-sentinel/ip-sentinel-0.12' make[2]: `install-exec-am' に対して行うべき事はありません。 test -z "/usr/local/man/man8" || mkdir -p -- "/usr/local/man/man8" /usr/bin/install -c -m 644 './doc/ip-sentinel.8' '/usr/local/man/man8/ip-sentinel.8' : : |
設定ファイルの変更 # vi /etc/sysconfig/ip-sentinel # IPS_USER=ip-sentinel # IPS_GROUP= # IPS_CHROOT=/var/lib/ip-sentinel 制限設定ファイルの指定(先頭の「#」を消す) IPS_IPFILE=ips.cfg 各種ログファイルの指定(先頭の「#」を消す) IPS_LOGFILE=/var/log/ip-sentinel.out IPS_ERRFILE=/var/log/ip-sentinel.err # IPS_OPTIONS= NICの指定(先頭の「#」を消す) IPS_DEVICE=eth0 複数NIC(ネットワークカード)がある場合、対象のデバイス名を指定します。 ## Assign to yes if running a dietlibc-compiled version of ip-sentinel ## on a system using remote NSS for passwd-lookups (e.g. LDAP, NIS). ## ## When using a group which is not the effective group of the user, ## you will have to assign the numeric gid of this group to GROUP. # IPS_NEEDS_NUMERIC_UID= |
制限設定ファイルの作成(新規作成)
# vi /var/lib/ip-sentinel/ips.cfg
全てのIPアドレスを拒否
0.0.0.0/0
IPアドレスが「192.168.1.100」および、MACアドレスが「aa:bb:cc:dd:ee:11」を許可
192.168.1.100@!aa:bb:cc:dd:ee:11
IPアドレスが「192.168.1.120」〜「192.168.1.129」の範囲で、MACアドレスが「aa:bb:cc:dd:ee:22」を許可
192.168.1.{120-129}@!aa:bb:cc:dd:ee:22
IPアドレスが「192.168.1.130」または「192.168.1.139」で、MACアドレスが「aa:bb:cc:dd:ee:33」を許可
192.168.1.{130,129}@!aa:bb:cc:dd:ee:33
IPアドレスが「192.168.1.140」〜「192.168.1.149」または「192.168.2.140」〜「192.168.2.149」で、MACアドレスが「aa:bb:cc:dd:ee:44」を許可
192.168.{1,2}.{140-149}@!aa:bb:cc:dd:ee:44
IPアドレスに関係なくMACアドレスが「aa:bb:cc:dd:ee:55」を許可 (一番手っ取り早く有効な手段)
ネットワーク接続を許す機器のMACアドレスを全て下記の様に定義するのが望ましい
*@!aa:bb:cc:dd:ee:55
※:考え方はファイアウォールと同じで、全てを拒否し必要な機器のみ許可すると考えた方がわかりやすいでしょう。
【Fedora7 / Fedora8 以外は以下を実施】
制限設定ファイルのオーナ・グループ変更
# chown ip-sentinel:ip-sentinel /usr/local/ip-sentinel/ips.cfg
|
「ip-sentinel」の起動 # /etc/rc.d/init.d/ip-sentinel start ip-sentinel を起動中: [ OK ] 「ip-sentinel」の終了方法 # /etc/rc.d/init.d/ip-sentinel stop |
「ip-sentinel」の起動 # /usr/local/sbin/ip-sentinel -r /usr/local/ip-sentinel -i /ips.cfg --direction BOTH eth0 ※:最後の「eth0」はネットワークカードの番号です。 制限をかけたいネットワークに繋がれたネットワークカードを指定します。 「ip-sentinel」の終了方法 終了したい場合は、「ip-sentinel」が実行されているプロセス番号を強制終了します。 「ip-sentinel」のプロセス表示 # ps -ef | grep ip-sentinel 512 9125 1 0 14:30 ? 00:00:00 /usr/local/sbin/ip-sentinel -r /usr/local/ip-sentinel -i /ips.cfg --direction BOTH eth0 512 9126 9125 0 14:30 ? 00:00:00 /usr/local/sbin/ip-sentinel -r /usr/local/ip-sentinel -i /ips.cfg --direction BOTH eth0 root 9131 32451 0 14:30 pts/2 00:00:00 grep ip-sentinel ※:最後の「root 9131 32451 0 14:30 pts/2 00:00:00 grep ip-sentinel」はプロセス表示時のコマンドなので無視 「ip-sentinel」の終了 # kill -9 9125 9126 ※:上記のプロセス番号を「-9」(強制終了)で終了させます |
起動時に「ip-sentinel」を起動する # chkconfig ip-sentinel on 設定内容を確認 # chkconfig --list ip-sentinel ip-sentinel 0:off 1:off 2:on 3:on 4:on 5:on 6:off |
起動時に実行される「/etc/rc.local」に起動コマンドを登録する # vi /etc/rc.local 最終行に以下を追加する /usr/local/sbin/ip-sentinel -r /usr/local/ip-sentinel -i /ips.cfg --direction BOTH eth0 |
# cat /var/log/ip-sentinel.out @4000000047d9e3712b4bc168: (Re)reading blacklist. @4000000047d9e37519ccc068: 192.168.1.170/aa:bb:cc:dd:ee:ff -> 192.168.1.170/00:00:00:00:00:00 [01:80:c2:00:00:01] @4000000047d9e37519d06dd0: 192.168.1.170/aa:bb:cc:dd:ee:ff >- 192.168.1.170/00:00:00:00:00:00 [01:80:c2:00:00:01] IP「192.168.1.170」MAC「aa:bb:cc:dd:ee:ff」のPCが、でたらめなMAC「01:80:c2:00:00:01」に強制変更されています。 IPアドレスからEthernetの物理アドレス(MACアドレス)を求めるのに使われるARP(アドレス解決プロトコル)を強制変更し通信できなくしてしまいます。 |