Difference between revisions of "Postgres INET NTOA"
From Observer GigaFlow Support | VIAVI Solutions Inc.
Kevin Wilkie (Talk | contribs) (Created page with "To convert from an integer to an IP address Add the following function to postgres CREATE OR REPLACE FUNCTION kinetntoa(ip integer) RETURNS text AS $$ BEGIN return ((ip ...") |
Latest revision as of 08:42, 29 August 2023
To convert from an integer to an IP address
Add the following function to postgres
CREATE OR REPLACE FUNCTION kinetntoa(ip integer) RETURNS text AS $$ BEGIN return ((ip >> 24) & 255)|| '.' || ((ip >> 16) & 255)|| '.' || ((ip >> 8) & 255) || '.' || (ip & 255); END; $$ LANGUAGE plpgsql;
Use as such
select kinetntoa(srcadd::int),kinetntoa(dstadd::int) from netflow limit 1000;