Getting Data In

Extract public and private IP addresses fields separately

cs308
Loves-to-Learn

I have trouble with getting public and private IP addresses fields separately. How can I extract private and public IP addresses fields separately using regex???  Because, when I extract IP field from failed ssh login log, I get both public and private  fields in same filed, therefore I want extract them in different fields.

Labels (1)
0 Karma

PickleRick
SplunkTrust
SplunkTrust

1. Don't think about it like that. If a field in your data is - let's say - the source of the connection, it is that source regardless of whether it is a public IP or a private one. You can filter on that field later.

2. Even if you tried doing that it will not be pretty using regex alone.

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

@PickleRick I think the point is that @cs308 wants to be able to determine if an IP address is private or not. Yes, the regex may not be pretty, but it is doable (about 135 characters for a version that detects private ip addresses, and about 150 characters for a version that detects non-private ip addresses). As I said, this depends on what the definition of private is and how robust the expression needs to be.

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Please share what you have tried so far and some anonymised sample events that you are working with.

Also, is this ipv4 only?

In general, ipv4 private addresses fall into distinct groups, is it that you want to use these groups to determine which sort of address it is? If so, which groups do you want to treat as private? For example: 127.x.x.x, 192.168.x.x, etc?

0 Karma
Get Updates on the Splunk Community!

Tech Talk Recap | Mastering Threat Hunting

Mastering Threat HuntingDive into the world of threat hunting, exploring the key differences between ...

Observability for AI Applications: Troubleshooting Latency

If you’re working with proprietary company data, you’re probably going to have a locally hosted LLM or many ...

Splunk AI Assistant for SPL vs. ChatGPT: Which One is Better?

In the age of AI, every tool promises to make our lives easier. From summarizing content to writing code, ...