FreeBSD 11.1 RELEASE - ポート遮断プログラム portsentry
- 1. ports
- 2. 構成ファイルの編集
- 3. 起動
- 4. 試験
1. ports
cd /usr/ports/security/portsentry
make
make install
2. 構成ファイルの編集
/usr/local/etc/portsentry.conf
/usr/local/etc/portsentry.ignore
この2つを編集します。
「/usr/local/etc/portsentry.conf」は
#KILL_ROUTE="/bin/echo 'block in log on external_interface from $TARGET$/32 to any' | /sbin/ipf -f -"
の先頭の # を削除して生かします。これで、攻撃してきた IP を遮断します。
ただこの行のコメントが「For those running ipfilt (OpenBSD, etc.)」となっていて上の方に「FreeBSD」というコメントのある行があるのが気になりますわなぁ。
/usr/local/etc/portsentry.ignore は
0.0.0.0
の行を削除して、遮断しないアドレス(つまり自分のローカルやワールドのアドレス)を記述します。
/(スラッシュ)を使うことによってサブネットマスクを使ってネットワークアドレスでの記述ができます。
3. 起動
起動スクリプトが作成されています。
/usr/local/etc/rc.d/portsentry.sh
操作コマンドは、以下になります。
プロンプト略
service portsentry.sh start ← 起動
service portsentry.sh stop ← 停止
ステータスを見るオプションがないので、起動しているか見るのはとりあえず
> pgrep -lf portsentry
17304 /usr/local/bin/portsentry -udp
17302 /usr/local/bin/portsentry -tcp
で良しとしましょう。
4. 試験
portsentry を実行している状態でポートスキャンをかけて /var/log/message を見てみます。
Aug 26 14:50:23 vm portsentry[1200]: attackalert: Connect from host: 192.168.174.1/192.168.174.1 to TCP port: 1
Aug 26 14:50:23 vm portsentry[1200]: attackalert: Host 192.168.174.1 has been blocked via wrappers with string: "ALL: 192.168.174.1"
Aug 26 14:50:23 vm portsentry[1200]: attackalert: Host 192.168.174.1 has been blocked via dropped route using command: "/bin/echo
'block in log on external_interface from 192.168.174.1/32 to any' | /sbin/ipf -f -"
Aug 26 14:50:25 vm portsentry[1200]: attackalert: Connect from host: 192.168.174.1/192.168.174.1 to TCP port: 11
Aug 26 14:50:25 vm portsentry[1200]: attackalert: Host: 192.168.174.1 is already blocked. Ignoring
Aug 26 14:50:26 vm portsentry[1200]: attackalert: Connect from host: 192.168.174.1/192.168.174.1 to TCP port: 15
Aug 26 14:50:26 vm portsentry[1200]: attackalert: Host: 192.168.174.1 is already blocked. Ignoring
Aug 26 14:50:38 vm portsentry[1200]: attackalert: Connect from host: 192.168.174.1/192.168.174.1 to TCP port: 79
Aug 26 14:50:38 vm portsentry[1200]: attackalert: Host: 192.168.174.1 is already blocked. Ignoring
・・・
おお、出てる出てる。
/usr/local/etc/portsentry.ignore
を編集して。「192.168.174.1」を遮断しないようにすると、ログが出てこなくなったのでうまく動作しているようです。
|
|