- 1. ports
- 2. 構成ファイルの編集
- 3. 起動
- 4. 試験
- 5. 能書き
1. ports
/usr/ports/security/portsentry
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 を遮断します。
/usr/local/etc/portsentry.ignore
は
0.0.0.0
の行を削除して、遮断しない IPアドレス (つまり自分のローカルやワールドの IP アドレス) を記述します。/ を使うことによってネットマスクでの記述ができます。
3. 起動
起動スクリプトが作成されています。
/usr/local/etc/rc.d/portsentry.sh
起動は
> /usr/local/etc/rc.d/portsentry.sh start
停止は
> /usr/local/etc/rc.d/portsentry.sh stop
です。
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 を遮断しないようにすると、ログが出てこなくなったのでうまく動作しているようです。
5. 能書き
2015年8月26日 記
馬鹿まるだしの話をしますが。portsentry についてはつい先ほど知ったのです。
以前、YAMAHA のルータを使っていて(ボーレート 128KB~10MB 時代)、そのファイアウォールまかせにしていて、特に攻撃を受けてもネットワークに影響を受けることなく動作していたので、さほど気にしていなかったのです。
回線を 100MB に変更したとき、お金がなくてルータの購入をけちってしまいました。なので今は YAMAHA のルータではないのです。購入予定はあるのですが、まだ予算がたちません。
ルータからほぼスルーでサーバマシンにアクセスできるため、SSH などは不審な攻撃を受けた結果が、ログに毎日たくさん残っています。SSH 以外でも相当な攻撃を受けていることは予想できるのですが、特に対策もたてないまま時がすぎたのですが。
なんだ、それ風のプログラムが存在しているのでした。
|
|