Splunk Search

Getting reverse of IP address occurring in event ex " 2.20.111.140" should be shown as "140.111.20.2"

yogeshpunia05
Explorer

Events have IP address and are needed to be shown in reverse form .

" 2.20.111.140" should be shown as "140.111.20.2"

0 Karma
1 Solution

yogeshpunia05
Explorer

Thanks mehala for solution:

eval myField="2.20.111.140" |  rex field=myField mode=sed "s/(\d+)\.(\d+)\.(\d+)\.(\d+)/\4.\3.\2.\1/g".

View solution in original post

0 Karma

richgalloway
SplunkTrust
SplunkTrust

Here's one way.

... | rex field=IPAddress "(?P<o1>\d+)\.(?P<o2>\d+)\.(?P<o3>\d+)\.(?P<o4>\d+)" | eval revIPAddress = o4.".".03.".".o2.".".01 | ...
---
If this reply helps you, Karma would be appreciated.
0 Karma

yogeshpunia05
Explorer

Thanks mehala for solution:

eval myField="2.20.111.140" |  rex field=myField mode=sed "s/(\d+)\.(\d+)\.(\d+)\.(\d+)/\4.\3.\2.\1/g".
0 Karma
Get Updates on the Splunk Community!

.conf24 | Registration Open!

Hello, hello! I come bearing good news: Registration for .conf24 is now open!   conf is Splunk’s rad annual ...

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...