Splunk Search

How do I find internal and external ip addresses of splunk universal forwarder?

snakhuda
Engager

Hi there,

I have a use case to query internal and external ip addresses of the host which has UF installed. I am using approach below and hoping for a better solution. Appreciate your help in advance!

For external IP:

index=_internal group=tcpin_connections hostname=* 

This will provide me sourceIp (external ip)

For Internal IP:

index=_internal sourcetype=splunkd_access phonehome | rex command to retrieve internal ip from the string

Is this the correct approach? I was hoping for a single search to retrieve both IPs.  

0 Karma
1 Solution

yeahnah
Motivator

Hi @snakhuda 

I'm not sure what you mean by external and internal IP address for a Splunk UF.  However, if you needed to tie these two events together then something like this should work for you

index=_internal (group=tcpin_connections hostname=* sourceIp=* guid=*) OR (sourcetype=splunkd_access phonehome clientip=*)
| rex field=file "(?:(.+?_)){4}(?<hostname>[^_]+)_(?<guid>.*)"
| fields guid hostname sourceIp clientip
| rename sourceIp AS externalIP clientip AS internalIP
| stats values(*) AS * BY guid

Hopefully this helps you find what you're looking for

View solution in original post

seth_a_zuykn-io
Engager

@snakhuda We built this for the external public IP portion if you need it still:
https://zuykn.io/apps/splunk
https://github.com/zuykn/TA-get_public_ip

Get Public IP Add-on
━━━━━━━━━━━

A lightweight, cross-platform add-on that collects your Splunk Forwarder’s external public IPv4 address using native system commands only — implemented in Windows Batch (.bat) and POSIX sh (Linux / Unix / macOS).

━━━━━━━━━━━
⚙️Highlights
• HTTPS or DNS lookup with intelligent fallback
• No dependencies — built-in system tools only
• Auto-selects commands:
 ↳ Windows → curl, certutil, bitsadmin, nslookup
 ↳ Linux / macOS → curl, wget, dig, nslookup
• Works with any IPv4-returning site — checkip.amazonaws.com, ipinfo.io/ip, icanhazip.com, etc.

00_get_public_ip_table.png01_get_public_ip_geostats.png02_get_public_ip_batch.png03_get_public_ip_shell.png

Let me know if you have any questions!
- Seth

Tags (4)

BTrust
Path Finder

Hi @seth_a_zuykn-io ,

Thanks a lot, this was indeed an interesting read and useful input, most appreciated!

/Bjarbe

gcusello
SplunkTrust
SplunkTrust

Hi @snakhuda,

running this search you can have all the information about connected clients, also IP:

| rest splunk_server=<hostname_deployment_server> /services/deployment/server/clients

Ciao.

Giuseppe

0 Karma

yeahnah
Motivator

Hi @snakhuda 

I'm not sure what you mean by external and internal IP address for a Splunk UF.  However, if you needed to tie these two events together then something like this should work for you

index=_internal (group=tcpin_connections hostname=* sourceIp=* guid=*) OR (sourcetype=splunkd_access phonehome clientip=*)
| rex field=file "(?:(.+?_)){4}(?<hostname>[^_]+)_(?<guid>.*)"
| fields guid hostname sourceIp clientip
| rename sourceIp AS externalIP clientip AS internalIP
| stats values(*) AS * BY guid

Hopefully this helps you find what you're looking for

BTrust
Path Finder

Hi @yeahnah,

Unfortunately your solution don't provide the truth as the clientIp is NOT equal to the Internal IP, it's unfortunately the public IP, which is not that same as the internal - and what I'd rather call the Private IP.

The reason I know this is because I'm sitting with a bunch of external UF calling home to a DPL outside the network to all UF's, and I need to get the same information - the internal (private) IP, but it's not available.

Till now I only see one way, which is scripted input and/or an existing app that collects this info.

Your search is still good 😉  it just don't provide what's requested.

0 Karma

PickleRick
SplunkTrust
SplunkTrust

To answer such question one should first define what "internal" and "external" IPs mean here given many possible deployment scenarios including multihomed hosts, NAT-s, intermediate forwarders, proxies and so on. Only then one can start digging into available data.

0 Karma

BTrust
Path Finder

Hi @PickleRick ,

I agree to a certain extend.

The question was here how to "find internal and external ip addresses", and I think we here can agree on, that it's not the Internal IP that is presented, unless they are sitting on the same network. But as many (most I suppose) are more or less distributed, you'll not be able to get the internal ip this way - right?

0 Karma

PickleRick
SplunkTrust
SplunkTrust

The question was very vague and ambiguous.

Let's consider a situation where you have a server hosting two interfaces - 192.168.10.23/24 and 172.17.1.10/24. It receives HEC data on the 172.17.1.10 interface and has a default route via 192.168.10.1. It sends its data to an indexer located at 10.1.2.3/24 but the connection is SNAT-ed so it appears to the indexer as coming from 10.20.1.1.

What is internal and external in this case? It is _not_ straightforward. I could throw in an intermediate forwarder to this mix and possibly some HTTP proxy.

"Internal" and "external" mean different things depending on where you look from.

0 Karma

BTrust
Path Finder

As you say: "is _not_ straightforward", and I agree, why I think the "solution" here is vague, and ought to be refined

0 Karma

snakhuda
Engager

Thank you! This is much better. I was doing running 2 separate queries and then going to use 2 lookup tables to retrieve IPs by hostname. Appreciate your help!

Thanks!!

0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @snakhuda,

good for you, see next time!

Ciao and happy splunking

Giuseppe

P.S.: Karma Points are appreciated by all the contributors 😉

0 Karma
Get Updates on the Splunk Community!

Splunk Decoded: Service Maps vs Service Analyzer Tree View vs Flow Maps

It’s Monday morning, and your phone is buzzing with alert escalations – your customer-facing portal is running ...

What’s New in Splunk Observability – September 2025

What's NewWe are excited to announce the latest enhancements to Splunk Observability, designed to help ITOps ...

Fun with Regular Expression - multiples of nine

Fun with Regular Expression - multiples of nineThis challenge was first posted on Slack #regex channel ...