IS_IP_ADDRESS_IN_RANGE

SinceVersion dev

IS_IP_ADDRESS_IN_RANGE

description

Syntax

BOOLEAN IS_IP_ADDRESS_IN_RANGE(STRING ip_str, STRING cidr_prefix)

判断IP(IPv4或IPv6)地址是否包含在以CIDR表示法表示的网络中。如果是,则返回true,否则返回false。

notice

入参ip_str和cidr_prefix均不能为NULL

example

  1. mysql> SELECT is_ip_address_in_range('127.0.0.1', '127.0.0.0/8');
  2. +----------------------------------------------------+
  3. | is_ip_address_in_range('127.0.0.1', '127.0.0.0/8') |
  4. +----------------------------------------------------+
  5. | 1 |
  6. +----------------------------------------------------+
  7. mysql> SELECT is_ip_address_in_range('::ffff:192.168.0.1', '::ffff:192.168.0.4/128');
  8. +------------------------------------------------------------------------+
  9. | is_ip_address_in_range('::ffff:192.168.0.1', '::ffff:192.168.0.4/128') |
  10. +------------------------------------------------------------------------+
  11. | 0 |
  12. +------------------------------------------------------------------------+

keywords

IS_IP_ADDRESS_IN_RANGE, IP