Luzilla / dnsbl_exporter

Prometheus compatible exporter to query DNSBLs/RBLs.
https://www.luzilla-capital.com/
Other
33 stars 8 forks source link

Support IPv6 #228

Open dragoangel opened 6 months ago

dragoangel commented 6 months ago

Currently IPv6 isn't supported by this module.

For example IP 2003:e8:7f1d:f600:: is listed on zen.spamhaus.org and to check if it is the case we can resolve next record: 0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.6.f.d.1.f.7.8.e.0.0.3.0.0.2.zen.spamhaus.org IN A which is expanded version of IPv6 requested in backward direction as any other IP RBL. as result we will get 127.0.0.11, but /prober?target=2003:e8:7f1d:f600:: will return luzilla_rbls_errors{rbl="zen.spamhaus.org"} 1, manually expanding IPv6 and querying exporter also doesn't works /prober?target=2003:00e8:7f1d:f600:0000:0000:0000:0000.

To support IPv6 we need:

  1. check user provided value if it is a valid IPv6
  2. if this is valid IPv6 we need expand IPv6 to it's full version
  3. if this is not valid IPv6 we need check if this is valid IPv4, and if this also not the case set an error for this target
  4. if this IPv6: remove all : as we don't need them, split IP to array by 1 char, invert order of array and join it back to string by .
  5. if this IPv4: split IP by . to array, invert over of array and join it back to string by .
  6. append . and rbl domain to the end of record and resolve it, profit.
till commented 6 months ago

Can you add an example for a RBL that supports IPv6? Might come in handy to test.

dragoangel commented 6 months ago

Hi @till - it is, in the first part of issue 😊, with real IP, real blacklist, real response...

image

till commented 6 months ago

I thought spamhaus didn't support ipv6?

dragoangel commented 6 months ago

I thought spamhaus didn't support ipv6?

https://check.spamhaus.org/faqs/?id=how_does_xbl_handle_ipv6_addresses_

dragoangel commented 6 months ago

More over you just can paste random ipv6 to https://multirbl.valli.org/ and see most of public rbls that supports ipv6