IP Address Functions
This section describes IP address functions, including their syntax, parameters, and usage examples.
Function List
Function |
Description |
---|---|
Checks whether the target IPv4 address is internal or external. |
|
Obtains the prefix of the target IPv4 address. |
|
Checks whether the target IPv4 CIDR block is a subnet of a specified CIDR block. |
|
Checks whether the target IPv4 address is in a specified CIDR block. |
|
Obtains the largest IP address in an IPv4 CIDR block. |
|
Obtains the smallest IP address in an IPv4 CIDR block. |
|
Obtains the range of an IPv4 CIDR block. |
|
Returns the name of the city where an IPv4 address is located. |
|
Returns the carrier name of an IPv4 address. |
|
Returns the carrier name of an IPv6 address. |
|
Returns the code of the country where an IPv6 address is located. |
|
Returns the name of the province where an IPv6 address is located. |
|
Returns the name of the city where an IPv6 address is located. |
|
Returns the network service provider of an IPv6 address. |
|
Returns the coordinates of the city where an IPv6 address is located. |
|
Returns the coordinates of the city where an IPv6 address is located. |
|
Checks whether the IP address is an intranet address. |
ip_to_domain
This function checks whether the target IPv4 address is internal or external.
Syntax: ip_to_domain(expr)
Parameter |
Description |
Type |
Mandatory |
---|---|---|---|
expr |
IP address. |
String |
Yes |
Return value type: string
Example: SELECT IP_TO_DOMAIN('10.110.10.210'), IP_TO_DOMAIN('192.175.4.1')
Type |
Query Statement |
Returned Result |
---|---|---|
Scenario 1 |
IP_TO_DOMAIN('10.110.10.210') |
intranet |
Scenario 2 |
IP_TO_DOMAIN('192.175.4.1') |
internet |
ip_prefix
This field obtains the prefix of the target IPv4 address.
Syntax: ip_prefix(expr, prefixBit)
Parameter |
Description |
Type |
Mandatory |
---|---|---|---|
expr |
IPv4 Address |
String |
Yes |
prefixBit |
Number of prefix digits. |
String |
Yes |
Return value type: string
Example: SELECT IP_PREFIX('10.110.10.210', 8), IP_PREFIX('144.101.32.5', 12)
Type |
Query Statement |
Returned Result |
---|---|---|
Scenario 1 |
IP_PREFIX('10.110.10.210', 8) |
10.0.0.0/8 |
Scenario 2 |
IP_PREFIX('144.101.32.5', 12) |
144.96.0.0/12 |
is_prefix_subnet_of
This function checks whether the target IPv4 CIDR block is a subnet of a specified CIDR block.
Syntax: is_prefix_subnet_of(expr1, expr2)
Parameter |
Description |
Type |
Mandatory |
---|---|---|---|
expr1 |
Specified IPv4 CIDR block. |
String |
Yes |
expr2 |
Target IPv4 CIDR block. |
String |
Yes |
Return value type: Boolean
Example: SELECT IS_PREFIX_SUBNET_OF('192.168.0.1/24', '192.168.1.1/24')
Type |
Query Statement |
Returned Result |
---|---|---|
Scenario |
IS_PREFIX_SUBNET_OF('192.168.0.1/24', '192.168.1.1/24') |
false |
is_subnet_of
This function checks whether the target IPv4 address is in a specified CIDR block.
Syntax: is_subnet_of(expr1, expr2)
Parameter |
Description |
Type |
Mandatory |
---|---|---|---|
expr1 |
Specified IPv4 CIDR block. |
String |
Yes |
expr2 |
Target IPv4 address. |
String |
Yes |
Return value type: Boolean
Example: SELECT IS_SUBNET_OF('192.168.0.1/24', '192.168.1.1')
Type |
Query Statement |
Returned Result |
---|---|---|
Scenario |
IS_SUBNET_OF('192.168.0.1/24', '192.168.1.1') |
false |
ip_subnet_max
This function obtains the largest IP address in an IPv4 CIDR block.
Syntax: ip_subnet_max(expr)
Parameter |
Description |
Type |
Mandatory |
---|---|---|---|
expr |
IPv4 CIDR block. |
String |
Yes |
Return value type: string
Example: SELECT IP_SUBNET_MAX('192.120.80.128/10')
Type |
Query Statement |
Returned Result |
---|---|---|
Scenario |
IP_SUBNET_MAX('192.120.80.128/10') |
192.127.255.255 |
ip_subnet_min
This function obtains the smallest IP address in an IPv4 CIDR block.
Syntax: ip_subnet_min(expr)
Parameter |
Description |
Type |
Mandatory |
---|---|---|---|
expr1 |
IPv4 CIDR block. |
String |
Yes |
Return value type: string
Example: SELECT IP_SUBNET_MIN('192.120.80.128/10')
Type |
Query Statement |
Returned Result |
---|---|---|
Scenario |
IP_SUBNET_MIN('192.120.80.128/10') |
192.64.0.0 |
ip_subnet_range
This function obtains the range of an IPv4 CIDR block.
Syntax: ip_subnet_range(expr)
Parameter |
Description |
Type |
Mandatory |
---|---|---|---|
expr1 |
IPv4 CIDR block. |
String |
Yes |
Return value type: string
Example: SELECT IP_SUBNET_RANGE('192.120.80.128/10')
Type |
Query Statement |
Returned Result |
---|---|---|
Scenario |
IP_SUBNET_RANGE ('192.120.80.128/10') |
["192.64.0.0","192.127.255.255"] |
When the maximum IP address, minimum IP address, and IP address range of a given CIDR block are calculated, its unicast and broadcast addresses are excluded. The maximum and minimum available IP addresses and the available IP address range of the CIDR block is returned.
ip_to_city
This function returns the city of an IPv4 address.
Syntax: ip_to_city(x)
Parameter |
Description |
Type |
Mandatory |
---|---|---|---|
x |
IPv4 address. |
String |
Yes |
Return value type: string
Example: select ip_to_city(ip)
Type |
Query Statement |
Returned Result |
---|---|---|
Scenario |
ip_to_city(ip) |
Cochise |
ip_to_provider
This function returns the carrier name of an IPv4 address.
Syntax: ip_to_provider(x)
Parameter |
Description |
Type |
Mandatory |
---|---|---|---|
x |
IPv4 address. |
String |
Yes |
Return value type: string
Example: select ip_to_provider(ip)
Type |
Query Statement |
Returned Result |
---|---|---|
Scenario |
ip_to_provider(ip) |
CONUS-YPG |
ipv6_to_country
This function returns the carrier name of an IPv6 address.
Syntax: ipv6_to_country(x)
Parameter |
Description |
Type |
Mandatory |
---|---|---|---|
x |
IPv6 address. |
String |
Yes |
Return value type: string
Example: select ipv6_to_country(ip)
Type |
Query Statement |
Returned Result |
---|---|---|
Scenario |
ipv6_to_country(ip) |
China |
ipv6_to_country_code
This function returns the code of the country where an IPv6 address is located.
Syntax: ipv6_to_country_code(x)
Parameter |
Description |
Type |
Mandatory |
---|---|---|---|
x |
IPv6 address. |
String |
Yes |
Return value type: string
Example: select ipv6_to_country_code(ip)
Type |
Query Statement |
Returned Result |
---|---|---|
Scenario |
ipv6_to_country_code(ip) |
CN |
ipv6_to_province
This function returns the name of the province where an IPv6 address is located.
Syntax: ipv6_to_province(x)
Parameter |
Description |
Type |
Mandatory |
---|---|---|---|
x |
IPv6 address. |
String |
Yes |
Return value type: string
Example: select ipv6_to_province(ip)
Type |
Query Statement |
Returned Result |
---|---|---|
Scenario |
ipv6_to_province(ip) |
Shaanxi |
ipv6_to_city
This function returns the name of the city where an IPv6 address is located.
Syntax: ipv6_to_city(x)
Parameter |
Description |
Type |
Mandatory |
---|---|---|---|
x |
IPv6 address. |
String |
Yes |
Return value type: string
Example: select ipv6_to_city(ip)
Type |
Query Statement |
Returned Result |
---|---|---|
Scenario |
ipv6_to_city(ip) |
Xi'an |
ipv6_to_provider
This function returns the network service provider of an IPv6 address.
Syntax: ipv6_to_provider(x)
Parameter |
Description |
Type |
Mandatory |
---|---|---|---|
x |
IPv6 address. |
String |
Yes |
Return value type: string
Example: select ipv6_to_provider(ip)
Type |
Query Statement |
Returned Result |
---|---|---|
Scenario |
ipv6_to_provider(ip) |
China Telecom |
ipv6_to_city_geo
This function returns the coordinates of the city where an IPv6 address is located.
Syntax: ipv6_to_city_geo(x)
Parameter |
Description |
Type |
Mandatory |
---|---|---|---|
x |
IPv6 address. |
String |
Yes |
Return value type: string
Example: select ipv6_to_city_geo(ip)
Type |
Query Statement |
Returned Result |
---|---|---|
Scenario |
ipv6_to_city_geo(ip) |
39.904989,116.405285 |
ipv6_to_geo
This function returns the coordinates of the city where an IPv6 address is located.
Syntax: ipv6_to_geo(x)
Parameter |
Description |
Type |
Mandatory |
---|---|---|---|
x |
IPv6 address. |
String |
Yes |
Return value type: string
Example: select ipv6_to_geo(ip)
Type |
Query Statement |
Returned Result |
---|---|---|
Scenario |
ipv6_to_geo(ip) |
39.904989,116.405285 |
ipv6_to_domain
This function checks whether the IP address is an intranet address.
Syntax: ipv6_to_domain(x)
Parameter |
Description |
Type |
Mandatory |
---|---|---|---|
x |
IPv6 address. |
String |
Yes |
Return value type: string
Example: select ipv6_to_domain(ip)
Type |
Query Statement |
Returned Result |
---|---|---|
Scenario |
ipv6_to_domain(ip) |
internet |
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.