views:

275

answers:

2

Hi

I'd like to have a column in a Postgres table which will store the remote IP address of the user connecting to the database. I'm thinking of data type "inet" with some sort of default constraint. Any ideas?

Thanks.

A: 

Can you be a little more specific? Do you mean to record the IP of every user that connects with the psql command line, or do you have a website built with a Postgres database on the backend? If you're logging from a website, then the inet datatype should work great.

clee
Well, i have a database where different clients around our network are connecting to. For every insert into a specific table I'd like also to record the IP address from where the client is connecting from.
neptoon
+3  A: 

The function for you is inet_client_addr().

Peter Eisentraut
Thanks alot. That's exactly what I was looking for.
neptoon