Splunk Search

DNS Resolution in a search

balcv
Contributor

Is it possible to have ip addresses in a search resolved to a host name and displayed in the results rather then the ip address. My search is:

source="udp:514" "dst=192.168." | stats count by dst | sort -count limit=10

This gives me the top ten hit ip addresses. I would like to see the host name rather than (or as well as) the ip address. Can this be done as part of the search string?

Tags (2)
1 Solution

pryzrak
Path Finder

There is no need to create a lookup table as long as the nameserver holds those records. Just use the following after your example search:

<search> | lookup dnslookup clientip as dst OUTPUT clienthost as DST_RESOLVED

View solution in original post

tibbian
Engager

If performance is an issue with dnslookup, which can happen when you have many distinct ips being returned by your search, you may want to populate your own lookup and refresh it nightly when there is less demand for resources. Here's a search I run nightly against a week of Windows security event log data to get the ips of machines that have been logged into, but you could substitute your own search for a list of ips to look up:

sourcetype=wineventlog:security EventCode=4768 NOT src_ip="::1"
| eval ip=replace(src_ip,"[f:]","") 
| dedup ip 
| lookup dnslookup clientip as ip OUTPUTNEW clienthost as hostname 
| table ip, hostname
| outputlookup ip2host.csv

johnsond
Engager

this query has worked for me "lookup dnslookup clientip as lsp_rro OUTPUT clienthost as hops" when trying to make a human readable LSP path. We use /etc/hosts for the IP to hostname lookup, you can also use a DNS server to fill this requirement such as BIND9, MS Server or dnsmasq to name a few.

0 Karma

pryzrak
Path Finder

There is no need to create a lookup table as long as the nameserver holds those records. Just use the following after your example search:

<search> | lookup dnslookup clientip as dst OUTPUT clienthost as DST_RESOLVED

johnsond
Engager

perfect, thanks for this solution - works perfectly

woodcock
Esteemed Legend

You should click "Accept" to close the question.

0 Karma

lukejadamec
Super Champion

Yes. But you will need a lookup table that matches the IP address to the host name.

Depending on the apps you have installed, you may find that this lookup table already exists. If it does already exist you will find it in the lookup folder, and it will automatically populate a field in which case you simply need to add the field to your stats. The name of the field escapes me.

0 Karma

lukejadamec
Super Champion

You answered at the same time I did. Besides, if they are already there...

0 Karma

jtrucks
Splunk Employee
Splunk Employee

Actually, the answers entries I linked to are for using an external command that performs the lookup on the fly and responds with the results.

--
Jesse Trucks
Minister of Magic
0 Karma

jtrucks
Splunk Employee
Splunk Employee

balcv
Contributor

The transforms.conf files did the trick and with a little manipulation of the search I have the results I wanted.

Thanks.

Get Updates on the Splunk Community!

Routing logs with Splunk OTel Collector for Kubernetes

The Splunk Distribution of the OpenTelemetry (OTel) Collector is a product that provides a way to ingest ...

Welcome to the Splunk Community!

(view in My Videos) We're so glad you're here! The Splunk Community is place to connect, learn, give back, and ...

Tech Talk | Elevating Digital Service Excellence: The Synergy of Splunk RUM & APM

Elevating Digital Service Excellence: The Synergy of Real User Monitoring and Application Performance ...