找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 12403|回复: 3

[其它] 请教 获取vpn认证失败的ip地址

[复制链接]
发表于 2020-12-11 20:09:34 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?注册

×
如果vpn拨入认证失败,就把这个ip加入黑名单一分钟。

请问,获取拨入ip地址


routeros
发表于 2020-12-12 10:22:38 | 显示全部楼层
用计费的话可以很轻松的实现并且进行统计
routeros
回复

使用道具 举报

发表于 2020-12-14 21:13:14 | 显示全部楼层
本帖最后由 cspm333 于 2020-12-14 21:23 编辑

將連線ip抓到temp裡:
Snap4.jpg
  1. /ip firewall mangle
  2. add action=jump chain=input connection-state=new dst-port=1723,443,1194 in-interface-list=WAN jump-target=vpn-point protocol=tcp
  3. add action=jump chain=input connection-state=new dst-port=1701,500,4500 in-interface-list=WAN jump-target=vpn-point protocol=udp
  4. add action=return chain=vpn-point src-address-list=VPN
  5. add action=add-src-to-address-list address-list=temp address-list-timeout=2m chain= vpn-point src-address-list=!temp
复制代码

profile:有連線的從temp移除,並置入VPN
Snap5.jpg
  1. :do {/ip firewall address-list add list=VPN comment=mobile address=$"caller-id" timeout=1d} on-error={}
  2. :do {/ip firewall address-list remove [find list~"(temp|Scanners)" address=$"caller-id" dynamic]} on-error={}
复制代码

帳號綁定profile:VPN
Snap6.jpg

未在接觸後1分鐘內完成連線的遠端,停止1分鐘後才能繼續。
Snap7.jpg
  1. /ip firewall raw
  2. add action=drop chain=prerouting src-address-list=Scanners
复制代码

驗證script:
Snap8.jpg
  1. :global vpn
  2. :local connected [/ip firewall address-list find list=temp dynamic]

  3. :local scanners 0
  4. :foreach i in=$connected do={
  5.   :if ([/ip firewall address-list get $i timeout]<0:1:0) do={
  6.     :do {/ip firewall address-list add list=Scanners address=[get $i address] timeout=1m} on-error={}
  7.     /ip firewall address-list remove $i ; :set scanners ($scanners+1)
  8.   }
  9. }
  10. :if ([:len $connected]>$scanners) do={:set vpn ($vpn-1)}
复制代码

排程,每分鐘檢查一次:
Snap9.jpg
  1. :global vpn
  2. :if ([:typeof $vpn]!="num") do={:set vpn 0}

  3. :local check [/ip firewall mangle get [find src-address-list~"temp"] byte]
  4. :if ($vpn!=$check) do={:set vpn $check ; /system script run vpn-server}
复制代码


routeros
回复

使用道具 举报

发表于 2020-12-18 22:46:45 | 显示全部楼层
这个工作应该让RADIUS来做,不应该让接入路由器承担这个压力
routeros
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|Archiver|手机版|小黑屋|软路由 ( 渝ICP备15001194号-1|渝公网安备 50011602500124号 )

GMT+8, 2024-3-28 19:19 , Processed in 0.161088 second(s), 5 queries , Gzip On, Redis On.

Powered by Discuz! X3.5 Licensed

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表