IP range as a variable

How do I save IP ranges as variables. E.g. these work as Lucene queries:

srcip: [10.1.0.1 TO 10.1.0.254]
srcip: 10.1.0.*

I cannot however get them to work as custom variables. I have tried escaping certain characters but had no success.

Thanks