OSEC

Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com
Looking up relay IPs from a database

From: Andrew Koros (akoroske.uu.net)
Date: Fri Dec 07 2007 - 00:15:54 CST


Hello,

I have postfix 2.4.6 on Fedora built with postgresql support.

Being a service provider I want to be able to lookup IPs of hosts I
relay for from a postgresql database so that we can manage the IP's
easily without modifying the postfix configurations.

The following is an excerpt from my main.cf

   mynetworks = 127.0.0.0/8,
                hash:/etc/postfix/relay_ips,
                proxy:pgsql:/etc/postfix/pgsql-relay_ips.cf

The pgsql:/etc/postfix/pgsql-relay_ips.cf is a SQL query that calls a
postgresql function to check for a inet IP or subnet in a table and
gives a NULL result if the input is a hostname or if the requested IP
does not exist or is not a part of a listed subnet.

e.g.

   postmap -q 192.168.0.12 pgsql:/etc/postfix/pgsql-relay_ips.cf

gives a result like:
   192.168.0.0/28

While
   postmap -q host.example.com pgsql:/etc/postfix/pgsql-relay_ips.cf

give a result like:
   postmap: warning: table "pgsql:/etc/postfix/pgsql-relay_ips.cf":
empty lookup result for: "host.example.com" -- ignored

It works fine but I keep getting warning messages like the ones below:
Is there a way to get postfix to only query for the IP and not the
hostname? Secondly is there a way to get it to stop these warning
messages in the logs as it can be quit a lot when the server is busy.

Dec 7 08:52:45 smtp-server postfix/proxymap[18778]: warning: table
"pgsql:/etc/postfix/pgsql-relay_ips.cf": empty lookup result for:
"host.example.com" -- ignored
Dec 7 08:52:45 smtp-server postfix/proxymap[18778]: warning: table
"pgsql:/etc/postfix/pgsql-relay_ips.cf": empty lookup result for:
".example.com" -- ignored
Dec 7 08:52:45 smtp-server postfix/proxymap[18778]: warning: table
"pgsql:/etc/postfix/pgsql-relay_ips.cf": empty lookup result for: ".com"
-- ignored
Dec 7 08:52:45 smtp postfix/proxymap[18778]: warning: table
"pgsql:/etc/postfix/pgsql-relay_ips.cf": empty lookup result for:
"192.168.0.150" -- ignored

Regards,

Andrew Koros
Systems Developer

UUNET Kenya Ltd,
Your WiMAX future is now here

Email: akoros <at> ke.uu.net
http://www.ics.uunet.co.ke/

"The contents of this e-mail and any accompanying documentation
is confidential and any use thereof, in whatever form, by anyone
other than the addressee for whom it is intended, is strictly
prohibited."

|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| / / (_)__ __ ____ __ |
| / /__/ / _ \/ // /\ \/ / | Freedom to
| /____/_/_//_/\_,_/ /_/\_\ | Experiment
|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~