IPV6安全保护

1.fail2ban安装
sudo apt install fail2ban
2.拷贝配置文件
#/etc/fail2ban/jail.conf 每次更新都会被重置 
sudo cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.local
sudo vim /etc/fail2ban/jail.local
3.修改jail.local文件
[sshd]
enabled  = true
port     = ssh
filter   = sshd
logpath  = /var/log/auth.log
# 只要是尝试密码登录(无论对错)或者私钥校验失败,都会被记录
maxretry = 3
findtime = 10m
bantime  = 24h

# 关键:确保使用 nftables 以完美支持 IPv6
banaction = nftables-multiport

# 一天尝试5次失败,封一周
[recidive]
enabled  = true
logpath  = /var/log/fail2ban.log
banaction = nftables-multiport
bantime  = 1w
findtime = 1d
maxretry = 5
4.启用fail2ban
sudo systemctl restart fail2ban
5.查看哪些ipv6被封禁
#查看ipv6被封禁
sudo fail2ban-client status sshd
#解封自己的IPv6
sudo fail2ban-client set sshd unbanip <你的IPv6地址>
#查看日志
tail -f /var/log/fail2ban.log
#一键清空 Fail2ban 的 IPv6 黑名单
sudo ip6tables -F f2b-sshd
#清除 recidive(累犯)
sudo ip6tables -F f2b-recidive
posted @ 2026-02-11 21:55  HadyLiu  阅读(21)  评论(0)    收藏  举报