mirror of
https://github.com/fatedier/frp.git
synced 2026-05-15 16:15:49 -06:00
[GH-ISSUE #4692] ban the brute-force attack ssh ip by fail2ban in frp client #3708
Labels
No labels
In Progress
WIP
WaitingForInfo
bug
doc
duplicate
easy
enhancement
future
help wanted
invalid
lifecycle/stale
need-issue-template
need-usage-help
no plan
proposal
pull-request
question
todo
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: github-starred/frp#3708
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @MikoyChinese on GitHub (Mar 4, 2025).
Original GitHub issue: https://github.com/fatedier/frp/issues/4692
Hi,
This is a tutorial about how to ban the ip whom try to brute force attack your frp client by fail2ban. update config from https://github.com/fatedier/frp/issues/2470.
requirements:
note: If you dont want to build the go-mmproxy, you can try this go-mmproxy.zip version. And for fail2ban, you can found the installation in their github project.
Here are the step:
As for me: All files will save in /home/ubuntu/frp/
1.create a frpc config file :
In this step, you can add
proxy_protocol_versionto turn on Proxy Protocol, and prepare a local port which using in go-mmproxy, not your real forward port.For example, I want to proxy my ssh 22 port with frp with proxy protocol, you need a other port such as 12222, so:
frpc.toml
2. Set up for go-mmproxy:
You can build it from go-mmproxy github main page or download the x86_64 binary which I build on my Ubuntu 20.04 with go version go1.16.5 linux/amd64 from the following url: go-mmproxy.zip, and move it to somepath where you want. For me, I move it to /home/ubuntu/frp/.
3. Create go-mmproxy service file
You need to create a
go-mmproxy.servicein/home/ubuntu/frp/. The go-mmproxy will listen12222and forward to22which is the ssh port.go-mmproxy.service
4. Create frpc service file
frpc.service
If you have done, you can find in your directory, eg: /home/ubuntu/frp/:
The link the services file to /etc/systemd/system/ and enable it.
Add fail2ban
If your OS is Ubuntu, you can install it by
sudo apt install fail2banHere is the config(you can find the config file in /etc/fail2ban/):
create a
jail.localfile in /etc/fail2banThe you can find the remote ip in /var/log/auth.log and /var/log/fail2ban.log.
@MikoyChinese commented on GitHub (Mar 4, 2025):
If you want to improve the security of your FRP server, you can use nft-blackhole to block specific countries. If your SSH service only accepts connections from your home country's IP addresses, give it a try—you'll notice how clean your host becomes.
@wuai1024 commented on GitHub (Mar 5, 2025):
Thank you very much
@wuai1024 commented on GitHub (Mar 5, 2025):
我看
go-mmproxy没有编译,顺便编译了一个docker版本。我是在群辉里面使用的,群辉没有
System管理,就使用 Docker 也是可以。现在效果很好:
@wuai1024 commented on GitHub (Mar 5, 2025):
测试出来了一个小问题。
环境:
frps部署在服务器A上,然后frpc和go-mmproxy部署在服务器B上。访问: 其他机器访问服务器A上
frps监听的端口,穿透到服务器B上可以正常获取到 客户端源公网ip,如上图显示。但是有个特殊情况,不知道是不是环境的问题导致。
就是当我在服务器A中的内网访问这个地址,就会显示内网ip。
@frankjoey2048 commented on GitHub (Mar 16, 2025):
纠正一下:
@frankjoey2048 commented on GitHub (Mar 17, 2025):
这个好像有点问题,如果按照systemctl 的方式写没问题,但docker 就连不上,我猜想是不是
没放进去
@luomo-pro commented on GitHub (Mar 17, 2025):
我前几天用上面朋友的docker,也是怎么连都不行,访问对外的ip,一直会显示服务器返回空内容。
后面自己编译了个docker,要不行的也可以尝试下。
直接在群辉里,创建一个名为Dockerfile的文件,粘贴如下内容:
然后使用这个命令编译:
编译完后要使用就很简单了,使用docker-compose。
注意其中的
PORT_MAPPINGS
定义了对外跟要转发的端口,比如
15000:5000
意思就是监听15000,转发到5000,多个之间使用逗号分割就行。
@wuai1024 commented on GitHub (Mar 17, 2025):
为了安全和透明,这个路由表规则,需要手动执行,没有封装到 Docker 里。
@gexiaopeng commented on GitHub (Apr 9, 2025):
请问你在群晖的docker怎么样配合执行 ip rule 与 ip route 的? 具体能说吗?非常感谢
@gexiaopeng commented on GitHub (Apr 9, 2025):
请问封装在docker为什么会不安全?
@gexiaopeng commented on GitHub (Apr 9, 2025):
此方法可行,非常感谢!
@wuai1024 commented on GitHub (Apr 9, 2025):
任务计划,设置开机执行,用
root账号就可以执行至于我为什么不封装在
docker里,因人而异,毕竟这种跟路由相关的。@wuai1024 commented on GitHub (Apr 9, 2025):
觉得我这样麻烦,可以直接用这个
@github-actions[bot] commented on GitHub (Apr 24, 2025):
Issues go stale after 14d of inactivity. Stale issues rot after an additional 3d of inactivity and eventually close.