LAN Mail Server
Jump to navigation
Jump to search
1 Introduction
1.1 Aim
Setting an Internet Message Access Protocol (IMAP) server for a Local Area Network (LAN)
- Mail server: cyber8, a ThinkPad X230 set up with CentOS 8.1
- Mail client: cyber7, another ThinkPad X230, set up with CentOS 7.8
- Mail software
- Dovecot: IMAP server and Mail Delivery Agent (MDA)
- Postfix: Mail Transfer Agent (MTA)
- Thunderbird: email client / Mail User Agent (MUA)
1.2 Context
All hosts connected to ISP-provided Modem/Router
- DHCP-configured LAN 192.168.0.0/24
- Router IPv4 address: 192.168.0.1
- cyber7 IP addresses (fixed by the Modem/Router)
- IPv4: 192.168.0.210
- IPv6: 2001:8003:22bc:1700:7787:2b17:cc6f:5b46
- cyber8 IP addresses (fixed by the Modem/Router)
- IPv4: 192.168.0.53
- IPv6: 2001:8003:22bc:1700:66be:1375:b866:a57b
- Domain Name System (cf. the DNS page for the setup)
- Server: cyber8
- Domain Name: rshome.lan
- Host fully qualified names
- cyber7.rshome.lan
- cyber8.rshome.lan
2 Setup
2.1 Firewall
Open all machines' firewalls (server and clients) as follows
- Simple Mail Transfer Protocol (SMTP) and Secure variant
- firewall-cmd --permanent --add-service smtp --add-service smtps
- firewall-cmd --permanent --add-port=25/tcp --add-port=465/tcp --add-port=587/tcp
- Internet Message Access Protocol (IMAP) and Secure variant
- firewall-cmd --permanent --add-service imap --add-service imaps
- firewall-cmd --permanent --add-port=143/tcp --add-port=993/tcp
- Post Office Protocol (POP3) and Secure variant
- firewall-cmd --permanent --add-service pop3 --add-service pop3s
- firewall-cmd --permanent --add-port=110/tcp --add-port=995/tcp
- firewall-cmd --reload
2.2 cyber8 Mail Server
2.2.1 RPMs
- dnf install dovecot postfix
2.2.2 Dovecot
- Edit /etc/pki/dovecot/dovecot-openssl.cnf and update as follows
- C=AU
- ST=NSW
- L=Sydney
- CN=cyber8.rshome.lan
- (Note: the CN line indicating the mail server host is crucial for the mail system to work)
- emailAddress=root@rshome.lan
- Run /usr/libexec/dovecot/mkcert.sh to generate the SSL certificate from above values
- Edit /etc/dovecot/dovecot.conf and update as follows
- protocols = imap pop3 lmtp
- (do not try serving the protocol "submission" as its implementation in dovecot-2.3.8 is buggy and breaks the processing of other protocols)
- listen = *, ::
- Edit /etc/dovecot/conf.d/10-mail.conf and update as follows
- mail_location = mbox:~/mail:INBOX=/var/mail/%u
- mail_access_groups = mail
- first_valid_uid = ...
- (In case some users identifiers (uid) are below the default (1000))
- systemctl restart dovecot
- systemctl enable dovecot
2.2.3 Postfix
- Edit /etc/postfix/main.cf and update as follows
- myhostname = cyber8.rshome.lan
- mydomain = rshome.lan
- myorigin = $mydomain
- inet_interfaces = all
- mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
- mynetworks = 192.168.0.0/16, 127.0.0.0/8, [2001:8003:22bc:1700::]/64, [::1]/128
- mail_spool_directory = /var/spool/mail
- Append the following to /etc/aliases
- root: roger
- (emails sent to root redirected to Linux username roger)
- roger.seguin: roger
- (Declare roger.seguin@... as an alias to roger@...)
- Run the command newaliases to update the alias database
- systemctl restart postfix
- systemctl enable postfix
2.2.4 DNS
- Add the instruction
- IN MX 0 cyber8.rshome.lan.
to the DNS Zone File /var/named/named.rshome.lan |
IN NS cyber8 cyber8 IN A 192.168.0.53 cyber8 IN AAAA 2001:8003:22bc:1700:66be:1375:b866:a57b cyber7 IN A 192.168.0.210 cyber7 IN AAAA 2001:8003:22bc:1700:7787:2b17:cc6f:5b46 IN MX 0 cyber8.rshome.lan. |
2.3 cyber7 Mail Client
2.3.1 RPMs
- yum install thunderbird postfix
2.3.2 Email account
Launch Thunderbird
- Select Edit from the top bar, then Account Settings"
- The "Account Settings" windows pops up
- Select Account Actions, then "Add Mail Account..."
- The "Set Up an Existing Email Account" window pops up
- Your name: Roger
- Email address: roger.seguin@rshome.lan
- Password: ...
- (cyber8 login password)
- Check Remember password
- Press [Continue]
- A new "Set Up an Existing Email Account" window pops up
- Change the incoming IMAP server to cyber8.rshome.lan
- Change the outgoing SMTP server to cyber8.rshome.lan
- Press [Re-test]
- The window should now display
- The following settings were found by probing the given server
- with all details updated accordingly
- Press [Done]