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.

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.

Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Index This | What travels the world but is also stuck in place?

April 2026 Edition  Hayyy Splunk Education Enthusiasts and the Eternally Curious!   We’re back with this ...

Discover New Use Cases: Unlock Greater Value from Your Existing Splunk Data

Realizing the full potential of your Splunk investment requires more than just understanding current usage; it ...

Continue Your Journey: Join Session 2 of the Data Management and Federation Bootcamp ...

As data volumes continue to grow and environments become more distributed, managing and optimizing data ...