Can I get postfix to use what's returned by dnsdomainname for mydomain?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
41 messages Options
123
Reply | Threaded
Open this post in threaded view
|

Can I get postfix to use what's returned by dnsdomainname for mydomain?

Chris Green-11
It would be really handy if I could get postfix to use the value
returned by the dnsdomainname command for its mydomain value as I
could then use the same main.cf file in several headless 'send only'
systems where postfix is used solely for sending error messages from
cron and similar.

There isn't an 'include' type directive in postfix configuration so I
can't see any way of doing this by capturing the output of
dnsdomainname at startup and then including this in main.cf.

Has anyone else wanted to do anything like this and come up with a
solution?

--
Chris Green
Reply | Threaded
Open this post in threaded view
|

AW: Can I get postfix to use what's returned by dnsdomainname for mydomain?

ludicree
Can't this be simply done by bash/cron?

Execute dnsdomainname
Alter main.cf
postfix reload

Not sure about startup / system boot.

Just my first thoughts.

Greets,
Ludi

-----Urspr√ľngliche Nachricht-----
Von: [hidden email] <[hidden email]> Im
Auftrag von Chris Green
Gesendet: Mittwoch, 10. Februar 2021 14:57
An: [hidden email]
Betreff: Can I get postfix to use what's returned by dnsdomainname for
mydomain?

It would be really handy if I could get postfix to use the value returned by
the dnsdomainname command for its mydomain value as I could then use the
same main.cf file in several headless 'send only'
systems where postfix is used solely for sending error messages from cron
and similar.

There isn't an 'include' type directive in postfix configuration so I can't
see any way of doing this by capturing the output of dnsdomainname at
startup and then including this in main.cf.

Has anyone else wanted to do anything like this and come up with a solution?

--
Chris Green

Reply | Threaded
Open this post in threaded view
|

Re: Can I get postfix to use what's returned by dnsdomainname for mydomain?

Chris Green-11
On Wed, Feb 10, 2021 at 03:03:47PM +0100, [hidden email] wrote:

> > Von: [hidden email] <[hidden email]> Im
> > Auftrag von Chris Green
> > Gesendet: Mittwoch, 10. Februar 2021 14:57
> > An: [hidden email]
> > Betreff: Can I get postfix to use what's returned by dnsdomainname for
> > mydomain?
> >
> > It would be really handy if I could get postfix to use the value returned by
> > the dnsdomainname command for its mydomain value as I could then use the
> > same main.cf file in several headless 'send only'
> > systems where postfix is used solely for sending error messages from cron
> > and similar.
> >
> > There isn't an 'include' type directive in postfix configuration so I can't
> > see any way of doing this by capturing the output of dnsdomainname at
> > startup and then including this in main.cf.
> >
> > Has anyone else wanted to do anything like this and come up with a solution?
>
> Can't this be simply done by bash/cron?
>
> Execute dnsdomainname
> Alter main.cf
> postfix reload
>
> Not sure about startup / system boot.
>
> Just my first thoughts.
>
Yes, I *could* do something like this but it's quite a bit of added
complexity for what is really quite a simple requirement.  I'd have to
add a bit of code to run from (say) /etc/rc.local which would have to
run sed or something similar against the main.cf file.

--
Chris Green
Reply | Threaded
Open this post in threaded view
|

Re: Can I get postfix to use what's returned by dnsdomainname for mydomain?

Matus UHLAR - fantomas
In reply to this post by Chris Green-11
On 10.02.21 13:57, Chris Green wrote:

>It would be really handy if I could get postfix to use the value
>returned by the dnsdomainname command for its mydomain value as I
>could then use the same main.cf file in several headless 'send only'
>systems where postfix is used solely for sending error messages from
>cron and similar.
>
>There isn't an 'include' type directive in postfix configuration so I
>can't see any way of doing this by capturing the output of
>dnsdomainname at startup and then including this in main.cf.
>
>Has anyone else wanted to do anything like this and come up with a
>solution?


the default is get from your myhostname, can't you set up that one?

btw are you sure you dont mean myorigin instead of mydomain?


--
Matus UHLAR - fantomas, [hidden email] ; http://www.fantomas.sk/
Warning: I wish NOT to receive e-mail advertising to this address.
Varovanie: na tuto adresu chcem NEDOSTAVAT akukolvek reklamnu postu.
Spam is for losers who can't get business any other way.
Reply | Threaded
Open this post in threaded view
|

Re: Can I get postfix to use what's returned by dnsdomainname for mydomain?

Chris Green-11
On Wed, Feb 10, 2021 at 03:14:11PM +0100, Matus UHLAR - fantomas wrote:

> On 10.02.21 13:57, Chris Green wrote:
> > It would be really handy if I could get postfix to use the value
> > returned by the dnsdomainname command for its mydomain value as I
> > could then use the same main.cf file in several headless 'send only'
> > systems where postfix is used solely for sending error messages from
> > cron and similar.
> >
> > There isn't an 'include' type directive in postfix configuration so I
> > can't see any way of doing this by capturing the output of
> > dnsdomainname at startup and then including this in main.cf.
> >
> > Has anyone else wanted to do anything like this and come up with a
> > solution?
>
>
> the default is get from your myhostname, can't you set up that one?
>
> btw are you sure you dont mean myorigin instead of mydomain?
>
Apart from the TLS/SASL bits the main.cf for all these headless
systems is:-

    mydomain = zbmc.eu
    myorigin = $mydomain
    relayhost = [mail.gandi.net]:465
    luser_relay = [hidden email]
    local_recipient_maps =
    #
    #
    # We don't accept any incoming connections
    #
    mydestination =
    inet_interfaces = loopback-only

So myhostname isn't explicitly set.

Having 'mydomain = zbmc.eu' worked until now because the systems in
question were on a LAN which is zbmc.eu.  However I'd now rather like
to use the same main.cf on some systems which aren't on the same LAN.
It does need to be set so that one can tell easily where messages come
from.

--
Chris Green
Reply | Threaded
Open this post in threaded view
|

Re: Can I get postfix to use what's returned by dnsdomainname for mydomain?

Wietse Venema
Chris Green:

> On Wed, Feb 10, 2021 at 03:14:11PM +0100, Matus UHLAR - fantomas wrote:
> > On 10.02.21 13:57, Chris Green wrote:
> > > It would be really handy if I could get postfix to use the value
> > > returned by the dnsdomainname command for its mydomain value as I
> > > could then use the same main.cf file in several headless 'send only'
> > > systems where postfix is used solely for sending error messages from
> > > cron and similar.
> > >
> > > There isn't an 'include' type directive in postfix configuration so I
> > > can't see any way of doing this by capturing the output of
> > > dnsdomainname at startup and then including this in main.cf.
> > >
> > > Has anyone else wanted to do anything like this and come up with a
> > > solution?
> >
> >
> > the default is get from your myhostname, can't you set up that one?
> >
> > btw are you sure you dont mean myorigin instead of mydomain?
> >
> Apart from the TLS/SASL bits the main.cf for all these headless
> systems is:-
>
>     mydomain = zbmc.eu
>     myorigin = $mydomain
>     relayhost = [mail.gandi.net]:465
>     luser_relay = [hidden email]
>     local_recipient_maps =
>     #
>     #
>     # We don't accept any incoming connections
>     #
>     mydestination =
>     inet_interfaces = loopback-only
>
> So myhostname isn't explicitly set.
>
> Having 'mydomain = zbmc.eu' worked until now because the systems in
> question were on a LAN which is zbmc.eu.  However I'd now rather like
> to use the same main.cf on some systems which aren't on the same LAN.
> It does need to be set so that one can tell easily where messages come
> from.

First, there is no requirement to SET myhostname. Postfix uses the SYSTEM
HOSTNAME by default. Postfix will automatically append $mydomain
if the SYSTEM HOSTNAME is not in FQDN form.

Second, please don't run sed on main.cf or master.cf. Use postconf
commands instead.

For example:

    postconf "myhostname = $(dnsdomainname)"
    postfix start

Not all the world is LINUX, and most systems get along with the
defaults just fine.

        Wietse
Reply | Threaded
Open this post in threaded view
|

Re: Can I get postfix to use what's returned by dnsdomainname for mydomain?

Chris Green-11
In reply to this post by Chris Green-11
On Wed, Feb 10, 2021 at 03:47:29PM +0100, Matus UHLAR - fantomas wrote:

> On 10.02.21 14:36, Chris Green wrote:
> > Apart from the TLS/SASL bits the main.cf for all these headless
> > systems is:-
> >
> >    mydomain = zbmc.eu
> >    myorigin = $mydomain
> >    relayhost = [mail.gandi.net]:465
> >    luser_relay = [hidden email]
> >    local_recipient_maps =
> >    #
> >    #
> >    # We don't accept any incoming connections
> >    #
> >    mydestination =
> >    inet_interfaces = loopback-only
> >
> > So myhostname isn't explicitly set.
>
> myhostname is set by default to your local hostname and mydomain is set by
> default to your hostname stripped of first segment.
>
Local hostname doesn't have FQDN by default though:-

    chris@isbdGandi$ hostname
    isbdGandi
    chris@isbdGandi$ hostname -f
    isbdGandi.isbd.uk

> Do your OS instances have their hostnames?
>
See above.


> > Having 'mydomain = zbmc.eu' worked until now because the systems in
> > question were on a LAN which is zbmc.eu.  However I'd now rather like
> > to use the same main.cf on some systems which aren't on the same LAN.
> > It does need to be set so that one can tell easily where messages come
> > from.
>
> don't set the myhostname or mydomain in main.cf, and you'll get the default
> values. You can use them.
>
If I remove the mydomain setting from main.cf outgoing mail fails:-

    Feb 10 15:42:03 isbdGandi postfix/smtp[3852]: A59B186D46:
    to=<chris@localdomain>, relay=mail.gandi.net[217.70.178.9]:465,
    delay=0.35, delays=0.06/0/0.07/0.21, dsn=5.5.2, status=bounced (host
    mail.gandi.net[217.70.178.9] said: 504 5.5.2 <chris@localdomain>:
    Recipient address rejected: need fully-qualified address (in reply to
    RCPT TO command))

--
Chris Green
Reply | Threaded
Open this post in threaded view
|

Re: Can I get postfix to use what's returned by dnsdomainname for mydomain?

Chris Green-11
In reply to this post by Wietse Venema
On Wed, Feb 10, 2021 at 09:53:02AM -0500, Wietse Venema wrote:

> Chris Green:
> > On Wed, Feb 10, 2021 at 03:14:11PM +0100, Matus UHLAR - fantomas wrote:
> > > On 10.02.21 13:57, Chris Green wrote:
> > > > It would be really handy if I could get postfix to use the value
> > > > returned by the dnsdomainname command for its mydomain value as I
> > > > could then use the same main.cf file in several headless 'send only'
> > > > systems where postfix is used solely for sending error messages from
> > > > cron and similar.
> > > >
> > > > There isn't an 'include' type directive in postfix configuration so I
> > > > can't see any way of doing this by capturing the output of
> > > > dnsdomainname at startup and then including this in main.cf.
> > > >
> > > > Has anyone else wanted to do anything like this and come up with a
> > > > solution?
> > >
> > >
> > > the default is get from your myhostname, can't you set up that one?
> > >
> > > btw are you sure you dont mean myorigin instead of mydomain?
> > >
> > Apart from the TLS/SASL bits the main.cf for all these headless
> > systems is:-
> >
> >     mydomain = zbmc.eu
> >     myorigin = $mydomain
> >     relayhost = [mail.gandi.net]:465
> >     luser_relay = [hidden email]
> >     local_recipient_maps =
> >     #
> >     #
> >     # We don't accept any incoming connections
> >     #
> >     mydestination =
> >     inet_interfaces = loopback-only
> >
> > So myhostname isn't explicitly set.
> >
> > Having 'mydomain = zbmc.eu' worked until now because the systems in
> > question were on a LAN which is zbmc.eu.  However I'd now rather like
> > to use the same main.cf on some systems which aren't on the same LAN.
> > It does need to be set so that one can tell easily where messages come
> > from.
>
> First, there is no requirement to SET myhostname. Postfix uses the SYSTEM
> HOSTNAME by default. Postfix will automatically append $mydomain
> if the SYSTEM HOSTNAME is not in FQDN form.
>
Yes, OK, that's exactly what I'm seeing.

> Second, please don't run sed on main.cf or master.cf. Use postconf
> commands instead.
>
> For example:
>
>     postconf "myhostname = $(dnsdomainname)"
>     postfix start
>
OK, I was just explaining why I didn't particularly want to do this
sort of thing, sed was just the first thing that came to mind.

These systems are all systemd'ed so I can't just run postfix as above.
However will 'postconf "myhostname = $(dnsdomainname)"' actually
change/set the myhostname value in main.cf?  If so then simply putting
the postconf command in /etc/rc.local will do all I need, especially
after one reboot.

> Not all the world is LINUX, and most systems get along with the
> defaults just fine.
>
Yes, I know, I'm from a mixed background of Sun Solaris and Dec Ultrix
in days gone by.  I just get my ?nix fix by running Linux on all my
own systems! :-)

--
Chris Green
Reply | Threaded
Open this post in threaded view
|

Re: Can I get postfix to use what's returned by dnsdomainname for mydomain?

Jaroslaw Rafa
Dnia 10.02.2021 o godz. 15:10:09 Chris Green pisze:
>
> These systems are all systemd'ed so I can't just run postfix as above.
> However will 'postconf "myhostname = $(dnsdomainname)"' actually
> change/set the myhostname value in main.cf?  If so then simply putting
> the postconf command in /etc/rc.local will do all I need, especially
> after one reboot.

Are these machines moved from domain to domain? Ie. is it possible that
"dnsdomainname" will change, or is it the same all the time? If the latter,
I don't see why do you need to set it at each reboot - it is enough to set
it once. So I would try to set it in a script that deploys/copies Postfix
configuration to the target machine.
--
Pozdrowienia,
   Jaroslaw Rafa
   [hidden email]
--
"In a million years, when kids go to school, they're gonna know: once there
was a Hushpuppy, and she lived with her daddy in the Bathtub."
Reply | Threaded
Open this post in threaded view
|

Re: Can I get postfix to use what's returned by dnsdomainname for mydomain?

Chris Green-11
On Wed, Feb 10, 2021 at 04:40:13PM +0100, Jaroslaw Rafa wrote:

> Dnia 10.02.2021 o godz. 15:10:09 Chris Green pisze:
> >
> > These systems are all systemd'ed so I can't just run postfix as above.
> > However will 'postconf "myhostname = $(dnsdomainname)"' actually
> > change/set the myhostname value in main.cf?  If so then simply putting
> > the postconf command in /etc/rc.local will do all I need, especially
> > after one reboot.
>
> Are these machines moved from domain to domain? Ie. is it possible that
> "dnsdomainname" will change, or is it the same all the time? If the latter,
> I don't see why do you need to set it at each reboot - it is enough to set
> it once. So I would try to set it in a script that deploys/copies Postfix
> configuration to the target machine.

I could just edit the value in each system, but then all the main.cf
files would be different.

Currently I have a single main.cf file kept in mercurial that I deploy
on all these systems.  If I change the file in my mercurial repository
the change gets distributed to all systems (by a file synchronising
process).  I'm just trying to see if I can keep my single master
version of main.cf with a different domain name for each system.

I can keep different versions of main.cf for each system in mercurial
but that means if I want/need to change something related to postfix I
have to remember to make the change in multiple main.cf files.

I don't currently have a mechanism for manipulating files during
deployment from the mercurial repository to the destination.

--
Chris Green
Reply | Threaded
Open this post in threaded view
|

Re: Can I get postfix to use what's returned by dnsdomainname for mydomain?

Jaroslaw Rafa
Dnia 10.02.2021 o godz. 15:55:23 Chris Green pisze:
>
> Currently I have a single main.cf file kept in mercurial that I deploy
> on all these systems.  If I change the file in my mercurial repository
> the change gets distributed to all systems (by a file synchronising
> process).  I'm just trying to see if I can keep my single master
> version of main.cf with a different domain name for each system.
[...]
> I don't currently have a mechanism for manipulating files during
> deployment from the mercurial repository to the destination.

I was thinking of using some placeholder in your "master" cf file instead of
domain name, that gets replaced by a proper value during copying file to the
destination server. This would probably require adding some custom script to
the command that deploys files onto the target that modifies the file after
downloading it.
--
Regards,
   Jaroslaw Rafa
   [hidden email]
--
"In a million years, when kids go to school, they're gonna know: once there
was a Hushpuppy, and she lived with her daddy in the Bathtub."
Reply | Threaded
Open this post in threaded view
|

Re: Can I get postfix to use what's returned by dnsdomainname for mydomain?

Matus UHLAR - fantomas
In reply to this post by Chris Green-11
>> Dnia 10.02.2021 o godz. 15:10:09 Chris Green pisze:
>> >
>> > These systems are all systemd'ed so I can't just run postfix as above.
>> > However will 'postconf "myhostname = $(dnsdomainname)"' actually
>> > change/set the myhostname value in main.cf?  If so then simply putting
>> > the postconf command in /etc/rc.local will do all I need, especially
>> > after one reboot.

>On Wed, Feb 10, 2021 at 04:40:13PM +0100, Jaroslaw Rafa wrote:
>> Are these machines moved from domain to domain? Ie. is it possible that
>> "dnsdomainname" will change, or is it the same all the time? If the latter,
>> I don't see why do you need to set it at each reboot - it is enough to set
>> it once. So I would try to set it in a script that deploys/copies Postfix
>> configuration to the target machine.

On 10.02.21 15:55, Chris Green wrote:
>I could just edit the value in each system, but then all the main.cf
>files would be different.

setting "myhostname = $(dnsdomainname)" what Wietse recommended would not.

Setting FQDN hostname or maybe setting own IP with FQDN in /etc/hosts would
not (I'm not sure whether te latter one would be enough, you can try)

I was in your situation some years ago, when I maintained the same configs
for multiple apps on multiple servers. I maintained /etc/hosts and
hostnames per-machine and most of the rest was the same.

--
Matus UHLAR - fantomas, [hidden email] ; http://www.fantomas.sk/
Warning: I wish NOT to receive e-mail advertising to this address.
Varovanie: na tuto adresu chcem NEDOSTAVAT akukolvek reklamnu postu.
2B|!2B, that's a question!
Reply | Threaded
Open this post in threaded view
|

Re: Can I get postfix to use what's returned by dnsdomainname for mydomain?

Viktor Dukhovni
In reply to this post by Chris Green-11
On Wed, Feb 10, 2021 at 03:01:44PM +0000, Chris Green wrote:

> Local hostname doesn't have FQDN by default though:-
>
>     chris@isbdGandi$ hostname
>     isbdGandi
>     chris@isbdGandi$ hostname -f
>     isbdGandi.isbd.uk
>
> > Do your OS instances have their hostnames?
>
> See above.

The simplest solution is to arrange for the systems to instead have
fully-qualified hostnames.  This will likely have additional benefits
down the line.

If, for some reason, that is not something you're willing/able to do,
then you can use "make" to construct the "main.cf" file for each host,
distributing instead a "Makefile" and a "main.cf.in":

    Makefile:
        main.cf:    main.cf.in
                mkdir -p staged
                cp main.cf.in staged/main.cf
                domain=`domainname` && postconf -c `pwd`/staged mydomain=$$domain
                if ! cmp -s staged/main.cf main.cf; then mv staged/main.cf main.cf; fi

    main.cf.in:
        # whatever
        ...

Deployment command: "umask 022; cd /etc/postfix; make".  You can even do
something similar for deploying multi-instance configurations, by
iterating "make" over each instance.

--
    Viktor.
Reply | Threaded
Open this post in threaded view
|

Re: Can I get postfix to use what's returned by dnsdomainname for mydomain?

@lbutlr
In reply to this post by ludicree
On 10 Feb 2021, at 07:03, [hidden email] wrote:
>> It would be really handy if I could get postfix to use the value returned by
>> the dnsdomainname command for its mydomain value as I could then use the
>> same main.cf file in several headless 'send only'
>> systems where postfix is used solely for sending error messages from cron
>> and similar.
> Can't this be simply done by bash/cron?

Yes. Or even just sed. Create the case file with a placeholder my domain and then replace it. I'm not sure why you would need to do this though, unless myhostname is not getting set properly.

> postfix reload

Ah, yes, a shell script would be the simplest way to reload after making the change.

> Not sure about startup / system boot.

Unless the hostname is changing at boot that shouldn't be any issue, but If it is it should be trivial to hook into the rc.d startup script to do this. A trivial script of a couple of lines should do the trick.


--
If there's a bustle in your hedgerow don't be alarmed now.

Reply | Threaded
Open this post in threaded view
|

Re: Can I get postfix to use what's returned by dnsdomainname for mydomain?

@lbutlr
In reply to this post by Chris Green-11
On 10 Feb 2021, at 07:36, Chris Green <[hidden email]> wrote:
> So myhostname isn't explicitly set.
That is correct. Myshostname is not normally set, it is taken from the machine name by postfix. The only reason you would declare it in main.cf is to override the name for some reasons.

   postconf -d myhostname

Will return the DEFAULT value for myhostname. Should be unique to each of your machines.

--
"Life is one damned kitten after another." Mehitabel the Alley Cat

Reply | Threaded
Open this post in threaded view
|

Re: Can I get postfix to use what's returned by dnsdomainname for mydomain?

Chris Green-11
In reply to this post by Matus UHLAR - fantomas
On Wed, Feb 10, 2021 at 05:31:47PM +0100, Matus UHLAR - fantomas wrote:

> > > Dnia 10.02.2021 o godz. 15:10:09 Chris Green pisze:
> > > >
> > > > These systems are all systemd'ed so I can't just run postfix as above.
> > > > However will 'postconf "myhostname = $(dnsdomainname)"' actually
> > > > change/set the myhostname value in main.cf?  If so then simply putting
> > > > the postconf command in /etc/rc.local will do all I need, especially
> > > > after one reboot.
>
> > On Wed, Feb 10, 2021 at 04:40:13PM +0100, Jaroslaw Rafa wrote:
> > > Are these machines moved from domain to domain? Ie. is it possible that
> > > "dnsdomainname" will change, or is it the same all the time? If the latter,
> > > I don't see why do you need to set it at each reboot - it is enough to set
> > > it once. So I would try to set it in a script that deploys/copies Postfix
> > > configuration to the target machine.
>
> On 10.02.21 15:55, Chris Green wrote:
> > I could just edit the value in each system, but then all the main.cf
> > files would be different.
>
> setting "myhostname = $(dnsdomainname)" what Wietse recommended would not.
>
Yes, but since I'd have to add something to each rc.local (and they're
mostly default, i.e. as installed) it's more stuff to keep maintained.


> Setting FQDN hostname or maybe setting own IP with FQDN in /etc/hosts would
> not (I'm not sure whether te latter one would be enough, you can try)
>
Yes, I've tried these.  I added the FQDN to /etc/hosts such that
dnsdomainname returns the domain but postfix doesn't use that.  I've
also tried setting 'hostname <FQDN>' and that hasn't helped either.


> I was in your situation some years ago, when I maintained the same configs
> for multiple apps on multiple servers. I maintained /etc/hosts and
> hostnames per-machine and most of the rest was the same.
>
So I have the FQDN everywhere:-

    chris@isbdGandi$ hostname
    isbdGandi.isbd.uk
    chris@isbdGandi$ more /etc/hosts
    # The following lines are desirable for IPv4 capable hosts
    127.0.0.1       isbdGandi.isbd.uk isbdGandi isbd localhost
    ...
    ...
    chris@isbdGandi$ dnsdomainname
    isbd.uk
    chris@isbdGandi$

... and now postfix sends cron mail *to* [hidden email] as well as from
[hidden email] which doesn't help at all!  I have an entry for chris in
/etc/aliases:-

    chris:[hidden email]

but this doesn't seem to have worked.  What am I doing wrong now? (I
have run 'newaliases').




--
Chris Green
Reply | Threaded
Open this post in threaded view
|

Re: Can I get postfix to use what's returned by dnsdomainname for mydomain?

Chris Green-11
In reply to this post by Viktor Dukhovni
On Wed, Feb 10, 2021 at 11:36:42AM -0500, Viktor Dukhovni wrote:

> On Wed, Feb 10, 2021 at 03:01:44PM +0000, Chris Green wrote:
>
> > Local hostname doesn't have FQDN by default though:-
> >
> >     chris@isbdGandi$ hostname
> >     isbdGandi
> >     chris@isbdGandi$ hostname -f
> >     isbdGandi.isbd.uk
> >
> > > Do your OS instances have their hostnames?
> >
> > See above.
>
> The simplest solution is to arrange for the systems to instead have
> fully-qualified hostnames.  This will likely have additional benefits
> down the line.
>
They have, it doesn't seem to help.

What exactly do you mean by "... have fully-qualified hostnames?". I
know what you mean by FQDN but in general although 'hostname -f' and
'dnsdomainname' return the domain name postfix still doesn't use it.

--
Chris Green
Reply | Threaded
Open this post in threaded view
|

Re: Can I get postfix to use what's returned by dnsdomainname for mydomain?

Viktor Dukhovni
In reply to this post by Chris Green-11
On Wed, Feb 10, 2021 at 05:05:52PM +0000, Chris Green wrote:

> So I have the FQDN everywhere:-
>
>     chris@isbdGandi$ hostname
>     isbdGandi.isbd.uk
>
> ... and now postfix sends cron mail *to* [hidden email] as well as from
> [hidden email] which doesn't help at all!  I have an entry for chris in
> /etc/aliases:-

The built-in default is:

    $ postconf -d myorigin
    myorigin = $myhostname

Looks like you've set "myorigin = $mydomain", with my $mydomain inferred
from the hostname by dropping the first FQDN label.

>     chris:[hidden email]
>
> but this doesn't seem to have worked.  What am I doing wrong now? (I
> have run 'newaliases').

The aliases(5) table is only consulted when delivering mail to local
recipients (domain listed in $mydestination) via the local(8) delivery
agent.  Alias expansion applies only to envelope recipient addresses,
and generally (absent an "owner-" alias) does not affect the envelope
sender or mail headers.

This may be a good time to clearly (re)state what problem you're trying
to solve, now that you're apparently able to assign the desired mydomain
to each machine.

--
    Viktor.
Reply | Threaded
Open this post in threaded view
|

Re: Can I get postfix to use what's returned by dnsdomainname for mydomain?

Viktor Dukhovni
In reply to this post by Chris Green-11
On Wed, Feb 10, 2021 at 05:14:57PM +0000, Chris Green wrote:

> What exactly do you mean by "... have fully-qualified hostnames?".

This means that the raw system hostname reported via `uname -n` or
`hostname` commands (really the underlying system calls) is an FQDN.

> I know what you mean by FQDN but in general although 'hostname -f' and
> 'dnsdomainname' return the domain name postfix still doesn't use it.

Neither of these reports the raw system hostname (on Linux).

--
    Viktor.
Reply | Threaded
Open this post in threaded view
|

Re: Can I get postfix to use what's returned by dnsdomainname for mydomain?

@lbutlr
In reply to this post by Chris Green-11
On 10 Feb 2021, at 10:05, Chris Green <[hidden email]> wrote:
> but this doesn't seem to have worked.  What am I doing wrong now? (I
> have run 'newaliases').

what does

postconf -d myhostname mydomain myorigin

Report?

It should report:

myhostname = isbdGandi.isbd.uk
mydomain = isbd.uk
myorigin = $myhostname

NONE of these should need to be set in main.cf, as the are default values.

--
'Ah... I see that the new traffic division is having the desired
        effect.' He indicated a large pile of paper. 'I am getting any
        amount of complaints from the Carters' and Drovers' Guild. Well
        done. Do pass on my thanks to Sergeant Colon and his team.'
'I will, sir.'
'I see in one day they clamped seventeen carts, ten horses, eighteen oxen and one duck.'
'It was parked illegally, sir.'

123