Mail Server Debian 13

Dari Dokumentasi Robie
Loncat ke navigasi Loncat ke pencarian

TUTORIAL INSTALASI MAIL SERVER

Debian 13 di Proxmox CT

Komponen yang Dipelajari:

Apache2

BIND9

Postfix

Dovecot

Roundcube

Spesifikasi Lab:

HDD 8 GB | RAM 512 MB | Proxmox Container | IP: 192.168.111.103 (sesuai ip yang didapatkan)

TUJUAN PEMBELAJARAN

Setelah mengikuti tutorial ini, siswa mampu:

  1. Memahami arsitektur dasar mail server
  2. Menginstal dan mengkonfigurasi layanan DNS, SMTP, IMAP, dan Webmail
  3. Menguji koneksi email menggunakan Telnet
  4. Melakukan troubleshooting dasar jika terjadi error

PERSIAPAN AWAL

Spesifikasi Server

Komponen Spesifikasi Minimum
Proxmox VE Versi 8.x (Container Mode)
OS Guest Debian 13 (Trixie) 64-bit
Storage 8 GB HDD
RAM 512 MB + Swap 512 MB
IP Address 192.168.111.103/24
Domain belajar.local
Hostname mailserver.belajar.local

Langkah 1: Buat Container di Proxmox

  1. Buka Proxmox Web UI: https://IP-PROXMOX:8006
  2. Download template Debian 13: Datacenter β†’ Node β†’ local β†’ CT Templates
  3. Klik Create CT dan isi:
Parameter Nilai Contoh
CT ID 101 (sesuai dengan CT yang sudah ada)
Hostname mailserver
Template debian-13-standard
Disk 8 GB
CPU 1 core
RAM 512 MB
Swap 512 MB (wajib!)
Network IP Static: 192.168.111.103/24 (sesuai IP yang didapatkan masing-masing

Langkah 2: Masuk ke Container & Update Sistem

# Masuk ke console container
apt update && apt upgrade -y

# Install paket dasar
apt install -y curl wget nano net-tools dnsutils ufw rsyslog

Langkah 3: Set Hostname & Swap

# Set hostname
hostnamectl set-hostname mailserver

# Edit file hosts
nano /etc/hosts

Isi file /etc/hosts:

127.0.0.1       localhost
192.168.111.103   mailserver.belajar.local   mailserver
001-etc-hosts.jpg

πŸ”§ BAGIAN 1: INSTALASI DNS SERVER (BIND9)

Langkah 1: Install BIND9

apt install -y bind9 bind9utils dnsutils

Langkah 2: Konfigurasi named.conf.options

nano /etc/bind/named.conf.options

Isi dengan:

options {
    directory "/var/cache/bind";
    forwarders { 8.8.8.8; 8.8.4.4; };
    dnssec-validation auto;
    listen-on { any; };
    allow-query { any; };
    recursion yes;
};
002-etc-bind-named-conf-options.jpg

Langkah 3: Konfigurasi Zone Domain

nano /etc/bind/named.conf.local

Tambahkan:

zone "belajar.local" {
    type master;
    file "/etc/bind/db.belajar.local";
};
zone "111.168.192.in-addr.arpa" {
    type master;
    file "/etc/bind/db.192.168.111";
};
003-etc-bind-named-conf-local.jpg

Langkah 4: Buat File Zone Forward

nano /etc/bind/db.belajar.local

Isi file:

$TTL    604800
@   IN  SOA mailserver.belajar.local. root.belajar.local. (
                2024010101 ; Serial
                604800 ; Refresh
                86400  ; Retry
                2419200 ; Expire
                604800 ) ; Negative Cache TTL
;
@       IN  NS  mailserver.belajar.local.
@       IN  A   192.168.111.103
@       IN  MX 10 mailserver.belajar.local.
mailserver IN A 192.168.111.103
mail       IN A 192.168.111.103
www        IN A 192.168.111.103
004-etc-bind-db-belajar-local.jpg

Langkah 5: Buat File Zone Reverse

nano /etc/bind/db.192.168.111

Isi file:

$TTL    604800
@   IN  SOA mailserver.belajar.local. root.belajar.local. (
                2024010101 ; Serial
                604800 ; Refresh
                86400  ; Retry
                2419200 ; Expire
                604800 ) ; Negative Cache TTL
;
@   IN  NS  mailserver.belajar.local.
103 IN  PTR mailserver.belajar.local.
005-etc-bind-db-192168111.jpg

Langkah 6: Set DNS Lokal & Restart

# Set DNS ke server sendiri
nano /etc/resolv.conf

Isi:

nameserver 192.168.111.103
search belajar.local
006-etc-resolv-conf.jpg
# Cek konfigurasi
named-checkconf
named-checkzone belajar.local /etc/bind/db.belajar.local

# Restart BIND9
systemctl restart bind9
systemctl enable bind9

# Tes DNS
nslookup mailserver.belajar.local
dig MX belajar.local
007-cek-konfigurasi-named-checkzone-belajar-local.jpg
008-nslookup-maiserver-belajar-local.jpg
009-dig-mx-belajar-local.jpg

BAGIAN 2: INSTALASI WEB SERVER & DATABASE

Langkah 1: Install Apache2

apt install -y apache2
systemctl start apache2
systemctl enable apache2

Langkah 2: Install PHP dan Modul

apt install -y php php-cli php-common php-curl php-gd php-intl \
    php-json php-mbstring php-mysql php-xml php-zip libapache2-mod-php

Cek PHP sudah terinstall:

php -v

Langkah 3: Install MariaDB

apt install -y mariadb-server mariadb-client
systemctl start mariadb
systemctl enable mariadb

Langkah 4: Buat Database untuk Roundcube

mysql -u root -p (enter)

biarkan Password tetap kosong, langsung tekan Enter saja.

Masukkan perintah SQL:

CREATE DATABASE roundcubemail CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'roundcube'@'localhost' IDENTIFIED BY 'password123';
GRANT ALL PRIVILEGES ON roundcubemail.* TO 'roundcube'@'localhost';
FLUSH PRIVILEGES;
EXIT;

Langkah 5: Aktifkan Modul Apache

a2enmod rewrite ssl headers
systemctl restart apache2

BAGIAN 3: INSTALASI SMTP SERVER (POSTFIX)

Langkah 1: Install Postfix

apt install -y postfix mailutils

Saat muncul dialog:

  1. Pilih: Internet Site
  2. System mail name: belajar.local

Langkah 2: Konfigurasi main.cf

nano /etc/postfix/main.cf

Tambahkan/ubah konfigurasi berikut:

# Identitas server
myhostname = mailserver.belajar.local
mydomain = belajar.local
myorigin = $mydomain

# Jaringan
inet_interfaces = all
inet_protocols = ipv4
mydestination = $myhostname, localhost.$mydomain, $mydomain, localhost
mynetworks = 127.0.0.0/8 192.168.111.0/24

# Format mailbox
home_mailbox = Maildir/

# Autentikasi via Dovecot
smtpd_sasl_type = dovecot
smtpd_sasl_path = private/auth
smtpd_sasl_auth_enable = yes
smtpd_sasl_security_options = noanonymous

# Keamanan relay
smtpd_recipient_restrictions =
    permit_sasl_authenticated,
    permit_mynetworks,
    reject_unauth_destination

# Optimasi untuk RAM rendah
default_process_limit = 10
smtpd_client_connection_rate_limit = 30
010-nano-etc-postfix-main-cf.jpg

Langkah 3: Aktifkan Port Submission

nano /etc/postfix/master.cf

Cari baris submission dan hapus tanda #:

submission inet n       -       y       -       -       smtpd
  -o syslog_name=postfix/submission
  -o smtpd_tls_security_level=encrypt
  -o smtpd_sasl_auth_enable=yes
  -o smtpd_recipient_restrictions=permit_sasl_authenticated,reject
011-nano-etc-postfix-master-cf.jpg

Langkah 4: Restart Postfix

systemctl restart postfix
systemctl enable postfix

# Cek port sudah terbuka
ss -tlnp | grep -E ':25|:587'
012-restart-postfix.jpg

BAGIAN 4: INSTALASI IMAP SERVER (DOVECOT)

Langkah 1: Install Dovecot

apt install -y dovecot-core dovecot-imapd dovecot-pop3d

Langkah 2: Konfigurasi Protokol

nano /etc/dovecot/dovecot.conf

Ubah baris:

protocols = imap pop3
013-nano-etc-dovecot-conf.jpg

Langkah 3: Konfigurasi Format Mail

nano /etc/dovecot/conf.d/10-mail.conf

Cari dan ubah:

mail_path = maildir:~/Maildir
014-etc-dovecot-conf-d-10-mail-conf.jpg

Langkah 4: Konfigurasi Autentikasi

nano /etc/dovecot/conf.d/10-auth.conf

Pastikan baris ini aktif (tanpa tanda #):

!include auth-system.conf.ext
015-etc-dovecot-conf-d-10-auth-conf.jpg

Langkah 5: Konfigurasi Socket untuk Postfix

nano /etc/dovecot/conf.d/10-master.conf

Cari bagian service auth dan pastikan seperti ini:

service auth {
  unix_listener /var/spool/postfix/private/auth {
    mode = 0660
    user = postfix
    group = postfix
  }

  unix_listener auth-userdb {
  mode = 0660
  user = dovecot
  }
}
016-nano-etc-dovecot-conf-d-10-master-conf.jpg

Langkah 6: Restart Dovecot

# Restart Dovecot dulu
systemctl restart dovecot
systemctl enable dovecot

# Lalu restart Postfix
systemctl restart postfix

# Cek port
ss -tlnp | grep -E ':110|:143'
017-restart-dovecot-6.jpg

BAGIAN 5: MEMBUAT AKUN EMAIL

Buat User Email

# Buat user1
adduser --shell /sbin/nologin user1
# Masukkan password saat diminta

# Buat user2
adduser --shell /sbin/nologin user2

# Buat folder Maildir
mkdir -p /home/user1/Maildir/{new,cur,tmp}
chown -R user1:user1 /home/user1/Maildir

mkdir -p /home/user2/Maildir/{new,cur,tmp}
chown -R user2:user2 /home/user2/Maildir

πŸ’‘ Info:

πŸ§ͺ BAGIAN 6: PENGUJIAN DENGAN TELNET

Langkah 1: Install Telnet

apt install -y telnet

Langkah 2: Tes Kirim Email via SMTP

telnet 192.168.111.103 25

Jika berhasil, akan muncul:

220 mailserver.belajar.local ESMTP Postfix

Ketik perintah berikut satu per satu:

EHLO belajar.local
MAIL FROM:<[email protected]>
RCPT TO:<[email protected]>
DATA

Kemudian ketik isi email:

From: [email protected]
To: [email protected]
Subject: Hallo dari user1

Halo user2, ini email percobaan kita!
Semoga berhasil ya!
.

⚠️ Penting: Titik (.) di baris terakhir harus sendiri, tanpa spasi!

Lanjutkan:

QUIT

Langkah 3: Cek Email Masuk

ls /home/user2/Maildir/new/

Jika muncul file, email berhasil diterima!

# Lihat isi email
cat /home/user2/Maildir/new/*

Langkah 4: Tes IMAP

telnet 192.168.111.103 143

Harus muncul: * OK Dovecot ready

a LOGIN user2 passworduser2
b SELECT INBOX
d LOGOUT

🌍 BAGIAN 7: INSTALASI WEBMAIL (ROUNDCUBE)

Langkah 1: Download Roundcube

cd /var/www/html
wget https://github.com/roundcube/roundcubemail/releases/download/1.6.6/roundcubemail-1.6.6-complete.tar.gz
tar xzf roundcubemail-1.6.6-complete.tar.gz
mv roundcubemail-1.6.6 roundcube
rm roundcubemail-1.6.6-complete.tar.gz

Langkah 2: Set Permission

chown -R www-data:www-data /var/www/html/roundcube
chmod -R 755 /var/www/html/roundcube
chmod -R 777 /var/www/html/roundcube/temp
chmod -R 777 /var/www/html/roundcube/logs

Langkah 3: Konfigurasi Apache

nano /etc/apache2/sites-available/roundcube.conf

Isi:

<VirtualHost *:80>
    ServerName mail.belajar.local
    DocumentRoot /var/www/html/roundcube
    <Directory /var/www/html/roundcube>
        Options -Indexes +FollowSymLinks
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>

Aktifkan site:

a2ensite roundcube.conf
a2dissite 000-default.conf
systemctl reload apache2

Langkah 4: Import Database Roundcube

mysql -u roundcube -p roundcubemail < /var/www/html/roundcube/SQL/mysql.initial.sql

Langkah 5: Setup via Browser

  1. Buka browser: http://192.168.111.103/roundcube/installer
  2. Ikuti wizard setup
  3. Konfigurasi database:
    1. Server: localhost
    2. Database: roundcubemail
    3. User: roundcube
    4. Password: password123 (sesuai yang dibuat tadi)
  4. Konfigurasi IMAP: localhost, port 143
  5. Konfigurasi SMTP: localhost, port 25
  6. Klik Create config β†’ Initialize database

Langkah 6: Hapus Folder Installer

rm -rf /var/www/html/roundcube/installer

Langkah 7: Akses Webmail

Buka browser: http://192.168.111.103/roundcube Login dengan:

  • Username: user1 atau user2
  • Password: (sesuai password user Linux)

πŸ” TROUBLESHOOTING DASAR

Mail Server Tidak Bisa Dikirim

# Cek log Postfix
journalctl -u postfix --no-pager | tail -20

# Cek antrian email
mailq

# Flush antrian
postqueue -f

Dovecot Tidak Bisa Login

# Cek log Dovecot
journalctl -u dovecot --no-pager | tail -20

# Cek konfigurasi
doveconf -n | head -20

DNS Tidak Resolve

# Cek konfigurasi BIND
named-checkconf
named-checkzone belajar.local /etc/bind/db.belajar.local

# Restart BIND
systemctl restart bind9

Perintah Berguna untuk Siswa

# Cek status semua layanan
systemctl status bind9 apache2 mariadb postfix dovecot

# Restart semua layanan
systemctl restart bind9 apache2 mariadb postfix dovecot

# Monitor log realtime
journalctl -f

# Tambah user email baru
adduser --shell /sbin/nologin namauser
mkdir -p /home/namauser/Maildir/{new,cur,tmp}
chown -R namauser:namauser /home/namauser/Maildir

πŸ“‹ CHECKLIST AKHIR

No Pengujian Perintah Hasil OK
1 DNS aktif systemctl is-active bind9 active
2 MX record dig MX belajar.local mailserver.belajar.local
3 Apache aktif systemctl is-active apache2 active
4 Database aktif systemctl is-active mariadb active
5 Postfix aktif systemctl is-active postfix active
6 Port 25 terbuka grep :25 LISTEN
7 Dovecot aktif systemctl is-active dovecot active
8 Port 143 terbuka grep :143 LISTEN
9 Kirim email Telnet telnet localhost 25 220 banner muncul
10 Email masuk ls /home/user2/Maildir/new/ ada file
11 Webmail bisa diakses Browser ke /roundcube halaman login muncul

πŸŽ“ TUGAS PRAKTIKUM

  1. βœ… Instal mail server sesuai tutorial ini
  2. βœ… Buat 3 akun email: siswa1, siswa2, guru
  3. βœ… Kirim email dari siswa1 ke siswa2 via Telnet
  4. βœ… Verifikasi email masuk ke Maildir siswa2
  5. βœ… Login ke webmail Roundcube dengan akun guru
  6. βœ… Kirim email via webmail dari guru ke siswa1
  7. βœ… Dokumentasikan setiap langkah dengan screenshot
  8. βœ… Buat laporan praktikum dalam format PDF

πŸ“š REFERENSI