Support Questions

Find answers, ask questions, and share your expertise

Check tcp.sender IP in IP Range - NiFi


I would like to check if the tcp.sender attribute of a ListenTCP NiFi processor is within any of 3 IP ranges specified in a json file and route (using RouteOnAttribute) based on the IP range detected.

I guess the function found here: could be used but I don't know how using NiFi.

Your help will be greatly appreciated.

Thank you.


I solved this by writing a regex for each IP range I am routing to after having broken down to individual attributes the ListenTCP tcp.sender attribute.

E.g. For the Least Significant Byte of the IP address (IP_LSB) I did a regex: IP_LSB <-- ${tcp.sender:substringAfterLast('.')}
Note: I have already updated tcp.sender with ${tcp.sender:substringAfter('/')} to get rid of the forward slash in the attribute.

Hence in the RouteOnAttribute processor I can now do a regex on the individual parts of the IP.
E.g. Route to r_first for Value: ${IP_LSB:toNumber():gt(34):and(${IP_LSB:toNumber():lt(63)})}
That is, if the LSB of the IP address is between 35 and 62 inclusive, the routing would be to r_first.

The above question and the entire response thread below was originally posted in the Community Help track. On Fri Jul 26 22:53 UTC 2019, a member of the HCC moderation staff moved it to the Data Ingestion & Streaming track. The Community Help Track is intended for questions about using the HCC site itself, not technical questions about the use of NiFi processors.

Bill Brooks, Community Moderator
Was your question answered? Make sure to mark the answer as the accepted solution.
If you find a reply useful, say thanks by clicking on the thumbs up button.