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
Get Updates on the Splunk Community!

Earn a $35 Gift Card for Answering our Splunk Admins & App Developer Survey

Survey for Splunk Admins and App Developers is open now! | Earn a $35 gift card!      Hello there,  Splunk ...

Continuing Innovation & New Integrations Unlock Full Stack Observability For Your ...

You’ve probably heard the latest about AppDynamics joining the Splunk Observability portfolio, deepening our ...

Monitoring Amazon Elastic Kubernetes Service (EKS)

As we’ve seen, integrating Kubernetes environments with Splunk Observability Cloud is a quick and easy way to ...