Mail Server Debian 13: Perbedaan antara revisi

Dari Dokumentasi Robie
Loncat ke navigasi Loncat ke pencarian
(←Membuat halaman berisi '= PANDUAN LENGKAP INSTALASI MAIL SERVER = '''Debian 13 di Proxmox CT''' ''Edisi Revisi v2.0 — Diperbarui berdasarkan hasil implementasi nyata'' '''Stack:''' Apache2 • BIND9 • Postfix • Dovecot 2.4 • Roundcube • Telnet '''Spesifikasi:''' HDD 8 GB | RAM 512 MB | Proxmox Container (CT) | IP: 192.168.111.103 == BAB 1 — PENDAHULUAN & GAMBARAN UMUM == === 1.1 Tujuan Panduan === Panduan ini menjelaskan langkah-langkah lengkap untuk membangun Mail Server...')
 
 
(10 revisi perantara oleh pengguna yang sama tidak ditampilkan)
Baris 1: Baris 1:
= PANDUAN LENGKAP INSTALASI MAIL SERVER =
= TUTORIAL INSTALASI MAIL SERVER =
'''Debian 13 di Proxmox CT'''
'''Debian 13 di Proxmox CT'''  
''Edisi Revisi v2.0 — Diperbarui berdasarkan hasil implementasi nyata''


'''Stack:''' Apache2 • BIND9 • Postfix • Dovecot 2.4 • Roundcube • Telnet
'''Komponen yang Dipelajari:'''  
'''Spesifikasi:''' HDD 8 GB | RAM 512 MB | Proxmox Container (CT) | IP: 192.168.111.103


== BAB 1 — PENDAHULUAN & GAMBARAN UMUM ==
Apache2
=== 1.1 Tujuan Panduan ===
Panduan ini menjelaskan langkah-langkah lengkap untuk membangun Mail Server di atas Proxmox Container (CT) menggunakan Debian 13. Konfigurasi dirancang sesuai dengan keterbatasan sumber daya (HDD 8 GB, RAM 512 MB) dan telah diverifikasi melalui implementasi nyata.


'''✅ KOREKSI v2:''' Panduan ini adalah revisi v2 yang memperbaiki beberapa konfigurasi dari versi sebelumnya, khususnya untuk Dovecot 2.4, konfigurasi socket auth Postfix-Dovecot, sistem logging di Debian 13, dan format pengujian Telnet.
BIND9


=== 1.2 Arsitektur Layanan ===
Postfix
Urutan instalasi wajib diikuti karena setiap layanan menjadi prasyarat bagi layanan berikutnya:
 
{| class="wikitable"
Dovecot
! Urutan !! Layanan !! Aplikasi !! Fungsi
 
|-
Roundcube
| 1 || DNS Server || BIND9 || Resolusi domain, MX record, PTR record
 
|-
'''Spesifikasi Lab:'''
| 2 || Web Server || Apache2 + PHP || Hosting webmail Roundcube
 
|-
HDD 8 GB | RAM 512 MB | Proxmox Container | IP: 192.168.111.103 (sesuai ip yang didapatkan)
| 3 || Database || MariaDB || Penyimpanan data Roundcube
 
|-
== TUJUAN PEMBELAJARAN ==
| 4 || SMTP Server || Postfix 3.10 || Kirim & terima email (port 25/587)
Setelah mengikuti tutorial ini, siswa mampu:
|-
# Memahami arsitektur dasar mail server
| 5 || IMAP/POP3 || Dovecot 2.4 || Pengambilan email oleh klien (port 143/110)
# Menginstal dan mengkonfigurasi layanan DNS, SMTP, IMAP, dan Webmail
|-
# Menguji koneksi email menggunakan Telnet
| 6 || Webmail || Roundcube || Antarmuka web baca/kirim email
# Melakukan troubleshooting dasar jika terjadi error
|-
| 7 || Testing || Telnet || Pengujian koneksi SMTP/IMAP manual
|}


=== 1.3 Spesifikasi Lingkungan ===
== PERSIAPAN AWAL ==
{| class="wikitable"
=== Spesifikasi Server ===
! Platform !! Proxmox VE (Container / CT mode)
{| class="wikitable" style="width:100%"
|-
! Komponen !! Spesifikasi Minimum
! OS Guest !! Debian 13 (Trixie) 64-bit
|-
|-
! Storage !! 8 GB HDD
| Proxmox VE || Versi 8.x (Container Mode)
|-
|-
! RAM !! 512 MB + Swap 512 MB (wajib diaktifkan)
| OS Guest || Debian 13 (Trixie) 64-bit
|-
|-
! IP Address !! 192.168.111.103 (sesuaikan dengan jaringan Anda)
| Storage || 8 GB HDD
|-
|-
! Domain !! belajar.local
| RAM || 512 MB + Swap 512 MB
|-
|-
! Hostname !! mailserver.belajar.local
| IP Address || 192.168.111.103/24
|-
|-
! Postfix !! 3.10.5
| Domain || belajar.local
|-
|-
! Dovecot !! 2.4.1 (syntax berbeda dari versi lama!)
| Hostname || mailserver.belajar.local
|-
! Akses !! Root shell via Proxmox Console atau SSH
|}
|}


'''📌 CATATAN:''' Semua perintah dijalankan sebagai root. Dovecot 2.4 di Debian 13 menggunakan syntax konfigurasi baru yang berbeda dari tutorial lama berbasis Dovecot 2.2/2.3.
=== Langkah 1: Buat Container di Proxmox ===
 
# Buka Proxmox Web UI: <code>https://IP-PROXMOX:8006</code>
== BAB 2 — PERSIAPAN PROXMOX CONTAINER (CT) ==
# Download template Debian 13: <code>Datacenter → Node → local → CT Templates</code>
=== 2.1 Membuat Container Debian 13 di Proxmox ===
# Klik '''Create CT''' dan isi:
# Login ke Proxmox Web UI (https://IP-PROXMOX:8006)
# Download template: <code>Datacenter → Node → local → CT Templates</code> → cari <code>debian-13</code>
# Klik <code>Create CT</code> dan isi konfigurasi:
{| class="wikitable"
{| class="wikitable"
! Parameter !! Nilai
! Parameter !! Nilai Contoh
|-
! CT ID !! 101 (atau nomor bebas)
|-
|-
! Hostname !! mailserver
| CT ID || 101 (sesuai dengan CT yang sudah ada)
|-
|-
! Template !! debian-13-standard_*.tar.zst
| Hostname || mailserver
|-
|-
! Disk !! 8 GB
| Template || debian-13-standard
|-
|-
! CPU !! 1 core
| Disk || 8 GB
|-
|-
! RAM !! 512 MB
| CPU || 1 core
|-
|-
! Swap !! 512 MB (wajib)
| RAM || 512 MB
|-
|-
! Network !! eth0 → vmbr0, IP static 192.168.111.103/24
| Swap || 512 MB (wajib!)
|-
|-
! DNS !! 8.8.8.8 (sementara, akan diganti ke lokal)
| Network || IP Static: 192.168.111.103/24 (sesuai IP yang didapatkan masing-masing
|}
|}


=== 2.2 Konfigurasi Awal Sistem ===
=== Langkah 2: Masuk ke Container & Update Sistem ===
==== 2.2.1 Update & Paket Dasar ====
<pre>
<pre>
# Masuk ke console container
apt update && apt upgrade -y
apt update && apt upgrade -y
apt install -y curl wget git nano net-tools dnsutils ufw rsyslog
 
# Install paket dasar
apt install -y curl wget nano net-tools dnsutils ufw rsyslog
</pre>
</pre>
'''✅ KOREKSI v2:''' rsyslog wajib diinstall di awal. Debian 13 secara default hanya menggunakan systemd journald sehingga <code>/var/log/mail.log</code> tidak terbuat otomatis tanpa rsyslog.


==== 2.2.2 Set Hostname ====
=== Langkah 3: Set Hostname & Swap ===
<pre>
<pre>
# Set hostname
hostnamectl set-hostname mailserver
hostnamectl set-hostname mailserver
# Edit file hosts
nano /etc/hosts
nano /etc/hosts
</pre>
</pre>
Baris 102: Baris 91:
192.168.111.103  mailserver.belajar.local  mailserver
192.168.111.103  mailserver.belajar.local  mailserver
</pre>
</pre>
[[Berkas:001-etc-hosts.jpg|pus|jmpl|582x582px]]


==== 2.2.3 Aktifkan Swap ====
== 🔧 BAGIAN 1: INSTALASI DNS SERVER (BIND9) ==
<pre>
=== Langkah 1: Install BIND9 ===
fallocate -l 512M /swapfile
chmod 600 /swapfile
mkswap /swapfile
swapon /swapfile
echo "/swapfile none swap sw 0 0" >> /etc/fstab
free -h  # verifikasi swap aktif
</pre>
 
=== 2.3 Konfigurasi Firewall ===
<pre>
ufw allow 22/tcp
ufw allow 25/tcp
ufw allow 53
ufw allow 80/tcp
ufw allow 110/tcp
ufw allow 143/tcp
ufw allow 443/tcp
ufw allow 587/tcp
ufw allow 993/tcp
ufw allow 995/tcp
ufw enable
ufw status
</pre>
 
== BAB 3 — INSTALASI DNS SERVER (BIND9) ==
=== 3.1 Instalasi BIND9 ===
<pre>
<pre>
apt install -y bind9 bind9utils bind9-doc dnsutils
apt install -y bind9 bind9utils dnsutils
named -v
systemctl status bind9
</pre>
</pre>


=== 3.2 Konfigurasi named.conf.options ===
=== Langkah 2: Konfigurasi named.conf.options ===
<pre>
<pre>
nano /etc/bind/named.conf.options
nano /etc/bind/named.conf.options
</pre>
</pre>
Isi file:
Isi dengan:
<pre>
<pre>
options {
options {
Baris 152: Baris 114:
};
};
</pre>
</pre>
[[Berkas:002-etc-bind-named-conf-options.jpg|pus|jmpl|638x638px]]


=== 3.3 Konfigurasi Zone — named.conf.local ===
=== Langkah 3: Konfigurasi Zone Domain ===
<pre>
<pre>
nano /etc/bind/named.conf.local
nano /etc/bind/named.conf.local
</pre>
</pre>
Isi file:
Tambahkan:
<pre>
<pre>
zone "belajar.local" {
zone "belajar.local" {
Baris 168: Baris 131:
};
};
</pre>
</pre>
[[Berkas:003-etc-bind-named-conf-local.jpg|pus|jmpl|635x635px]]


=== 3.4 File Zone Forward ===
=== Langkah 4: Buat File Zone Forward ===
<pre>
<pre>
cp /etc/bind/db.local /etc/bind/db.belajar.local
nano /etc/bind/db.belajar.local
nano /etc/bind/db.belajar.local
</pre>
</pre>
Baris 191: Baris 154:
www        IN A 192.168.111.103
www        IN A 192.168.111.103
</pre>
</pre>
[[Berkas:004-etc-bind-db-belajar-local.jpg|pus|jmpl|583x583px]]


=== 3.5 File Zone Reverse ===
=== Langkah 5: Buat File Zone Reverse ===
<pre>
<pre>
cp /etc/bind/db.127 /etc/bind/db.192.168.111
nano /etc/bind/db.192.168.111
nano /etc/bind/db.192.168.111
</pre>
</pre>
Baris 210: Baris 173:
103 IN  PTR mailserver.belajar.local.
103 IN  PTR mailserver.belajar.local.
</pre>
</pre>
[[Berkas:005-etc-bind-db-192168111.jpg|pus|jmpl|677x677px]]


=== 3.6 Set DNS ke Lokal & Verifikasi ===
=== Langkah 6: Set DNS Lokal & Restart ===
<pre>
<pre>
# Set DNS ke server sendiri
nano /etc/resolv.conf
nano /etc/resolv.conf
</pre>
</pre>
Isi file:
Isi:
<pre>
<pre>
nameserver 192.168.111.103
nameserver 192.168.111.103
search belajar.local
search belajar.local
</pre>
</pre>
Verifikasi & restart:
[[Berkas:006-etc-resolv-conf.jpg|pus|jmpl|589x589px]]
<pre>
<pre>
# Cek konfigurasi
named-checkconf
named-checkconf
named-checkzone belajar.local /etc/bind/db.belajar.local
named-checkzone belajar.local /etc/bind/db.belajar.local
named-checkzone 111.168.192.in-addr.arpa /etc/bind/db.192.168.111
systemctl restart bind9 && systemctl enable bind9


# Verifikasi
# Restart BIND9
nslookup mailserver.belajar.local 192.168.111.103
systemctl restart bind9
dig MX belajar.local @192.168.111.103
systemctl enable bind9
dig -x 192.168.111.103 @192.168.111.103
 
# Tes DNS
nslookup mailserver.belajar.local
dig MX belajar.local
</pre>
</pre>
[[Berkas:007-cek-konfigurasi-named-checkzone-belajar-local.jpg|pus|jmpl|576x576px]]
[[Berkas:008-nslookup-maiserver-belajar-local.jpg|pus|jmpl|492x492px]]
[[Berkas:009-dig-mx-belajar-local.jpg|pus|jmpl|635x635px]]


== BAB 4 — INSTALASI WEB SERVER (Apache2 + PHP + MariaDB) ==
== BAGIAN 2: INSTALASI WEB SERVER & DATABASE ==
=== 4.1 Instalasi Apache2 ===
=== Langkah 1: Install Apache2 ===
<pre>
<pre>
apt install -y apache2 apache2-utils
apt install -y apache2
systemctl start apache2 && systemctl enable apache2
systemctl start apache2
systemctl enable apache2
</pre>
</pre>


=== 4.2 Instalasi PHP & Modul ===
=== Langkah 2: Install PHP dan Modul ===
<pre>
<pre>
apt install -y php php-cli php-common php-curl php-gd php-intl \
apt install -y php php-cli php-common php-curl php-gd php-intl \
     php-json php-mbstring php-mysql php-net-ldap2 \
     php-json php-mbstring php-mysql php-xml php-zip libapache2-mod-php
    php-net-smtp php-net-socket php-pear php-xml \
</pre>
    php-zip libapache2-mod-php
Cek PHP sudah terinstall:
<pre>
php -v
php -v
php -m | grep -E 'mysql|curl|mbstring|xml|zip|gd|intl'
</pre>
</pre>


=== 4.3 Instalasi & Konfigurasi MariaDB ===
=== Langkah 3: Install MariaDB ===
<pre>
<pre>
apt install -y mariadb-server mariadb-client
apt install -y mariadb-server mariadb-client
systemctl start mariadb && systemctl enable mariadb
systemctl start mariadb
mysql_secure_installation
systemctl enable mariadb
</pre>
</pre>
Jawaban saat <code>mysql_secure_installation</code>:
# Enter current password: (kosong, langsung Enter)
# Set root password? <code>Y</code> → masukkan password kuat
# Remove anonymous users? <code>Y</code>
# Disallow root login remotely? <code>Y</code>
# Remove test database? <code>Y</code>
# Reload privilege tables? <code>Y</code>


=== 4.4 Buat Database Roundcube ===
=== Langkah 4: Buat Database untuk Roundcube ===
<pre>
mysql -u root -p (enter)
</pre>
biarkan Password tetap kosong, langsung tekan Enter saja.
 
Masukkan perintah SQL:
<pre>
<pre>
mysql -u root -p
CREATE DATABASE roundcubemail CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE DATABASE roundcubemail CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'roundcube'@'localhost' IDENTIFIED BY 'password_roundcube';
CREATE USER 'roundcube'@'localhost' IDENTIFIED BY 'password123';
GRANT ALL PRIVILEGES ON roundcubemail.* TO 'roundcube'@'localhost';
GRANT ALL PRIVILEGES ON roundcubemail.* TO 'roundcube'@'localhost';
FLUSH PRIVILEGES;
FLUSH PRIVILEGES;
EXIT;
EXIT;
</pre>
</pre>
'''⚠️ PERHATIAN:''' Ganti <code>'password_roundcube'</code> dengan password yang kuat dan catat baik-baik.


=== 4.5 Aktifkan Modul Apache ===
=== Langkah 5: Aktifkan Modul Apache ===
<pre>
<pre>
a2enmod rewrite ssl headers
a2enmod rewrite ssl headers
Baris 281: Baris 249:
</pre>
</pre>


== BAB 5 — INSTALASI SMTP SERVER (POSTFIX) ==
== BAGIAN 3: INSTALASI SMTP SERVER (POSTFIX) ==
'''📌 CATATAN:''' Versi Postfix yang terinstall di Debian 13 adalah 3.10.5. Akan muncul pesan 'backwards-compatible default settings' saat pertama jalan — ini normal dan akan diatasi di langkah konfigurasi.
=== Langkah 1: Install Postfix ===
 
=== 5.1 Instalasi Postfix ===
<pre>
<pre>
apt install -y postfix postfix-mysql mailutils
apt install -y postfix mailutils
</pre>
</pre>
Saat dialog instalasi muncul:
Saat muncul dialog:
# General type of mail configuration: <code>Internet Site</code>
# Pilih: <code>Internet Site</code>
# System mail name: <code>belajar.local</code>
# System mail name: <code>belajar.local</code>


=== 5.2 Konfigurasi main.cf ===
=== Langkah 2: Konfigurasi main.cf ===
<pre>
<pre>
nano /etc/postfix/main.cf
nano /etc/postfix/main.cf
</pre>
</pre>
Isi/ubah konfigurasi:
Tambahkan/ubah konfigurasi berikut:
<pre>
<pre>
# Identitas server
# Identitas server
Baris 302: Baris 268:
mydomain = belajar.local
mydomain = belajar.local
myorigin = $mydomain
myorigin = $mydomain
# Jaringan
# Jaringan
inet_interfaces = all
inet_interfaces = all
Baris 307: Baris 274:
mydestination = $myhostname, localhost.$mydomain, $mydomain, localhost
mydestination = $myhostname, localhost.$mydomain, $mydomain, localhost
mynetworks = 127.0.0.0/8 192.168.111.0/24
mynetworks = 127.0.0.0/8 192.168.111.0/24
relayhost =
 
# Mailbox format Maildir
# Format mailbox
home_mailbox = Maildir/
home_mailbox = Maildir/
mailbox_size_limit = 51200000
 
message_size_limit = 10240000
# Autentikasi via Dovecot
# SASL Auth via Dovecot
smtpd_sasl_type = dovecot
smtpd_sasl_type = dovecot
smtpd_sasl_path = private/auth
smtpd_sasl_path = private/auth
smtpd_sasl_auth_enable = yes
smtpd_sasl_auth_enable = yes
smtpd_sasl_security_options = noanonymous
smtpd_sasl_security_options = noanonymous
smtpd_sasl_local_domain = $myhostname
 
# Pembatasan relay
# Keamanan relay
smtpd_recipient_restrictions =
smtpd_recipient_restrictions =
     permit_sasl_authenticated,
     permit_sasl_authenticated,
     permit_mynetworks,
     permit_mynetworks,
     reject_unauth_destination
     reject_unauth_destination
# Matikan warning compatibility
 
compatibility_level = 3.6
# Optimasi untuk RAM rendah
# Optimasi RAM rendah
default_process_limit = 10
default_process_limit = 10
smtpd_client_connection_rate_limit = 30
smtpd_client_connection_rate_limit = 30
</pre>
</pre>
'''✅ KOREKSI v2:''' Tambahkan <code>compatibility_level = 3.6</code> untuk menghilangkan warning 'Postfix is using backwards-compatible default settings' yang muncul di log.
[[Berkas:010-nano-etc-postfix-main-cf.jpg|pus|jmpl|560x560px]]


=== 5.3 Aktifkan Port Submission di master.cf ===
=== Langkah 3: Aktifkan Port Submission ===
<pre>
<pre>
nano /etc/postfix/master.cf
nano /etc/postfix/master.cf
</pre>
</pre>
Uncomment baris submission (hapus tanda <code>#</code>):
Cari baris <code>submission</code> dan hapus tanda <code>#</code>:
<pre>
<pre>
submission inet n      -      y      -      -      smtpd
submission inet n      -      y      -      -      smtpd
Baris 343: Baris 308:
   -o smtpd_recipient_restrictions=permit_sasl_authenticated,reject
   -o smtpd_recipient_restrictions=permit_sasl_authenticated,reject
</pre>
</pre>
[[Berkas:011-nano-etc-postfix-master-cf.jpg|pus|jmpl|534x534px]]


=== 5.4 Restart & Verifikasi ===
=== Langkah 4: Restart Postfix ===
<pre>
<pre>
systemctl restart postfix && systemctl enable postfix
systemctl restart postfix
postfix check
systemctl enable postfix
 
# Cek port sudah terbuka
ss -tlnp | grep -E ':25|:587'
ss -tlnp | grep -E ':25|:587'
</pre>
</pre>
[[Berkas:012-restart-postfix.jpg|pus|jmpl|731x731px]]


== BAB 6 — INSTALASI IMAP/POP3 SERVER (DOVECOT 2.4) ==
== BAGIAN 4: INSTALASI IMAP SERVER (DOVECOT) ==
'''⚠️ PERHATIAN:''' Dovecot 2.4 di Debian 13 menggunakan syntax konfigurasi yang BERBEDA dari versi 2.2/2.3. Jangan gunakan tutorial lama yang masih pakai <code>disable_plaintext_auth</code> atau <code>auth_mechanisms</code> langsung — syntax tersebut sudah tidak valid dan akan menyebabkan error saat restart.
=== Langkah 1: Install Dovecot ===
 
=== 6.1 Instalasi Dovecot ===
<pre>
<pre>
apt install -y dovecot-core dovecot-imapd dovecot-pop3d
apt install -y dovecot-core dovecot-imapd dovecot-pop3d
# Cek versi (akan menampilkan 2.4.x)
dovecot --version
</pre>
</pre>


=== 6.2 Konfigurasi Protokol — dovecot.conf ===
=== Langkah 2: Konfigurasi Protokol ===
<pre>
<pre>
nano /etc/dovecot/dovecot.conf
nano /etc/dovecot/dovecot.conf
</pre>
</pre>
Ubah/atur baris:
Ubah baris:
<pre>
<pre>
protocols = imap pop3
protocols = imap pop3
</pre>
</pre>
[[Berkas:013-nano-etc-dovecot-conf.jpg|pus|jmpl|654x654px]]


=== 6.3 Konfigurasi Mail Format — 10-mail.conf ===
=== Langkah 3: Konfigurasi Format Mail ===
Dovecot 2.4 menggunakan parameter <code>mail_driver</code> dan <code>mail_path</code> (bukan <code>mail_location</code> seperti versi lama):
<pre>
<pre>
nano /etc/dovecot/conf.d/10-mail.conf
nano /etc/dovecot/conf.d/10-mail.conf
</pre>
</pre>
Cari baris-baris lama dan comment semua, lalu tambahkan:
Cari dan ubah:
<pre>
<pre>
# Dovecot 2.4 - gunakan mail_driver dan mail_path
mail_path = maildir:~/Maildir
mail_driver = maildir
mail_path = ~/Maildir
mail_privileged_group = mail
</pre>
</pre>
'''✅ KOREKSI v2:''' Di Dovecot 2.4, parameter <code>mail_location</code> sudah diganti menjadi <code>mail_driver</code> + <code>mail_path</code>. Menggunakan <code>mail_location</code> di versi ini akan diabaikan atau menyebabkan error.
[[Berkas:014-etc-dovecot-conf-d-10-mail-conf.jpg|pus|jmpl|591x591px]]


=== 6.4 Konfigurasi Autentikasi — Syntax Dovecot 2.4 ===
=== Langkah 4: Konfigurasi Autentikasi ===
Di Dovecot 2.4, <code>disable_plaintext_auth</code> diganti dengan <code>auth_allow_cleartext</code>. Buat file konfigurasi khusus:
<pre>
<pre>
nano /etc/dovecot/conf.d/99-custom.conf
nano /etc/dovecot/conf.d/10-auth.conf
</pre>
</pre>
Isi file:
Pastikan baris ini aktif (tanpa tanda <code>#</code>):
<pre>
<pre>
# Konfigurasi auth untuk Dovecot 2.4
!include auth-system.conf.ext
# 'disable_plaintext_auth' sudah tidak ada di versi ini
auth_allow_cleartext = yes
passdb pam {
}
userdb passwd {
}
</pre>
</pre>
'''✅ KOREKSI v2:''' Jangan menambahkan <code>disable_plaintext_auth</code> atau <code>auth_mechanisms</code> di <code>10-auth.conf</code> karena akan menyebabkan: <code>Job for dovecot.service failed because the control process exited with error code</code>.
[[Berkas:015-etc-dovecot-conf-d-10-auth-conf.jpg|pus|jmpl|564x564px]]


=== 6.5 Konfigurasi Socket Auth untuk Postfix — 10-master.conf ===
=== Langkah 5: Konfigurasi Socket untuk Postfix ===
Ini adalah konfigurasi KRITIS. Postfix membutuhkan akses ke socket auth Dovecot. Jika socket ini tidak dikonfigurasi dengan benar, Postfix akan error: <code>SASL: Connect to Dovecot auth socket failed: Permission denied</code>.
<pre>
<pre>
nano /etc/dovecot/conf.d/10-master.conf
nano /etc/dovecot/conf.d/10-master.conf
</pre>
</pre>
Cari bagian <code>service auth</code> dan pastikan isinya seperti ini:
Cari bagian <code>service auth</code> dan pastikan seperti ini:
<pre>
<pre>
service auth {
service auth {
  # Socket untuk Postfix SASL
   unix_listener /var/spool/postfix/private/auth {
   unix_listener /var/spool/postfix/private/auth {
     mode = 0660
     mode = 0660
Baris 415: Baris 368:
     group = postfix
     group = postfix
   }
   }
  # Socket untuk userdb
 
   unix_listener auth-userdb {
   unix_listener auth-userdb {
    mode = 0600
  mode = 0660
    user = dovecot
  user = dovecot
   }
   }
}
}
</pre>
</pre>
'''⚠️ PERHATIAN:''' Urutan restart wajib: Dovecot DULU baru Postfix. Jika Postfix direstart sebelum Dovecot, socket belum terbuat dan Postfix akan gagal otentikasi.
[[Berkas:016-nano-etc-dovecot-conf-d-10-master-conf.jpg|pus|jmpl|754x754px]]


=== 6.6 Verifikasi Konfigurasi Sebelum Restart ===
=== Langkah 6: Restart Dovecot ===
<pre>
<pre>
# Cek tidak ada error syntax
# Restart Dovecot dulu
doveconf -n 2>&1 | head -20
systemctl restart dovecot
# Pastikan parameter utama terbaca
systemctl enable dovecot
doveconf -n | grep -E 'mail_driver|auth_allow|protocols'
</pre>
Output yang diharapkan:
<pre>
auth_allow_cleartext = yes
mail_driver = maildir
mail_path = ~/Maildir
protocols = imap pop3
</pre>


=== 6.7 Restart Dovecot & Verifikasi Socket ===
# Lalu restart Postfix
<pre>
# 1. Restart Dovecot dulu
systemctl restart dovecot
systemctl status dovecot
# 2. Verifikasi socket auth sudah terbuat
ls -la /var/spool/postfix/private/auth
</pre>
Output yang diharapkan dari <code>ls -la</code>:
<pre>
srw-rw---- 1 postfix postfix ... /var/spool/postfix/private/auth
</pre>
<pre>
# 3. Baru restart Postfix
systemctl restart postfix
systemctl restart postfix
# 4. Cek port yang terbuka
 
ss -tlnp | grep -E ':25|:110|:143|:587'
# Cek port
ss -tlnp | grep -E ':110|:143'
</pre>
</pre>
[[Berkas:017-restart-dovecot-6.jpg|pus|jmpl|653x653px]]


== BAB 7 — MEMBUAT AKUN PENGGUNA EMAIL ==
== BAGIAN 5: MEMBUAT AKUN EMAIL ==
Postfix dan Dovecot menggunakan akun sistem Linux sebagai akun email. Setiap user email = satu akun Linux.
=== Buat User Email ===
 
=== 7.1 Buat User & Direktori Maildir ===
<pre>
<pre>
# Buat user (tanpa login shell untuk keamanan)
# Buat user1
adduser --shell /sbin/nologin user1
adduser --shell /sbin/nologin user1
# Masukkan password saat diminta
# Buat user2
adduser --shell /sbin/nologin user2
adduser --shell /sbin/nologin user2
# Buat struktur direktori Maildir
 
# Buat folder Maildir
mkdir -p /home/user1/Maildir/{new,cur,tmp}
mkdir -p /home/user1/Maildir/{new,cur,tmp}
chown -R user1:user1 /home/user1/Maildir
chown -R user1:user1 /home/user1/Maildir
mkdir -p /home/user2/Maildir/{new,cur,tmp}
mkdir -p /home/user2/Maildir/{new,cur,tmp}
chown -R user2:user2 /home/user2/Maildir
chown -R user2:user2 /home/user2/Maildir
# Verifikasi
ls -la /home/user1/Maildir/
</pre>
</pre>
'''📌 CATATAN:''' Username = bagian email sebelum <code>@</code>. User 'user1' memiliki email <code>user1@belajar.local</code>
'''💡 Info:'''  
* User <code>user1</code> = email <code>user1@belajar.local</code>
* User <code>user2</code> = email <code>user2@belajar.local</code>


== BAB 8 — PENGUJIAN DENGAN TELNET ==
== 🧪 BAGIAN 6: PENGUJIAN DENGAN TELNET ==
=== 8.1 Instalasi Telnet ===
=== Langkah 1: Install Telnet ===
<pre>
<pre>
apt install -y telnet
apt install -y telnet
</pre>
</pre>


=== 8.2 Pengujian Koneksi SMTP (Port 25) ===
=== Langkah 2: Tes Kirim Email via SMTP ===
<pre>
<pre>
telnet 192.168.111.103 25
telnet 192.168.111.103 25
</pre>
</pre>
Server harus membalas dengan banner:
Jika berhasil, akan muncul:
<code>220 mailserver.belajar.local ESMTP Postfix</code>
'''⚠️ PERHATIAN:''' Jika koneksi terhubung tapi langsung tertutup tanpa banner 220, artinya Postfix menolak koneksi. Cek log dengan: <code>journalctl -u postfix --no-pager | tail -20</code>
 
Setelah banner muncul, ketik perintah berikut satu per satu:
<pre>
<pre>
EHLO belajar.local
220 mailserver.belajar.local ESMTP Postfix
</pre>
</pre>
Balas: <code>250-mailserver.belajar.local + daftar fitur ESMTP</code>
Ketik perintah berikut satu per satu:
<pre>
<pre>
EHLO belajar.local
MAIL FROM:<[email protected]>
MAIL FROM:<[email protected]>
</pre>
Balas: <code>250 2.1.0 Ok</code>
<pre>
</pre>
Balas: <code>250 2.1.5 Ok</code>
<pre>
DATA
DATA
</pre>
</pre>
Balas: <code>354 End data with <CR><LF>.<CR><LF></code>
Kemudian ketik isi email:
 
Ketik isi email dengan format lengkap (<code>From</code>, <code>To</code>, <code>Subject</code> WAJIB ada, diikuti baris kosong sebelum isi pesan):
<pre>
<pre>
Subject: Test Email Pertama
Subject: Hallo dari user1
Halo user2, ini adalah email test dari user1.
 
Halo user2, ini email percobaan kita!
Semoga berhasil ya!
.
.
</pre>
</pre>
Titik (<code>.</code>) di baris terakhir harus berdiri sendiri tanpa spasi untuk menandai akhir pesan.
'''⚠️ Penting:''' Titik (<code>.</code>) di baris terakhir harus sendiri, tanpa spasi!
Balas: <code>250 2.0.0 Ok: queued as XXXXXXXX</code>
 
Lanjutkan:
<pre>
<pre>
QUIT
QUIT
</pre>
</pre>
Balas: <code>221 2.0.0 Bye</code>
'''✅ KOREKSI v2:''' Format DATA yang benar wajib menyertakan header <code>From:</code>, <code>To:</code>, <code>Subject:</code> lalu satu baris kosong sebelum isi pesan. Tanpa header lengkap, beberapa mail client akan menolak atau gagal menampilkan email.


=== 8.3 Verifikasi Email Masuk ke Maildir ===
=== Langkah 3: Cek Email Masuk ===
<pre>
<pre>
ls /home/user2/Maildir/new/
ls /home/user2/Maildir/new/
</pre>
</pre>
Jika muncul file seperti <code>1776829892.Vfc11I411e9M718352.mail</code>, email berhasil diterima.
Jika muncul file, email berhasil diterima!
<pre>
<pre>
# Lihat isi email
# Lihat isi email
cat /home/user2/Maildir/new/NAMA_FILE_EMAIL
cat /home/user2/Maildir/new/*
</pre>
</pre>


=== 8.4 Pengujian Koneksi IMAP (Port 143) ===
=== Langkah 4: Tes IMAP ===
<pre>
<pre>
telnet 192.168.111.103 143
telnet 192.168.111.103 143
</pre>
</pre>
Server harus membalas: <code>* OK Dovecot ready</code>
Harus muncul: <code>* OK Dovecot ready</code>
<pre>
<pre>
a LOGIN user2 passworduser2
a LOGIN user2 passworduser2
b SELECT INBOX
b SELECT INBOX
c FETCH 1 BODY[]
d LOGOUT
d LOGOUT
</pre>
</pre>


=== 8.5 Cek Log — Cara yang Benar di Debian 13 ===
== 🌍 BAGIAN 7: INSTALASI WEBMAIL (ROUNDCUBE) ==
'''✅ KOREKSI v2:''' Di Debian 13 tanpa rsyslog, file <code>/var/log/mail.log</code> TIDAK ADA secara default. Gunakan journald untuk melihat log:
=== Langkah 1: Download Roundcube ===
<pre>
# Log Postfix via journald
journalctl -u postfix --no-pager | tail -30
# Log Dovecot via journald
journalctl -u dovecot --no-pager | tail -30
# Monitor realtime
journalctl -u postfix -f
# Setelah rsyslog terinstall, baru bisa pakai:
tail -f /var/log/mail.log
</pre>
 
=== 8.6 Troubleshooting Cepat ===
; Error: <code>Connection closed by foreign host</code> (tanpa banner 220)
: <pre>journalctl -u postfix --no-pager | tail -20</pre>
: Kemungkinan penyebab dan solusi:
:# <code>SASL: Connect to Dovecot auth socket failed: Permission denied</code> → Dovecot belum dikonfigurasi socketnya atau belum direstart. Jalankan: <code>systemctl restart dovecot</code>, lalu cek <code>ls -la /var/spool/postfix/private/auth</code>
:# <code>fatal: no SASL authentication mechanisms</code> → Akibat dari error socket di atas. Setelah Dovecot diperbaiki dan direstart, restart juga Postfix.
:# <code>mynetworks</code> tidak mencakup IP → Tambahkan: <code>postconf -e 'mynetworks = 127.0.0.0/8 192.168.111.0/24'</code>
 
; Error: Dovecot gagal restart setelah edit <code>10-auth.conf</code>
:# Hapus atau comment baris <code>disable_plaintext_auth</code> dan <code>auth_mechanisms</code> yang ditambahkan manual
:# Gunakan file <code>99-custom.conf</code> dengan parameter <code>auth_allow_cleartext = yes</code> sebagai gantinya
:# Verifikasi dengan: <code>doveconf -n 2>&1 | head -10</code>
 
== BAB 9 — INSTALASI WEBMAIL (ROUNDCUBE) ==
Roundcube adalah webmail berbasis PHP. Prasyarat: Apache2, PHP, dan MariaDB sudah berjalan, serta Postfix dan Dovecot sudah berhasil diuji dengan Telnet.
 
=== 9.1 Download & Ekstrak Roundcube ===
<pre>
<pre>
cd /var/www/html
cd /var/www/html
# Download Roundcube (cek versi terbaru di https://roundcube.net)
wget https://github.com/roundcube/roundcubemail/releases/download/1.6.6/roundcubemail-1.6.6-complete.tar.gz
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
tar xzf roundcubemail-1.6.6-complete.tar.gz
Baris 585: Baris 481:
</pre>
</pre>


=== 9.2 Set Permission ===
=== Langkah 2: Set Permission ===
<pre>
<pre>
chown -R www-data:www-data /var/www/html/roundcube
chown -R www-data:www-data /var/www/html/roundcube
Baris 593: Baris 489:
</pre>
</pre>


=== 9.3 Konfigurasi Apache Virtual Host ===
=== Langkah 3: Konfigurasi Apache ===
<pre>
<pre>
nano /etc/apache2/sites-available/roundcube.conf
nano /etc/apache2/sites-available/roundcube.conf
</pre>
</pre>
Isi file:
Isi:
<pre>
<pre>
&lt;VirtualHost *:80&gt;
<VirtualHost *:80>
     ServerName mail.belajar.local
     ServerName mail.belajar.local
     DocumentRoot /var/www/html/roundcube
     DocumentRoot /var/www/html/roundcube
     &lt;Directory /var/www/html/roundcube&gt;
     <Directory /var/www/html/roundcube>
         Options -Indexes +FollowSymLinks
         Options -Indexes +FollowSymLinks
         AllowOverride All
         AllowOverride All
         Require all granted
         Require all granted
     &lt;/Directory&gt;
     </Directory>
    ErrorLog ${APACHE_LOG_DIR}/roundcube_error.log
</VirtualHost>
    CustomLog ${APACHE_LOG_DIR}/roundcube_access.log combined
&lt;/VirtualHost&gt;
</pre>
</pre>
Aktifkan site:
Aktifkan site:
Baris 618: Baris 512:
</pre>
</pre>


=== 9.4 Import Skema Database ===
=== Langkah 4: Import Database Roundcube ===
<pre>
<pre>
mysql -u roundcube -p roundcubemail < /var/www/html/roundcube/SQL/mysql.initial.sql
mysql -u roundcube -p roundcubemail < /var/www/html/roundcube/SQL/mysql.initial.sql
</pre>
</pre>


=== 9.5 Setup via Web Installer ===
=== Langkah 5: Setup via Browser ===
# Buka browser: <code>http://192.168.111.103/roundcube/installer</code>
# Buka browser: <code>http://192.168.111.103/roundcube/installer</code>
# Ikuti wizard — pastikan semua ceklis hijau di halaman pertama
# Ikuti wizard setup
# Isi konfigurasi database:
# Konfigurasi database:
## Database server: <code>localhost</code>
## Server: <code>localhost</code>
## Database name: <code>roundcubemail</code>
## Database: <code>roundcubemail</code>
## Database user: <code>roundcube</code>
## User: <code>roundcube</code>
## Database password: (sesuai yang dibuat di BAB 4)
## Password: <code>password123</code> (sesuai yang dibuat tadi)
# Isi konfigurasi IMAP:
# Konfigurasi IMAP: <code>localhost</code>, port <code>143</code>
## IMAP host: <code>localhost</code>, port: <code>143</code>
# Konfigurasi SMTP: <code>localhost</code>, port <code>25</code>
## Connection type: normal (TLS opsional)
# Klik '''Create config''' → '''Initialize database'''
# Isi konfigurasi SMTP:
 
## SMTP host: <code>localhost</code>, port: <code>25</code>
=== Langkah 6: Hapus Folder Installer ===
# Klik <code>Create config</code> lalu <code>Initialize database</code>
# Setelah selesai, WAJIB hapus folder installer:
<pre>
<pre>
rm -rf /var/www/html/roundcube/installer
rm -rf /var/www/html/roundcube/installer
</pre>
</pre>


=== 9.6 Akses Roundcube ===
=== Langkah 7: Akses Webmail ===
Buka browser dan akses: <code>http://192.168.111.103/roundcube</code>
Buka browser: <code>http://192.168.111.103/roundcube</code>
Login menggunakan username dan password akun Linux (<code>user1</code> atau <code>user2</code>).
Login dengan:
'''📌 CATATAN:''' Jika login gagal, pastikan Dovecot berjalan dan cek: <code>journalctl -u dovecot --no-pager | tail -20</code>
* Username: <code>user1</code> atau <code>user2</code>
* Password: (sesuai password user Linux)


== BAB 10 — VERIFIKASI AKHIR & TROUBLESHOOTING ==
== 🔍 TROUBLESHOOTING DASAR ==
=== 10.1 Checklist Verifikasi Lengkap ===
=== Mail Server Tidak Bisa Dikirim ===
{| class="wikitable"
<pre>
! Item Pengujian !! Perintah !! Hasil Diharapkan
# Cek log Postfix
|-
journalctl -u postfix --no-pager | tail -20
| BIND9 berjalan || <code>systemctl is-active bind9</code> || active
 
|-
# Cek antrian email
| MX record terdaftar || <code>dig MX belajar.local</code> || mailserver.belajar.local
mailq
|-
 
| PTR record terdaftar || <code>dig -x 192.168.111.103</code> || mailserver.belajar.local
# Flush antrian
|-
postqueue -f
| Apache2 berjalan || <code>systemctl is-active apache2</code> || active
</pre>
|-
 
| MariaDB berjalan || <code>systemctl is-active mariadb</code> || active
=== Dovecot Tidak Bisa Login ===
|-
<pre>
| Postfix berjalan || <code>systemctl is-active postfix</code> || active
# Cek log Dovecot
|-
journalctl -u dovecot --no-pager | tail -20
| Port SMTP terbuka || <code>ss -tlnp | grep :25</code> || LISTEN :25
 
|-
# Cek konfigurasi
| Port Submission terbuka || <code>ss -tlnp | grep :587</code> || LISTEN :587
doveconf -n | head -20
|-
</pre>
| Dovecot berjalan || <code>systemctl is-active dovecot</code> || active
|-
| Port IMAP terbuka || <code>ss -tlnp | grep :143</code> || LISTEN :143
|-
| Socket auth ada || <code>ls /var/spool/postfix/private/auth</code> || socket file ada
|-
| Kirim email SMTP || <code>telnet localhost 25</code> || 220 banner muncul
|-
| Email masuk Maildir || <code>ls /home/user2/Maildir/new/</code> || ada file email
|-
| Login IMAP || <code>telnet localhost 143</code> || * OK Dovecot ready
|-
| Roundcube dapat diakses || <code>curl -sI http://localhost/roundcube</code> || HTTP 200
|}


=== 10.2 Perintah Manajemen Cepat ===
=== DNS Tidak Resolve ===
<pre>
<pre>
# Restart semua layanan sekaligus (urutan penting!)
# Cek konfigurasi BIND
systemctl restart bind9 mariadb apache2 dovecot postfix
named-checkconf
named-checkzone belajar.local /etc/bind/db.belajar.local
 
# Restart BIND
systemctl restart bind9
</pre>


=== Perintah Berguna untuk Siswa ===
<pre>
# Cek status semua layanan
# Cek status semua layanan
for svc in bind9 apache2 mariadb postfix dovecot; do
systemctl status bind9 apache2 mariadb postfix dovecot
    echo "[$svc]: $(systemctl is-active $svc)"
done


# Monitor log email realtime
# Restart semua layanan
journalctl -u postfix -f
systemctl restart bind9 apache2 mariadb postfix dovecot


# Cek antrian email
# Monitor log realtime
mailq
journalctl -f
 
# Flush antrian email tertunda
postqueue -f


# Tambah user email baru
# Tambah user email baru
Baris 708: Baris 589:
</pre>
</pre>


= APPENDIX — REFERENSI CEPAT =
== 📋 CHECKLIST AKHIR ==
== A.1 Daftar Port Layanan ==
{| class="wikitable" style="width:100%"
{| class="wikitable"
! No !! Pengujian !! Perintah !! Hasil OK
! Port !! Protokol !! Layanan !! Keterangan
|-
| 25 || TCP || Postfix SMTP || Terima email antar server
|-
| 53 || TCP/UDP || BIND9 DNS || Resolusi nama domain
|-
| 80 || TCP || Apache2 HTTP || Webmail Roundcube
|-
| 110 || TCP || Dovecot POP3 || Ambil email (POP3)
|-
| 143 || TCP || Dovecot IMAP || Ambil email (IMAP)
|-
| 443 || TCP || Apache2 HTTPS || Webmail HTTPS (opsional)
|-
|-
| 587 || TCP || Postfix Submission || Kirim email dari klien
| 1 || DNS aktif || <code>systemctl is-active bind9</code> || active
|-
|-
| 993 || TCP || Dovecot IMAPS || IMAP over SSL
| 2 || MX record || <code>dig MX belajar.local</code> || mailserver.belajar.local
|-
|-
| 995 || TCP || Dovecot POP3S || POP3 over SSL
| 3 || Apache aktif || <code>systemctl is-active apache2</code> || active
|}
 
== A.2 Ringkasan Koreksi v2 dari Implementasi Nyata ==
{| class="wikitable"
! No !! Masalah !! Panduan v1 (Salah) !! Panduan v2 (Benar)
|-
|-
| 1 || Dovecot 2.4 auth config || <code>disable_plaintext_auth = no</code> || <code>auth_allow_cleartext = yes</code> di <code>99-custom.conf</code>
| 4 || Database aktif || <code>systemctl is-active mariadb</code> || active
|-
|-
| 2 || Dovecot 2.4 mail format || <code>mail_location = maildir:~/Maildir</code> || <code>mail_driver = maildir</code> + <code>mail_path = ~/Maildir</code>
| 5 || Postfix aktif || <code>systemctl is-active postfix</code> || active
|-
|-
| 3 || Socket Postfix-Dovecot || Tidak ada konfigurasi socket || <code>service auth { unix_listener /var/spool/postfix/private/auth }</code>
| 6 || Port 25 terbuka || <code>ss -tlnp | grep :25</code> || LISTEN
|-
|-
| 4 || Urutan restart service || Restart bersamaan || Dovecot dulu, baru Postfix
| 7 || Dovecot aktif || <code>systemctl is-active dovecot</code> || active
|-
|-
| 5 || Log di Debian 13 || <code>tail -f /var/log/mail.log</code> || <code>journalctl -u postfix --no-pager</code>
| 8 || Port 143 terbuka || <code>ss -tlnp | grep :143</code> || LISTEN
|-
|-
| 6 || Format perintah DATA SMTP || Langsung isi tanpa header || From/To/Subject wajib, lalu baris kosong, lalu isi
| 9 || Kirim email Telnet || <code>telnet localhost 25</code> || 220 banner muncul
|-
|-
| 7 || Postfix compatibility || Tidak dikonfigurasi || <code>compatibility_level = 3.6</code>
| 10 || Email masuk || <code>ls /home/user2/Maildir/new/</code> || ada file
|-
|-
| 8 || IP Address contoh || 192.168.1.100 || 192.168.111.103
| 11 || Webmail bisa diakses || Browser ke <code>/roundcube</code> || halaman login muncul
|}
|}
''Panduan Mail Server Debian 13 di Proxmox CT — Revisi v2.0 —''
 
== 🎓 TUGAS PRAKTIKUM ==
# ✅ Instal mail server sesuai tutorial ini
# ✅ Buat 3 akun email: <code>siswa1</code>, <code>siswa2</code>, <code>guru</code>
# ✅ Kirim email dari <code>siswa1</code> ke <code>siswa2</code> via Telnet
# ✅ Verifikasi email masuk ke Maildir <code>siswa2</code>
# ✅ Login ke webmail Roundcube dengan akun <code>guru</code>
# ✅ Kirim email via webmail dari <code>guru</code> ke <code>siswa1</code>
# ✅ Dokumentasikan setiap langkah dengan screenshot
# ✅ Buat laporan praktikum dalam format PDF
 
== 📚 REFERENSI ==
* [https://www.postfix.org/ Postfix Official Documentation]
* [https://www.dovecot.org/ Dovecot Official Documentation]
* [https://roundcube.net/ Roundcube Webmail]
* [https://www.isc.org/bind/ BIND9 Documentation]
* Modul Praktikum TKJ SMK Administrasi Server Linux

Revisi terkini sejak 22 April 2026 07.30

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 configInitialize 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