Which interface for sql connection?

Peter Huetmannsberger huetmann at violine.at
Tue Sep 20 18:13:28 CEST 2011


Hello Mark,

thank you for your answer. (More below)

On Tue, 20 Sep 2011, Mark Martinec wrote:

> Peter,
>
>> yesterday I had a very weird phenomenon. I activated a new
>> network interface, which happened to be eth0.
>>
>> After that amavisd didn't work anymore, because the user
>> amavis at newIPadress was not allowed to connect to the mysqlDB.
>>
>> I was suprised to see that amavis does not try to connect to the DB via
>> 127.0.0.1
>>
>> Is there something wrong with my setup, or is there a place where I can
>> define which IPaddress (it's all running on the same server, which happens
>> to have 3 network interfaces) the daemon uses to connect to the DB?
>
> How are your @lookup_sql_dsn and/or @storage_sql_dsn defined?
>
> The host name (or its IP address) declared there (as part of a data set name)
> usually also determines the source IP address, but the exact logic is left
> for the kernel or a TCP/IP stack to decide. If the specified host is 127.0.0.1
> or 'localhost' or '::1', it is most likely the source IP address will also
> belong to a loopback interface.
>
> Currently there is no way in DBI->connect() to force a source IP address,
> but there is rarely any need for that.

@lookup_sql_dsn =
    ( ['DBI:mysql:database=mail;host=127.0.0.1;port=3306', 'amavis',
 			'password_not_shown'] );

@storage_sql_dsn = @lookup_sql_dsn;

host 127.0.0.1 returns localhost

yet in the logs I got:

connect_to_sql: unable to connect to DSN 
'DBI:mysql:database=mail;host=127.0.0.1;port=3306': Access denied for user 
'amavis'@'192.168.101.1'

the interface eth0 is configured for 192.168.101.1

Very strange. There is no mention whatsoever of that IPaddress in the 
amavisd.conf.

Turning off that interface made it work again (obviously). I am rather 
amazed about this behaviour, but I am sure it is a problem beyond amavis.

Thanks again,

.peter


>
>  Mark
>

-- 

-----------------------------------------
Please note that my email has changed to:
huetmann at violine.at




More information about the amavis-users mailing list