Splunk Enterprise Security
Highlighted

splunklib.client as client IPv6 Error

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 = parsedurl.hostname
1073 port = parsed
url.port

~\Anaconda3\lib\urllib\parse.py in urlparse(url, scheme, allowfragments)
366 (e.g. netloc is a single string) and we don't expand % escapes."""
367 url, scheme, _coerce
result = coerceargs(url, scheme)
--> 368 splitresult = urlsplit(url, scheme, allowfragments)
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, allowfragments)
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
Highlighted

Re: splunklib.client as client IPv6 Error

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.

0 Karma