Splunk Enterprise Security

splunklib.client as client IPv6 Error

jlittiebrant
New Member

Hello,

I am attempting to access the REST api of a splunk instance through Python and am receiving an IPv6 error in parsing the URL I provided. I have pinged the url and also nslookup it and I cannot retrieve an IPv6 address. The code I am using is straight from the docs:

import splunklib.client as client
service = client.connect(host=url, port=port,
username=username, password=password)
assert isinstance(service, client.Service)

The final error message is:
~\Anaconda3\lib\site-packages\splunklib\binding.py in _spliturl(url)
1069 # Crack the given url into (scheme, host, port, path)
1070 def _spliturl(url):
-> 1071 parsed_url = urllib.parse.urlparse(url)
1072 host = parsed_url.hostname
1073 port = parsed_url.port

~\Anaconda3\lib\urllib\parse.py in urlparse(url, scheme, allow_fragments)
366 (e.g. netloc is a single string) and we don't expand % escapes."""
367 url, scheme, _coerce_result = _coerce_args(url, scheme)
--> 368 splitresult = urlsplit(url, scheme, allow_fragments)
369 scheme, netloc, url, query, fragment = splitresult
370 if scheme in uses_params and ';' in url:

~\Anaconda3\lib\urllib\parse.py in urlsplit(url, scheme, allow_fragments)
438 if (('[' in netloc and ']' not in netloc) or
439 (']' in netloc and '[' not in netloc)):
--> 440 raise ValueError("Invalid IPv6 URL")
441 if allow_fragments and '#' in url:
442 url, fragment = url.split('#', 1)

Please assist, or let me know if IPv4 is not supported with the splunk api for Python.

0 Karma

nickhills
Ultra Champion

"I have pinged the url and also nslookup it and I cannot retrieve an IPv6 address."

That could well be your issue if you are unable to resolve the URL.

Is the Splunk Server running on IPv4 or IPv6?
How is it configured in server.conf, and web.conf?
https://docs.splunk.com/Documentation/Splunk/7.2.4/Admin/ConfigureSplunkforIPv6

Splunk and the rest API is supported on both 4&6.

If my comment helps, please give it a thumbs up!
0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.


Introducing Unified TDIR with the New Enterprise Security 8.2

Read the blog

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Community Content Calendar, September edition

Welcome to another insightful post from our Community Content Calendar! We're thrilled to continue bringing ...

Splunkbase Unveils New App Listing Management Public Preview

Splunkbase Unveils New App Listing Management Public PreviewWe're thrilled to announce the public preview of ...

Leveraging Automated Threat Analysis Across the Splunk Ecosystem

Are you leveraging automation to its fullest potential in your threat detection strategy?Our upcoming Security ...