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.

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

Get Updates on the Splunk Community!

What Is Splunk? Here’s What You Can Do with Splunk

Hey Splunk Community, we know you know Splunk. You likely leverage its unparalleled ability to ingest, index, ...

Level Up Your .conf25: Splunk Arcade Comes to Boston

With .conf25 right around the corner in Boston, there’s a lot to look forward to — inspiring keynotes, ...

Manual Instrumentation with Splunk Observability Cloud: How to Instrument Frontend ...

Although it might seem daunting, as we’ve seen in this series, manual instrumentation can be straightforward ...