众所周知,在Wireguard中只能设置允许的IP(AllowedIPs),没办法设置排除部分IP段。但是可以通过一个Python脚本来计算排除掉某个IP或IP段之后的AllowedIPs。改一下下面的参数,然后直接丢Python运行一下,输出结果填在AllowedIPs即可。1234567891011121314151617181920#!/usr/bin/python3from ipaddress import ip_networkstart = '0.0.0.0/0'#需要排除的ip或者ip段exclude = ['10.0.0.0/8', '172.16.0.0/12', '192.168.0.0/16', '6.6.6.6', '8.8.8.8']result = [ip_network(start)]for x in exclude:n = ip_network(x)new = []for y in result:if y.overlaps(n):new.extend(y.address_exclude(n))else:new.append(y)result = newprint(','.join(str(x) for x in sorted
...
继续阅读
(82)