aboutsummaryrefslogtreecommitdiffstats
path: root/bin/exclude_ip_list
blob: 8ddd42e5635e4746bed03d03f9376270d1df348f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!/usr/bin/env python3
from ipaddress import ip_network

start = '0.0.0.0/0'
exclude = ['127.0.0.1', '192.168.1.0/24',
           '185.126.202.69', '87.236.209.206', '185.126.202.69', '94.182.18.223']

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 = new

print(','.join(str(x) for x in sorted(result)))