LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Postfix 2.7.0 ignoring main.cf params? (https://www.linuxquestions.org/questions/linux-software-2/postfix-2-7-0-ignoring-main-cf-params-829414/)

Ron7 08-30-2010 07:44 PM

Postfix 2.7.0 ignoring main.cf params?
 
I've recently upgraded my home server from fc5 to fc13 which means installing the latest version of postfix (identified as 2.7.0 in the maillog). It is used to send mail from cron jobs and logwatch to a local mailbox (aliased) and my googlemail account so I can monitor when away from home.

I finally got it working, but had to pull a trick that I feel bad about--it feels very hacky, and does not survive a reboot.

The problem is no matter what I do, this version of Postfix ignores the settings for "masquerade_domains", "myhostname" and "mydomain" in main.cf, using instead getting the domain name from whatever 127.0.0.1 (or :::1) is set to in /etc/hosts!!

To send mail to Internet locations, the "from" needs to be a valid domain with an MX record. In an earlier version of Postfix (2.6.x) I just fudged this to a domain I own (that is parked) in main.cf using "masquerade_domains". Now I have to insert it in /etc/hosts instead of "localhost", eg:

Code:

127.0.0.1  hostname.real.domain hostname
I can't find anyone on the web who seems to be having this problem. Postfix is definitely reading main.cf as it is obviously picking up other setings such as debug_peer_level and proxy_interfaces.

As I said, it works, but I don't like my solution and /etc/hosts gets rewritten to ":::1 localhost6.localdomain6" when the system is rebooted, meaning I have to edit it to get Postfix working again as sendmail rejects "localhost6.localdomain6" as not found.

Suggestions most welcome.

kbp 08-30-2010 08:17 PM

Could you please provide a 'postconf -n'.. feel free to sanitise

cheers

Ron7 08-30-2010 11:14 PM

Quote:

Originally Posted by kbp (Post 4082983)
Could you please provide a 'postconf -n'.. feel free to sanitise

cheers

Sanitized:

Code:

alias_database = hash:/etc/aliases
alias_maps = hash:/etc/aliases
command_directory = /usr/sbin
config_directory = /etc/postfix
daemon_directory = /usr/libexec/postfix
data_directory = /var/lib/postfix
debug_peer_level = 2
html_directory = no
inet_protocols = all
mail_owner = postfix
mailq_path = /usr/bin/mailq.postfix
manpage_directory = /usr/share/man
masquerade_domains = <my real domain>
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain,
mydomain = <my real domain>
myhostname = kali.<my real domain>
mynetworks = 192.168.1.0/28, 127.0.0.0/8
myorigin = $mydomain
newaliases_path = /usr/bin/newaliases.postfix
proxy_interfaces = xxx.233.47.38
queue_directory = /var/spool/postfix
readme_directory = /usr/share/doc/postfix-2.7.0/README_FILES
sample_directory = /usr/share/doc/postfix-2.7.0/samples
sendmail_path = /usr/sbin/sendmail.postfix
setgid_group = postdrop
unknown_local_recipient_reject_code = 550


kbp 08-30-2010 11:24 PM

Can you try making /etc/hosts look like this ?

Code:

127.0.0.1  localhost.localdomain localhost
192.168.1.X  kali.<your real domain> kali

... also, I'm assuming 'inet_interfaces = all' ?

cheers

Ron7 09-01-2010 12:18 AM

Quote:

Originally Posted by kbp (Post 4083092)
Can you try making /etc/hosts look like this ?
... also, I'm assuming 'inet_interfaces = all' ?

It's not explicitly set, so should default to 'all' if I read the doco right. I've currently got all hosts ip entries as

Code:

192.168.1.x  name name.<my domain>
Will try reversing and rebooting. The sad part is the hosts file and the main.cf were copied from my old fc5 config which worked fine. Progress...

kbp 09-01-2010 12:29 AM

Another possibility is that something went screwy because you upgraded, remember that upgrading is not recommended. If all else fails it may be worth a fresh build ...

Ron7 09-01-2010 03:16 AM

Quote:

Originally Posted by kbp (Post 4084394)
Another possibility is that something went screwy because you upgraded, remember that upgrading is not recommended. If all else fails it may be worth a fresh build ...

Sorry, bad wording. The F13 was a clean install from DVD, followed by painstaking rebuild of stuff like users, perl libraries, yum installs (postfix etc) and diffs of new config files with old versions to modify the new ones (I didn't replace the new with old).

All that said, I've just tried editing the hosts file to "ip fully-qualified alias" format, and rebooted.

Results no different--postfix mail still fails be delivered following boot. The previous 127.0.0.1 entry in /etc/hosts (which used a hostname.domain with a MX record) was replaced with the following 2 lines (effectively 2 aliases):

Code:

127.0.0.1        kali        localhost.localdomain        localhost
::1        kali        localhost6.localdomain6        localhost6

Mail stopped being delivered due to postfix picking localhost.localdomain as the "from" domain (despite the main.cf settings, and why not the "kali" string which was in the canonical position?). The maillog extract (edited to change actual names and domains) shows what happened when mailx was used to send 1 mail to two addresses ("root,ron@valid.org").

After changing the 127.0.0.1 entry to the the valid fully qualified host.domain, the same mailx test succeeded. Didn't even have to restart postfix, so it must reread /etc/hosts every time!

Code:

Sep  1 17:18:14 kali postfix/master[1253]: daemon started -- version 2.7.0, configuration /etc/postfix
Sep  1 17:23:57 kali sendmail[2060]: o817Nkpw002060: from=me, size=238, class=0, nrcpts=2, msgid=<201009010723.o817Nkpw002060@localhost.localdomain>, relay=me@localhost
Sep  1 17:23:58 kali postfix/smtpd[2062]: connect from kali[127.0.0.1]
Sep  1 17:23:58 kali postfix/smtpd[2062]: 1B51280162: client=kali[127.0.0.1]
Sep  1 17:23:58 kali postfix/cleanup[2065]: 1B51280162: message-id=<201009010723.o817Nkpw002060@localhost.localdomain>
Sep  1 17:23:58 kali postfix/qmgr[1262]: 1B51280162: from=<me@localhost.localdomain>, size=689, nrcpt=2 (queue active)
Sep  1 17:23:58 kali sendmail[2060]: o817Nkpw002060: to=root,ron@valid.org, ctladdr=chernich (500/500), delay=00:00:12, xdelay=00:00:01, mailer=relay, pri=60238, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (Ok: queued as 1B51280162)
Sep  1 17:23:58 kali postfix/smtpd[2062]: disconnect from kali[127.0.0.1]
Sep  1 17:24:07 kali postfix/smtp[2066]: 1B51280162: to=<root@localhost.localdomain>, relay=none, delay=8.9, delays=0.11/0.04/8.8/0, dsn=5.4.4, status=bounced (Host or domain name not found. Name service error for name=localhost.localdomain type=AAAA: Host not found)
Sep  1 17:24:11 kali postfix/smtp[2067]: 1B51280162: to=<ron@valid.org>, relay=valid.org[75.126.89.28]:25, delay=14, delays=0.11/0.04/13/0.28, dsn=5.0.0, status=bounced (host valid.org[75.126.89.28] said: 550-Verification failed for <me@localhost.localdomain> 550-Unrouteable address 550 Sender verify failed (in reply to RCPT TO command))
Sep  1 17:24:12 kali postfix/cleanup[2065]: 228598018A: message-id=<20100901072412.228598018A@kali.valid.com>
Sep  1 17:24:12 kali postfix/qmgr[1262]: 228598018A: from=<>, size=3315, nrcpt=1 (queue active)
Sep  1 17:24:12 kali postfix/bounce[2068]: 1B51280162: sender non-delivery notification: 228598018A
Sep  1 17:24:12 kali postfix/qmgr[1262]: 1B51280162: removed
Sep  1 17:24:20 kali postfix/smtp[2066]: 228598018A: to=<me@localhost.localdomain>, relay=none, delay=8.4, delays=0.04/0/8.4/0, dsn=5.4.4, status=bounced (Host or domain name not found. Name service error for name=localhost.localdomain type=AAAA: Host not found)
Sep  1 17:24:20 kali postfix/qmgr[1262]: 228598018A: removed


kbp 09-01-2010 08:44 PM

Seems like your system is using dhcp instead of static addressing and something may be modifying /etc/hosts, can you confirm the contents of /etc/sysconfig/network and /etc/sysconfig/network-scripts/ifcfg-eth0 ?

Ron7 09-01-2010 08:52 PM

Some progress, I found that the "kali" which was being inserted as the canonical host name in the localhost address (ipv4 and 6) during boot was being read from the file /etc/sysconfig/network.

The doco says the HOSTNAME value should be canonical, so I changed this and the full host name now gets inserted into the 127.0.0.1 and ::1 lines of the host file during reboot. That sort of fixed my postfix problem of having to make changes after a reboot, though why the main.cf params myhostname, mydomain, and masquerade_domain are all being ignored is still most perplexing. The next point of investigation would be the 2.7.0 source, so I'll probably give up at this point.

The other odd thing is in all Fedora distros I've used since 3, I don't think I've ever seen /etc/hosts unilaterally modified at boot time before F13 (though I skipped 10,11,12 :D )

Ron7 09-01-2010 09:14 PM

Quote:

Originally Posted by kbp (Post 4085505)
Seems like your system is using dhcp instead of static addressing and something may be modifying /etc/hosts, can you confirm the contents of /etc/sysconfig/network and /etc/sysconfig/network-scripts/ifcfg-eth0 ?

You are right about using DHCP. For security, my modem is set to provide fixed IP addresses to specific NICs only. It also has the (short form) name for the address, though the linux box in question has a hostname set in /etc/sysconfig/network (see previous post). The eth0 cfg script seems innocuous:

Code:

DEVICE=eth0
HWADDR=00:1C:25:2F:5C:76
ONBOOT=yes
BOOTPROTO=dhcp
TYPE=Ethernet
NM_CONTROLLED=yes
USERCTL=no
IPV6INIT=no
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
NAME="System eth0"
UUID=5fb06bd0-0bb0-7ffb-45f1-d6edd65f3e03
DNS2=xxx.233.0.3
DNS1=xxx.233.0.4
PEERDNS=yes
PEERROUTES=yes


kbp 09-02-2010 12:36 AM

The 3 directives you're having problems with are all networking related, I think if you switch eth0 to static and fix your /etc/hosts file the problems will go away.. try this:

/etc/sysconfig/network-scripts/ifcfg-eth0
Code:

DEVICE=eth0
HWADDR=00:1C:25:2F:5C:76
ONBOOT=yes
BOOTPROTO=none
TYPE=Ethernet
USERCTL=yes
IPV6INIT=no
IPADDR=192.168.1.X
NETMASK=255.255.255.240
GATEWAY=192.168.1.Y

/etc/hosts
Code:

127.0.0.1  localhost.localdomain localhost
192.168.1.X  kali.<your real domain> kali

/etc/resolv.conf
Code:

domain <your real domain>
nameserver xxx.233.0.4
nameserver xxx.233.0.3

/etc/sysconfig/network
Code:

NETWORKING=yes
NETWORKING_IPV6=no
HOSTNAME=kali.<your real domain>

You can have the GATEWAY configured as above or in /etc/sysconfig/network...

cheers

Ron7 09-02-2010 01:13 AM

Quote:

The 3 directives you're having problems with are all networking related, I think if you switch eth0 to static and fix your /etc/hosts file the problems will go away.. try this:
Almost :D

The 127.0.0.1 and ::1 lines are still being set on boot using the HOSTNAME from /etc/sysconf/network:

Code:

127.0.0.1      kali.xyzzy.com        kali    localhost.localdomain  localhost
::1    kali.xyzzy.com        kali    localhost6.localdomain6 localhost6

And /etc/resolv.conf is still being written at boot. On first try, it was all comments saying I needed to set DNS1 and 2 in the ifcfg script. I did this and now it regenerates the resolv.conf without the 192.168.1.1 nameserver line (good).

So progress, sort of. I agree with the IP statically set, you'd not expect hosts and resolv.conf to get rewritten at boot, but they do! I could chmod +s but that's too tacky for words. However, as is, they are rewritten in a "good" state so postfix works and firefox won't have name RARP delays waiting for the modem DNS to time out.

vch 10-13-2010 12:41 PM

To revive an earlier question in this thread, "The problem is no matter what I do, this version of Postfix ignores the settings for "masquerade_domains", "myhostname" and "mydomain" in main.cf, using instead getting the domain name from whatever 127.0.0.1 (or :::1) is set to in /etc/hosts!!"

I'm having this same issue with RHEL 5.5 and Postfix 2.3.3. Is there a way to tell Postfix to ignore the Linux hostname and use what I tell it in the main.cf for the envelope sender (the from address)? I don't want to change the hostname of the server. I just need to email backup summaries using the "mail" command, but they get rejected due to a non-resolvable domain name (i.e. root@domain.local).

Here is the rejection I get:
550 5.1.0 domain.local does not exist (in reply to MAIL FROM command)

Thanks


All times are GMT -5. The time now is 09:30 PM.