-
-
Notifications
You must be signed in to change notification settings - Fork 13.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature Request] 服务端好像没有防火墙类的插件?fail2ban 使用说明 #3832
Comments
然而,效果并不明显,别人的爆破脚本很机智,不会一直爆破,有间隔时间:
半小时后仅仅才ban了4个ip:
暂未找到更好的解决办法 |
在未来的版本重构之后,会计划增加 ip 白名单的功能。 但是防火墙是很复杂的能力,也不是项目核心,目前可以尝试通过服务端插件的功能进行扩展,https://github.com/fatedier/frp/blob/dev/doc/server_plugin.md#newuserconn |
不知是否可以屏蔽那些多次在短时间内创建连接并关闭的ip,等有时间了尝试写一下插件试试 |
可以考虑更严格的fail2ban策略,比如失败3次ban一年 |
目前的策略是大时间窗口检测,24小时内触发250次就ban。 |
失败3次不行,frps没办法判断这个连接是成功了还是失败了 |
为了更准确一点,可以结合 #2470 里面介绍的方法,从frpc client端拿到真实ip, 更简单一点的办法是,从client中过滤出fail的auth log,然后写到server端的syslog里面去,由server端的fail2ban自动处理这些非法访问。 jail.local
maxRetry和banTime尽量改小是因为,我们把报告事件当成ban action,这两个频率不一样,需要让server尽量感知变化。 action.d/report2frps.local
最后因为复用了sshd的filter和action,默认只会ban ssh这个port,需要把内网转发的port(<ddd>自行替换)也加到规则里
或者server段jail.local里面把iptables改成iptables-allport
|
@pansila 您好,请问如果使用了跳板机的话,从跳板机经 |
那你在跳板机处理ip啊 |
我是用服务端插件处理的 app.post("handle", async (c, next) => {
let req = await c.req.json() as FrpsRpcReq
const checkResult = checkFrpsRpcReq(req)
if (checkResult) {
return c.json({"reject": false, "unchange": true})
} else {
return c.json({"reject": true, "reject_reason": "invalid user"})
}
});
function checkFrpsRpcReq(req: FrpsRpcReq): boolean {
const userConnFlag = req && req.op === "NewUserConn"
// 只判断用户连接请求
if (!userConnFlag) return true
//只处理tcp和名称以"_fp"结尾的代理
const {user, proxy_type, remote_addr, proxy_name} = req.content
const securityFlag = proxy_type === "tcp" && proxy_name.endsWith("_fp")
if (!securityFlag) return true
let ip = getUserIp(remote_addr)
//过滤安全ip
return IpList.has(ip);
} |
Describe the feature request
最近服务器ssh被爆破上了挖矿病毒,看了下是内网穿透的原因,找了一圈服务端好像没有防火墙类的插件,在issues里找到了使用fail2ban的办法,但没有找到具体的配置过程,在此记录下,减少后人走的弯路。
安装过程就不说了,安装完成之后在/etc/fail2ban/filter.d/目录下新建frps-ssh.conf,写入:
该文件是为了匹配frps的连接日志
之后将/etc/fail2ban/jail.conf 复制为 jail.local
在最后添加:
配置好之后重启fail2ban服务即可
以上
Describe alternatives you've considered
No response
Affected area
The text was updated successfully, but these errors were encountered: