Splunk Enterprise Security

Convert IPv4 Addresses to decimal

Travlin1
Engager

Hello everyone!

I most likely could solve this problem if given enough time, but always seem to never have enough 🙃.  Within Enterprise security we pull asset information via LDAPsearch into our ES instance hosted in Splunk Cloud. Within the cn=* field, multiplies for both IP and hostnames. We aim for host fields to be either hostname or nt_host. some of these values though are written as such:

cn=192_168_1_1

 

I want to evaluate the existing field and output them as normal decimals when seen. I am assuming I would need an if statement keeping intact hostname values while else performing the conversion. I am not at computer right now but will update with some data and my progress thus far.

 

Thanks!

 

Labels (1)
0 Karma
1 Solution

bowesmana
SplunkTrust
SplunkTrust

Something like this?

| makeresults format=csv data="hostname
cn=192_168_1_1
cn=myhost
otherhostnane"
| rex field=hostname "cn=(?<ipAddr>\d{1,3}[._]\d{1,3}[._]\d{1,3}[._]\d{1,3})"
| eval hostname=coalesce(replace(ipAddr, "_", "."), hostname)

View solution in original post

Travlin1
Engager

thanks @bowesmana @sainag_splunk ,

I tried both and results were near same! Sinece the CN field is already extracted I modified the search like this....

base search ....   | rex field=cn "(?<ipAddr>\d{1,3}[._]\d{1,3}[._]\d{1,3}[._]\d{1,3})"
| eval cn = coalesce(replace(ipAddr, "_", "."), cn)


In case anyone runs into this thread later. 

Much appreciated!

0 Karma

bowesmana
SplunkTrust
SplunkTrust

Something like this?

| makeresults format=csv data="hostname
cn=192_168_1_1
cn=myhost
otherhostnane"
| rex field=hostname "cn=(?<ipAddr>\d{1,3}[._]\d{1,3}[._]\d{1,3}[._]\d{1,3})"
| eval hostname=coalesce(replace(ipAddr, "_", "."), hostname)

sainag_splunk
Splunk Employee
Splunk Employee

@Travlin1 something like this?

 

| makeresults
| eval cn=mvappend(
"192_168_1_1",
"10_0_0_5",
"webserver-prod01",
"172_16_32_1",
"database.example.com",
"192_168_0_badformat",
"dev_server_01"
)
| mvexpand cn
| eval converted_host=case(
match(cn, "^\d+_\d+_\d+_\d+$"),
replace(cn, "_", "."),
true(),
cn
)
| eval host_type=case(
match(cn, "^\d+_\d+_\d+_\d+$"),
"ip_address",
true(),
"hostname"
)
| table cn, converted_host, host_type

 

 

 

 

If this helps, Please Upvote.

Get Updates on the Splunk Community!

Uncovering Multi-Account Fraud with Splunk Banking Analytics

Last month, I met with a Senior Fraud Analyst at a nationally recognized bank to discuss their recent success ...

Secure Your Future: A Deep Dive into the Compliance and Security Enhancements for the ...

What has been announced?  In the blog, “Preparing your Splunk Environment for OpensSSL3,”we announced the ...

New This Month in Splunk Observability Cloud - Synthetic Monitoring updates, UI ...

This month, we’re delivering several platform, infrastructure, application and digital experience monitoring ...