Answer the question
In order to leave comments, you need to log in
Checking if an IP address is in a range using SQL or PL/SQL?
Hello others.
Please tell me how to use SQL (preferably) or PL / SQL to implement a check for the occurrence of specific IP addresses in a particular range?
Simply put, you need to determine which subnet a particular IP address belongs to:
There is an ip_networks table of the format
RANGE_BEGIN RANGE_END RANGE_NAME<br/>
10.160.1.0 10.160.1.125 MSK<br/>
10.160.1.126 10.160.1.254 SPB
Answer the question
In order to leave comments, you need to log in
If the fields are of type inet, then:
SELECT * FROM ips WHERE inet '10.160.1.15' >= RANGE_BEGIN AND inet '10.160.1.15' <= RANGE_END ;
Well, as much as possible!
Make an ip - unsigned int
record - the bottom ip from the
selection range - the first from the sorted list in ascending order, greater than or equal to the bottom ip from the range
,
while the index is used well and quickly
.
unoccupied blocks are also registered, but this is an offline operation and is done simply.
True, for a separate region there will be many of them. For the world wide, everything will be just fine.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question