Am 01.10.2016 um 13:36 schrieb Mark Fletcher:
On Sat, Oct 01, 2016 at 11:06:07AM +0200, mo wrote:

I think i should elaborate a little more on my setup.. i guess i did not
make that very clear in the first place, sorry about that.

My network is consisting of the following systems:

Main PC - 192.168.23.11  (Running Debian Jessie)
Server  - 192.168.23.200 (Running Debian Jessie)

The server is always online, the PC is only half of the day on.

What i want to do now is the following:

Sending mail from my Main PC to my Server and also the other way around,
from the Server to my Main PC.
The Server should also be able to send mail to the "outside" (Meaning to
other SMTP servers).
The second requirement is optional since i dont own a domain and all this is
sitting locally at my home. The most important thing for me is to send and
receive mail from both systems in my home network.
I hope this made my problem a little clearer :)


Right. So you get mail going back and forth between your two machines,
server and PC, by creating and populating the hubbed_hosts file I
talked about in my previous mail, on both machines, pointing at each
other of course.

I created the hubbed_hosts file under /etc/exim4 and it now works fine, i can send mail from my server to my pc and vice versa :)

If you want to ping the server from the client, you should be able to do
"ping server.local" from your PC (obviously replace the actual name of
your server, which you didn't include in your mail, where I put server).
What is happening if you do that is your PC is saying "get me the
address of server.local!" and the Avahi daemon on your PC either already
knows that, or sends out a broadcast message to your network saying "is
there a server.local in the house???". The Avahi daemon running on the
server responds to that saying "yes, I'm here, and my IP address is
192.168.23.200!". The Avahi daemon on your PC responds to whatever did
the asking (ping in this case) with the required IP. Ping then requests
that packets be sent to IP address quoted. By this mechanism computers
on the same LAN can communicate with each other peer to peer without
fannying around with full-blown DNS, which is what Avahi is for. That is
installed by the Jessie installer by default as far as I can tell, so
both your machines should have it. It doesn't require any configuration,
so if you haven't touched it, it should work as I have described.
Although obviously, you have to substitute the real names for your
server and PC (but you *do* require the .local unless you have configured
Avahi to use something else)

I'm currently not using avahi as a matter of fact, but it works all fine without it ;) (I have static entries in the /etc/hosts file for my server and for the pc - on each system of course) I have never really worked with avahi... i kinda ask myself why do i need it if i can just use DNS or static entries in /etc/hosts. /etc/nsswitch.conf is also configured to lookup the /etc/hosts file first. I know this question is OT, but since you mentioned avahi maybe i can ask you what kind of benefits avahi can offer me? :)
(I'm having a statically configured network with 4 machines)

If you used the default config of exim4 the hubbed_hosts router is set
up and waiting to be used. All you need to do to enable it is to
populate the hubbed_hosts file as I described. The other thing you need
to do is follow Liam's advice, except importantly what needs to be set
there is the "domain" of the local PC (on the local PC) or the server
(on the server) only. So the PC will accept mail for pc.local (or
whatever your pc is called) and the server for server.local (or whatever
the server is called). Then, you will be able to email yourself at the
server from the PC by sending a mail to mo@server.local, where I am
assuming your user name on the server is mo and the server's machine
name is server. Obviously you would substitute real names. And to go the
other way, from the server, you could send a mail to yourself on the PC
by mailing mo@pc.local.

I have asked that before i believe, sorry if this question shows up twice.... But why do i even need to set up hubbed_hosts? I don't really understand why... Should exim not consider the /etc/hosts file to resolve the ip of my pc or server (Which i have entered there) Also i have seen (before it worked) in the log that i get a "destination unreachable"... I just don't understand why exim needs to rely on the hubbed_hosts being set up? (I hope you can understand what i mean, if not i will try my best to make it clearer :D )

Let's take a moment to go through what happens if you send a mail from
PC to server with everything set up as it should be.

On the PC you create a mail and address it to mo@server.local. Let's
imagine you use mutt to create it. And let's assume mutt is using its
default configuration to send the mail, which is to call sendmail. And,
since you have installed exim4, exim has overridden sendmail to actually
be calling exim4. So, when mutt sends a mail, exim4 running on your PC
gets handed the mail.

The first thing it does, is say is this mail for this domain. Hmmm. I am
pc.local. This mail is going to server.local. That ain't me. So not
local delivery. OK, next I will try hubbed hosts. Do I have any
hubbed_hosts? Let's look in the hubbed_hosts file. Yep, I do. Can i find
the @server.local domain in the hubbed_hosts file? Yes, I can. Right,
where do I send it then? Ah, I send it to a machine called server.local.
OK... Oi! Network! Gimme the address for server.local....... (this is
where Avahi does its thing)...Thanks! Right, Connect to 192.168.23.200
port 25!

At this point the exim4 running on your server gets a dig in the ribs,
wakes up, and responds to the connection. The two exim4s talk to each
other and the net result is the mail gets transferred from the exim4
running on the PC to the exim4 running on the server.

Then the exim4 running on the server goes through the same rigmarole,
except it finds that the mail IS addressed to a local address, so it
goes into delivery mode and the mail finds its way into the right
mailbox on that machine.

Now let's consider what would happen if you tried instead to send a mail
to the debian user mailing list from your PC (but the same would apply
to your server). You can't do this using mo@pc.local, because A) your
ISP most likely won't let you and B) most recipient domains will reject
that. Instead you have to use a "real" email address, ie one provided by
your ISP or something like a gmail account or similar. You'll have to
have configured exim4 in smarthost mode and you will have to have
configured exim4 to know what your outgoing mail server name is. For
example, for the specific case of sending to this mailing list, I use
gmail for outgoing mail and their server name is smtp.gmail.com if I
recall correctly. You'll also have had to put your email user name and
password into a file called passwd.client in your /etc/exim4 config
directory. Since this contains your email password, make sure the file
is owned by root and not world readable!

Then, any address that isn't local to the machine, and also isn't in the
hubbed_hosts file, will be treated as external and exim4 will connect to
the smarthost (your email provider's server) and pass on the message to
be delivered by it.

Net result -- you send an email from PC to Server, it gets delivered
directly by a conversation between the two exim4 instances. You send a
mail anywhere else, it gets handed off to your real-world (not that the
inside of your home is not "real"!) email provider for delivery.

Very great and detailed explanation, thank you very much! :)

Now, a word on exim4 config. Be sure to read the *DEBIAN* wiki etc on
configuring exim4, as the DEBIAN config is a bit different to what you
will find upstream. Let me save you a bit of time.

First, there are two ways to configure exim4, using one big config file
which is found in /var/lib/exim4, or using a config directory containing
a bunch of small config files each handling one small piece of the
configuration. Opinions abound on which is better, I have no opinion. By
default, exim4 on Debian will use the single file approach. Second,
Debian constructs the config file by using a TEMPLATE to be found in
/etc/exim4, and a second configuration file called
update-exim4.conf.conf (yes, the conf file for updating the conf
file......) You put your specific config in the update-exim4.conf.conf
file, then when you are done you run update-exim4.conf as root
(update-exim4.conf is actually a program, not a conf file...
update-exim4.conf.conf is a conf file...) and restart exim4. The
update-exim4.conf program combines the template with the specific info
in update-exim4.conf.conf and writes the result to
/var/lib/exim4/config.autogenerated which is the config exim4 on Debian
uses. This can also be done by running dpkg-reconfigure exim4.conf as
Liam suggested, but I think there are more things you can do with
update-exim4.conf.conf than the questions dpkg-reconfigure will ask you,
so it wouldn't hurt to get familiar with what is going on under the hood
when you do dpkg-reconfigure, but that's just my opinion.

That sure is nice to know, i will have a look at the wiki page ;)
(This saves me quite a lot of time :D Thx!)

If you need more specific help on how to get your local exim4 talking to
an external email provider, or for that matter if you need me to clarify
anything about getting local machine to local machine email working,
post back here.

As far as i understood it i need to set up exim as a smarthost of i want to send mail of to other smtp servers, for example gmail. I guess i will try that out as a next step, so i can send myself mail to my gmail or gmx account.... Well, since you asked: Is it enough to run 'dpkg-reconfigure exim4-config" and use the smarthost option from the curses menu?

Also, being able to receive replies to externally sent mails back into
your machine locally, needs another bit of setup. If you need that, let
us know and I'll help with that part too (it is where fetchmail comes
in). But, there is nothing to stop you using whatever mail client you
use today to read your email as you presumably do now, and you'll see
the mails you sent locally there in your sent mail (depending on the
precise behaviour of your provider's mail server)

Hope that helped clarify things. Sorry for the length of this but
someone has finally asked for help with something I know something
about, and I'm keen to help! :)


Your explanations sure helped me a lot, i can see clearer now, thx for that and of course for the long mail ;) Thx! :)

Mark


Greets

mo

Reply via email to