12 - Correo electrónico: Postfix

  1. Instalar servidor DNS

name: "smr"

services:
   bind9:
      image: smr/bind9
      container_name: bind9
      ports:
         - "53:53/udp"
         - "53:53/tcp"
      volumes:
         - ./bind9/config:/etc/bind
      networks:
         smr-net:
            ipv4_address: "192.168.100.2"
networks:
   smr-net:
      driver: bridge
      ipam:
         config:
            - subnet: "192.168.100.0/24"

  1. Configurar DNS (Configuramos también la zona inversa)

include "/etc/bind/named.conf.options";
include "/etc/bind/named.conf.local";
options {
   directory "/var/cache/bind";
   
   recursion yes;
   allow-recursion { any; };
   
   listen-on { any; };
   listen-on-v6 { any; };
};
zone "smr.local" {
   type master;
   file "/etc/bind/zones/db.smr.local";
};

zone "100.168.192.in-addr.arpa" {
   type master;
   file "/etc/bind/zones/db.192.168.100";
};

$TTL    604800
@   IN  SOA ns.smr.local. admin.smr.local. (
                2024010101 ; Serial
                604800     ; Refresh
                86400      ; Retry
                2419200    ; Expire
                604800 )   ; Negative Cache TTL
 
; Servidores de nombres
@   IN  NS  ns.smr.local. ; El punto final indica que el nombre de dominio es totalmente calificado o absoluto (FQDN, Fully Qualified Domain Name)
 
; Registros A
@   IN  A   192.168.100.2
ns  IN  A   192.168.100.2
www IN  A   192.168.100.2

$TTL    604800
@   IN  SOA ns.smr.local. admin.smr.local. (
                2024010101 ; Serial
                604800     ; Refresh
                86400      ; Retry
                2419200    ; Expire
                604800 )   ; Negative Cache TTL
 
; Servidores de nombres
@   IN  NS  ns.smr.local.
 
; Registros PTR
2   IN  PTR smr.local.

  1. Añadir servidor postfix

name: "smr"

services:
   bind9:
      image: smr/bind9
      container_name: bind9
      ports:
         - "53:53/udp"
         - "53:53/tcp"
      volumes:
         - ./bind9/config:/etc/bind
      networks:
         smr-net:
            ipv4_address: "192.168.100.2"
            
   postfix:
      image: smr/postfix
      container_name: postfix
      environment:
        - HOSTNAME=postfix.smr.local
        - RELAYHOST=mail.smr.local
        - MYNETWORKS=192.168.100.0/24
        - ALLOWED_SENDER_DOMAINS=smr.local
        - MASQUERADED_DOMAINS=smr.local
      volumes:
        - ./postfix/config:/etc/postfix
      ports:
        - "25:25"  # Puerto SMTP para recibir correos
      networks:
        smr-net:
          ipv4_address: "192.168.100.3"
          
networks:
   smr-net:
      driver: bridge
      ipam:
         config:
            - subnet: "192.168.100.0/24"

- Añadir el registro MX al servidor DNS (y su zona inversa)

$TTL    604800
@    IN  SOA ns.smr.local. admin.smr.local. (
                2024010101 ; Serial
                604800     ; Refresh
                86400      ; Retry
                2419200    ; Expire
                604800 )   ; Negative Cache TTL
 
; Servidores de nombres
@    IN  NS  ns.smr.local. ; El punto final indica que el nombre de dominio es totalmente calificado o absoluto (FQDN, Fully Qualified Domain Name)
 
; Registros A
@    IN  A   192.168.100.2
ns   IN  A   192.168.100.2
www  IN  A   192.168.100.2
mail IN  A   192.168.100.3

; Registro MX
@    IN  MX 10  mail.smr.local.

$TTL    604800
@   IN  SOA ns.smr.local. admin.smr.local. (
                2024010101 ; Serial
                604800     ; Refresh
                86400      ; Retry
                2419200    ; Expire
                604800 )   ; Negative Cache TTL
 
; Servidores de nombres
@   IN  NS  ns.smr.local.
 
; Registros PTR
2   IN  PTR smr.local.
3   IN  PTR mail.smr.local.