CONTENTS


Lastmodified 2024-02-17 (土) 08:34:56


blacklistd(8)

【参考URL】https://gihyo.jp/admin/serial/01/bsd-yomoyama/0113

https://fnf.seesaa.net/article/476415931.html

https://fnf.seesaa.net/article/476435243.html

/etc/rc.confに追加する設定

# sshd
sshd_enable="YES"
sshd_flags="-o UseBlacklist=yes"

# blacklistd
blacklistd_enable="YES"

#システムを再起動したらブロックをクリア
blacklistd_flags="-f"
#システムを再起動したら再度ルールを適用してブロックを開始
blacklistd_flags="-r"
 
# firewall
firewall_enable="YES"
firewall_type="OPEN"

纏めると

###################################################
sshd_enable="YES"
sshd_flags="-o UseBlacklist=yes"
# blacklistd
blacklistd_enable="YES"
#システムを再起動したらブロックをクリア
#blacklistd_flags="-f"
#システムを再起動したら再度ルールを適用してブロックを開始
blacklistd_flags="-r"
# firewall
firewall_enable="YES"
firewall_type="OPEN"
# touch /etc/ipfw-blacklist.rc
###################################################

ipfw(8)が使われるようにファイルを作成する

# touch /etc/ipfw-blacklist.rc

ftpd の監視

/etc/inetd.conf に、以下のように-Bオプションを追加する。

ftp stream tcp nowait root /usr/libexec/ftpd ftpd -l -B

blacklistd(8)の設定ファイル /etc/blacklistd.conf

# $FreeBSD$
#
# Blacklist rule
# adr/mask:port	type	proto	owner		name	nfail	disable
[local]
ssh		stream	*	*		*	3	24h
ftp		stream	*	*		*	3	24h
smtp		stream	*	*		*	3	24h
submission	stream	*	*		*	3	24h
#6161		stream	tcp6	christos	*	2	10m
*		*	*	*		*	3	60

# adr/mask:port	type	proto	owner		name	nfail	disable
[remote]
#129.168.0.0/16	*	*	*		=	*	*
#6161		=	=	=		=/24	=	=
#*		stream	tcp	*		=	=	=

の ssh ftp を

ssh		stream	*	*		*	3	60s
ftp		stream	*	*		*	3	10m

などと編集するもよし・・・

動作確認

# blacklistctl dump -ar
        address/ma:port id      nfail   remaining time
  192.168.185.1/32:22   OK      3/3     23h58m22s

blocklistctl の登録解除

ipfw table port22 delete XXX.XXX.XXX.XXX/32

とコマンドを打って消す

なお拒否期限が残ってる間は blacklistd を再起動する度に登録されるのでよろしく!

https://qiita.com/nanorkyo/items/cb900135cb736a033c31

blocklistctl の登録解除 ホワイトリスト編」

ホワイトリストをつくって /etc/blacklistd.conf に入れ ておけば終わり

/etc/blacklistd.conf

   # Block ssh, after 3 attempts for 6 hours on the bnx0 interface
    [local]
    # location      type    proto   owner   name    nfail   duration
    bnx0:ssh        *       *       *       *       3       6h
    [remote]
    # Never block 1.2.3.4
    1.2.3.4:ssh     *       *       *       *       *       *      ← これ
    # For addresses coming from 8.8.0.0/16 block class C networks instead
    # individual hosts, but keep the rest of the blocking parameters the same.
    8.8.0.0/16:ssh  *       *       *       /24     =       =

Total access 377:本日 4:昨日 0

Counter: 377, today: 4, yesterday: 0

トップ   編集 凍結 差分 履歴 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS
Last-modified: 2024-02-17 (土) 08:34:56