V6_TYPE
Returns an INTEGER value that classifies the type of the network address passed to it as defined in IETF RFC 4291 section 2.4.
Returns an INTEGER value that classifies the type of the network address passed to it as defined in IETF RFC 4291 section 2.4. For example, If you pass this function the string 127.0.0.1
, it returns 2 which indicates the address is a loopback address. This function accepts both IPv4 and IPv6 addresses.
Behavior type
ImmutableSyntax
V6_TYPE ( address)
Arguments
address
- A VARBINARY or VARCHAR containing an IPv6 or IPv4 address to describe.
Returns
The values returned by this function are:
Return Value | Address Type | Description |
---|---|---|
0 | GLOBAL | Global unicast addresses |
1 | LINKLOCAL | Link-Local unicast (and private-use) addresses |
2 | LOOPBACK | Loopback addresses |
3 | UNSPECIFIED | Unspecifiedaddresses |
4 | MULTICAST | Multicastaddresses |
The return value is based on the following table of IP address ranges:
Address Family | CIDR | Type |
---|---|---|
IPv4 | 0.0.0.0/8 | UNSPECIFIED |
10.0.0.0/8 | LINKLOCAL | |
127.0.0.0/8 | LOOPBACK | |
169.254.0.0/16 | LINKLOCAL | |
172.16.0.0/12 | LINKLOCAL | |
192.168.0.0/16 | LINKLOCAL | |
224.0.0.0/4 | MULTICAST | |
All other addresses | GLOBAL | |
IPv6 | ::0/128 | UNSPECIFIED |
::1/128 | LOOPBACK | |
fe80::/10 | LINKLOCAL | |
ff00::/8 | MULTICAST | |
All other addresses | GLOBAL |
This function returns NULL if you pass it a NULL value or an invalid address.
Examples
=> SELECT V6_TYPE(V6_ATON('192.168.2.10'));
v6_type
---------
1
(1 row)
=> SELECT V6_TYPE(V6_ATON('2001:db8::8:800:200c:417a'));
v6_type
---------
0
(1 row)