01Network - amagerard/Mail GitHub Wiki

HOME

Redhat/Mail

1- Network 2- Postfix 3- Dovecot 4- Postfixadmin 5- PostfixMariaDB 6- DovecotMariaDB
7- RelaySmtp 8- Troubleshoot 9- Selinux 10- GnomeShell 11- Backup

1. Network.

1.1 Prerequisites.

The mail server is a TemplateVM clone. See installation TemplateVM.
You need a dns server. See dns installation.
This tutorial is with Gnome shell already installed.

January 29 ,2025.  
This is  the RedHat version 9.5  
MariaDB-server-11.6.2  
php 8.4  
postfixadmin  3.3.15
dovecot 2.3.16-14  
postfix 3.5.25-1  
It's not apache but nginx  

The status of selinux is permissive.
vi /etc/crontab

@reboot root setenforce 0  

The 2 subnets were created by pfsense.
DNS:   192.168.90.0/24
SRV:   192.168.60.0/24
If you are an apprentice, you can put all the servers in the same subnet.

This procedure is based on this example.
DNS Server IP : 192.168.90.41
DNS Server Name: dns1.ol26modk.com
Domain : ol26modk.com
Mail Server IP : 192.168.60.41
Mail Server Name: hermes.ol26modk.com

smtp.ol26modk.com CNAME hermes.ol26modk.com
imap.ol26modk.com CNAME hermes.ol26modk.com
mail.ol26modk.com CNAME hermes.ol26modk.com
ol26modk.com MX hermes.ol26modk.com

An external email account for the relay.
Mail adress: [email protected].
Account: [email protected].
Provider: googl.com.
SMTP Provider:smtp.googl.com.

Uninstall rmstp (if installed).
dnf remove msmtp

1.2 Network configuration.

Mail server ip: 192.168.60.41
Gateway: 192.168.60.254
Domain: ol26modk.com
Nom serveur: hermes.ol26modk.com

vi /etc/hostname

hermes  

At the prompt you will have: <username>@hermes

This file is consulted before Internet access.
vi /etc/hosts

127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4  
192.168.60.41  hermes.ol26modk.com   mail.ol26modk.com hermes  

vi /etc/sysconfig/network

 # Created by anaconda  
# # Created by anaconda  
 networking=yes  
 HOSTNAME=hermes.ol26modk.com  

Change Network.
Example:
IP: 192.168.60.41/24
Gateway: 192.168.60.254
Name Server: 192.168.90.41
Search domain: ol26modk.com
nmcli con mod eth0 ipv4.method "manual" ipv4.addresses 192.168.60.41/24
nmcli con mod eth0 ipv4.gateway 192.168.60.254
nmcli con mod eth0 ipv4.dns 192.168.90.41
nmcli con mod eth0 ipv4.dns-search ol26modk.com

Read the new network configuration.
more /etc/NetworkManager/system-connections/eth0.nmconnection

Apply the new network configuration.

ifconfig eth0 0.0.0.0
systemctl restart NetworkManager
ifconfig eth0

Update :
RedHat may ask you to make a new subscription.
subscription-manager register --username <username> --password <password> --auto-attach --force

dnf update

1.3 Firewall.

Take over the rules of the TemplateVM firewall.
See Firewall configuration
Add rules.

ufw allow 'SMTP TLS'  
ufw allow 'SMTP SSL'  
ufw allow 'IMAP TLS'  
ufw allow 'IMAP SSL'  
ufw allow 'WWW Full'  
Maybe already done.  
ufw allow OUT 'SMTP TLS'  
ufw allow OUT 'SMTP SSL'  
ufw allow OUT 'IMAP TLS'  
ufw allow OUT 'IMAP SSL'  
ufw allow OUT 'WWW Full'  

ufw status verbose

 Status: active  
Logging: on (medium)  
Default: deny (incoming), deny (outgoing), disabled (routed)  
New profiles: skip  
  
To                         Action      From  
--                         ------      ----  
22                         ALLOW IN    192.168.14.0/29  
80,443/tcp (WWW Full)      ALLOW IN    Anywhere  
587/tcp (SMTP TLS)         ALLOW IN    Anywhere  
465/tcp (SMTP SSL)         ALLOW IN    Anywher   
993/tcp (IMAP SSL)         ALLOW IN    Anywher   
143/tcp (IMAP TLS)         ALLOW IN    Anywher   
  
123/udp (NTP2)             ALLOW OUT   Anywhere  
587/tcp (SMTP TLS)         ALLOW OUT   Anywhere  
465/tcp (SMTP SSL)         ALLOW OUT   Anywhere  
143/tcp (IMAP TLS)         ALLOW OUT   Anywhere  
993/tcp (IMAP SSL)         ALLOW OUT   Anywhere  
53 (DNS)                   ALLOW OUT   Anywhere  
80,443/tcp (WWW Full)      ALLOW OUT   Anywhere  
25/tcp (SMTP)              ALLOW OUT   Anywhere  

Restart mail server.
reboot or init6

⚠️ **GitHub.com Fallback** ⚠️