3

使用ipset来禁止国外的用户登录openvpn

 1 year ago
source link: https://bajie.dev/posts/20230329-ipset_block/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
  1. 主页
  2. 文章
  3. 使用ipset来禁止国外的用户登录openvpn

使用ipset来禁止国外的用户登录openvpn

2023-03-29 1 分钟阅读

突然来的个需求,要求屏蔽国外的用户登录公司的openvpn,防止滥用,搜了一下教程倒是真不少,问题不少都是要去下载那个无比大的ip地址库,好不容易找了一个可用的。

记录下来,备用,原理很简单,ipset建立一个china的hashset,不停添加条目,最后用iptalbes阻挡一下:

#!/bin/sh
ipset create china hash:net hashsize 10000 maxelem 1000000
ipset add china 1.0.1.0/24
......
ipset add china 91.234.36.0/24
iptables -I INPUT -m set --match-set china src -p udp -m udp --dport 1194 -j ACCEPT
iptables -A INPUT -p udp --dport 1194 -j DROP

相应脚本的下载:

ipset-rules.txt



About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK