Skip to content

IPV4_GET_INET, IPV6_GET_INET

Extract a strongly typed IPV4 or IPV6 address from a text string and remove masks as needed.

Use the appropriate function for IPV4-typed strings and IPV6-typed strings.

IPV4_GET_INET(text)
IPV6_GET_INET(text)

For example:

premdb=# select ipv4_get_inet('192.168.1.0/10'), 
ipv6_get_inet('2001:0db8:85a3:0000:0000:8a2e:0370:7334/20') 
from sys.const;
 ipv4_get_inet |              ipv6_get_inet              
---------------+-----------------------------------------
 192.168.1.0   | 2001:0db8:85a3:0000:0000:8a2e:0370:7334
(1 row)

Parent topic:Network Address Functions