1

I'm having a problem with Postfix (on Centos 6.5) whereby I have to set myhostname explicitly in main.cf, otherwise local mail is relayed through the relay host.

According to the Postfix main.cf: "The default is to use the fully-qualified domain name from gethostname()."

My /etc/hosts file is:

127.0.0.1       localhost
10.0.0.3        server123.company.org server123

hostname and hostname -f return correctly.

How can I troubleshoot why this isn't working?

2

Solved... problem was incorrect entry in /etc/sysconfig/network for HOSTNAME. This was set to the short name instead of the FQDN. Fixed the entry in that file and restarted the network service.

Was able to check that gethostname() retrieves the full hostname via the following test program:

#include <stdio.h>
#include <unistd.h>
#include <limits.h>

int main(int argc, char *argv[])
{
    char hostname[HOST_NAME_MAX];

    if (gethostname(hostname, sizeof hostname) == 0)
        puts(hostname);
    else
        perror("gethostname");

    return 0;
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.