# Geoip filtering for IPv6

**URL:** <https://discourse.haproxy.org/t/geoip-filtering-for-ipv6/2437>\
**Category:** Help!\
**Created:** [April 30, 2018, 7:52am UTC](https://discourse.haproxy.org/t/geoip-filtering-for-ipv6/2437 "2018-04-30T07:52:56Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![JPedroT](https://avatars.discourse-cdn.com/v4/letter/j/7c8e57/32.png) [@JPedroT](https://discourse.haproxy.org/u/JPedroT)\
**Post date:** [April 30, 2018, 7:52am UTC](https://discourse.haproxy.org/t/geoip-filtering-for-ipv6/2437/1 "2018-04-30T07:52:56Z")

</div>

I was able to setup up geofiltering using the tool and info from here

> **[berkayunal/haproxy-geoip-iprange](https://github.com/berkayunal/haproxy-geoip-iprange)**
>
> IP Ranges for Haproxy. Contribute to berkayunal/haproxy-geoip-iprange development by creating an account on GitHub.

Might be other ways of doing it, but that was what I was able to find.

But that only covers IPv4 and I need IPv6 filtering also, since now all IPv6 traffic is blocked.

Is there a similar tool to the iprange that can create lists for v6 also? Or must I write my own?

Any hints on where to look is greatly appreciated

Btw using Haproxy 1.7 on Debian 8.10.

---

<div class="post-metadata">

**Author:** ![JPedroT](https://avatars.discourse-cdn.com/v4/letter/j/7c8e57/32.png) [@JPedroT](https://discourse.haproxy.org/u/JPedroT)\
**Post date:** [May 1, 2018, 11:56am UTC](https://discourse.haproxy.org/t/geoip-filtering-for-ipv6/2437/2 "2018-05-01T11:56:54Z")

</div>

Ended up with having an intern write up a python script to create the files we needed.  
The script works, but YMMV.

```
#!/usr/local/bin/python3
#This only works with Python 3, due to the reliance on ipaddress module

import csv
import ipaddress

with open('geoipv6.csv') as csvfile:
    filereader = csv.reader(csvfile, delimiter = ',')

    for row in filereader:
       start = str(row[0])
       end = str(row[1])
       end = end[2:-1]
       ipaddr2 = [ipaddr for ipaddr in ipaddress.summarize_address_range(ipaddress.IPv6Address(start), ipaddress.IPv6Address(end))]
       printRow = row[2][2:-1]
       print(ipaddr2[0], printRow)
```
