Is there an easy way to convert an int to an IP address in PostgreSQL? I was able to go from IP to int using this code:
SELECT inet '1.2.3.4'-'0.0.0.0'
This doesn't work:
SELECT 16909060::inet
I didn't see anything in the documentation. Does anyone know how to do this?
Well, remember that an IP address is a 32 or 128 bit unsigned integer and storing the IP as an integer can have many advantages which will facilitate analysis: Integers use less space: If you are using a database, the 32bit INT takes up 4 bytes whereas you will need 15bytes to store an IP address as a string.
To do this in Chrome, simply open up the DevTools, navigate to the Network tab and select the site's HTML doc. You should then see the IP address associated with that URL under Headers > General > Remote Address.
DNS servers convert URLs and domain names into IP addresses that computers can understand and use. They translate what a user types into a browser into something the machine can use to find a webpage.
SELECT '0.0.0.0'::inet + 16909060
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With