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...')
 
Tidak ada ringkasan suntingan
Baris 1: Baris 1:
= PANDUAN LENGKAP INSTALASI MAIL SERVER =
= TUTORIAL INSTALASI MAIL SERVER =
'''Debian 13 di Proxmox CT'''
'''Debian 13 di Proxmox CT — Edisi Pemula TKJ'''
''Edisi Revisi v2.0 — Diperbarui berdasarkan hasil implementasi nyata''
''Panduan praktis untuk siswa SMK Jurusan Teknik Komputer dan Jaringan''


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


== BAB 1 — PENDAHULUAN & GAMBARAN UMUM ==
== 🎯 TUJUAN PEMBELAJARAN ==
=== 1.1 Tujuan Panduan ===
Setelah mengikuti tutorial ini, siswa mampu:
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.
# Memahami arsitektur dasar mail server
# Menginstal dan mengkonfigurasi layanan DNS, SMTP, IMAP, dan Webmail
# Menguji koneksi email menggunakan Telnet
# Melakukan troubleshooting dasar jika terjadi error


'''✅ 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.
== 📦 PERSIAPAN AWAL ==
 
=== Spesifikasi Server ===
=== 1.2 Arsitektur Layanan ===
{| class="wikitable" style="width:100%"
Urutan instalasi wajib diikuti karena setiap layanan menjadi prasyarat bagi layanan berikutnya:
! Komponen !! Spesifikasi Minimum
{| class="wikitable"
! Urutan !! Layanan !! Aplikasi !! Fungsi
|-
| 1 || DNS Server || BIND9 || Resolusi domain, MX record, PTR record
|-
| 2 || Web Server || Apache2 + PHP || Hosting webmail Roundcube
|-
| 3 || Database || MariaDB || Penyimpanan data Roundcube
|-
| 4 || SMTP Server || Postfix 3.10 || Kirim & terima email (port 25/587)
|-
| 5 || IMAP/POP3 || Dovecot 2.4 || Pengambilan email oleh klien (port 143/110)
|-
| 6 || Webmail || Roundcube || Antarmuka web baca/kirim email
|-
| 7 || Testing || Telnet || Pengujian koneksi SMTP/IMAP manual
|}
 
=== 1.3 Spesifikasi Lingkungan ===
{| class="wikitable"
! Platform !! Proxmox VE (Container / CT mode)
|-
! OS Guest !! Debian 13 (Trixie) 64-bit
|-
! Storage !! 8 GB HDD
|-
|-
! RAM !! 512 MB + Swap 512 MB (wajib diaktifkan)
| Proxmox VE || Versi 8.x (Container Mode)
|-
|-
! IP Address !! 192.168.111.103 (sesuaikan dengan jaringan Anda)
| OS Guest || Debian 13 (Trixie) 64-bit
|-
|-
! Domain !! belajar.local
| Storage || 8 GB HDD
|-
|-
! Hostname !! mailserver.belajar.local
| RAM || 512 MB + Swap 512 MB
|-
|-
! Postfix !! 3.10.5
| IP Address || 192.168.111.103/24
|-
|-
! Dovecot !! 2.4.1 (syntax berbeda dari versi lama!)
| Domain || belajar.local
|-
|-
! Akses !! Root shell via Proxmox Console atau SSH
| Hostname || mailserver.belajar.local
|}
|}


'''📌 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
|-
|-
! 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
|}
|}


=== 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 79:
192.168.111.103  mailserver.belajar.local  mailserver
192.168.111.103  mailserver.belajar.local  mailserver
</pre>
</pre>
==== 2.2.3 Aktifkan Swap ====
<pre>
<pre>
# Aktifkan Swap (agar tidak kehabisan memori)
fallocate -l 512M /swapfile
fallocate -l 512M /swapfile
chmod 600 /swapfile
chmod 600 /swapfile
Baris 110: Baris 86:
swapon /swapfile
swapon /swapfile
echo "/swapfile none swap sw 0 0" >> /etc/fstab
echo "/swapfile none swap sw 0 0" >> /etc/fstab
free -h   # verifikasi swap aktif
 
# Cek swap sudah aktif
free -h
</pre>
</pre>


=== 2.3 Konfigurasi Firewall ===
=== Langkah 4: Aktifkan Firewall ===
<pre>
<pre>
ufw allow 22/tcp
# Buka port yang dibutuhkan
ufw allow 25/tcp
ufw allow 22/tcp   # SSH
ufw allow 53
ufw allow 25/tcp   # SMTP
ufw allow 80/tcp
ufw allow 53       # DNS
ufw allow 110/tcp
ufw allow 80/tcp   # HTTP
ufw allow 143/tcp
ufw allow 110/tcp   # POP3
ufw allow 443/tcp
ufw allow 143/tcp   # IMAP
ufw allow 587/tcp
ufw allow 443/tcp   # HTTPS
ufw allow 993/tcp
ufw allow 587/tcp   # Submission
ufw allow 995/tcp
ufw allow 993/tcp   # IMAPS
ufw allow 995/tcp   # POP3S
 
# Aktifkan firewall
ufw enable
ufw enable
ufw status
ufw status
</pre>
</pre>


== BAB 3 — INSTALASI DNS SERVER (BIND9) ==
== 🔧 BAGIAN 1: INSTALASI DNS SERVER (BIND9) ==
=== 3.1 Instalasi BIND9 ===
=== Langkah 1: Install 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 153: Baris 132:
</pre>
</pre>


=== 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 169: Baris 148:
</pre>
</pre>


=== 3.4 File Zone Forward ===
=== Langkah 4: Buat File Zone Forward ===
<pre>
<pre>
cp /etc/bind/db.local /etc/bind/db.belajar.local
cp /etc/bind/db.local /etc/bind/db.belajar.local
Baris 192: Baris 171:
</pre>
</pre>


=== 3.5 File Zone Reverse ===
=== Langkah 5: Buat File Zone Reverse ===
<pre>
<pre>
cp /etc/bind/db.127 /etc/bind/db.192.168.111
cp /etc/bind/db.127 /etc/bind/db.192.168.111
Baris 211: Baris 190:
</pre>
</pre>


=== 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:
<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>


== 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
systemctl enable mariadb
</pre>
Amankan database:
<pre>
mysql_secure_installation
mysql_secure_installation
</pre>
</pre>
Jawaban saat <code>mysql_secure_installation</code>:
Jawab pertanyaan:
# Enter current password: (kosong, langsung Enter)
# Password root saat ini: (tekan Enter, kosongkan)
# Set root password? <code>Y</code> → masukkan password kuat
# Set password baru? <code>Y</code> → masukkan password
# Remove anonymous users? <code>Y</code>
# Hapus user anonim? <code>Y</code>
# Disallow root login remotely? <code>Y</code>
# Blokir root login dari jarak jauh? <code>Y</code>
# Remove test database? <code>Y</code>
# Hapus database test? <code>Y</code>
# Reload privilege tables? <code>Y</code>
# Reload privilege? <code>Y</code>


=== 4.4 Buat Database Roundcube ===
=== Langkah 4: Buat Database untuk Roundcube ===
<pre>
<pre>
mysql -u root -p
mysql -u root -p
</pre>
Masukkan perintah SQL:
<pre>
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.
'''⚠️ Catatan:''' Ganti <code>password123</code> dengan password yang lebih aman!


=== 4.5 Aktifkan Modul Apache ===
=== Langkah 5: Aktifkan Modul Apache ===
<pre>
<pre>
a2enmod rewrite ssl headers
a2enmod rewrite ssl headers
Baris 281: Baris 270:
</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 289:
mydomain = belajar.local
mydomain = belajar.local
myorigin = $mydomain
myorigin = $mydomain
# Jaringan
# Jaringan
inet_interfaces = all
inet_interfaces = all
Baris 307: Baris 295:
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 RAM rendah
default_process_limit = 10
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.


=== 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 344: Baris 325:
</pre>
</pre>


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


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


=== 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_location = 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.


=== 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>.


=== 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
     user = postfix
     user = postfix
     group = postfix
     group = postfix
  }
  # Socket untuk userdb
  unix_listener auth-userdb {
    mode = 0600
    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.


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


== 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 485:
</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 493:
</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 516:
</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)
 
== 🔍 TROUBLESHOOTING DASAR ==
=== Mail Server Tidak Bisa Dikirim ===
<pre>
# Cek log Postfix
journalctl -u postfix --no-pager | tail -20
 
# Cek antrian email
mailq
 
# Flush antrian
postqueue -f
</pre>
 
=== Dovecot Tidak Bisa Login ===
<pre>
# Cek log Dovecot
journalctl -u dovecot --no-pager | tail -20


== BAB 10 — VERIFIKASI AKHIR & TROUBLESHOOTING ==
# Cek konfigurasi
=== 10.1 Checklist Verifikasi Lengkap ===
doveconf -n | head -20
{| class="wikitable"
</pre>
! Item Pengujian !! Perintah !! Hasil Diharapkan
|-
| BIND9 berjalan || <code>systemctl is-active bind9</code> || active
|-
| MX record terdaftar || <code>dig MX belajar.local</code> || mailserver.belajar.local
|-
| PTR record terdaftar || <code>dig -x 192.168.111.103</code> || mailserver.belajar.local
|-
| Apache2 berjalan || <code>systemctl is-active apache2</code> || active
|-
| MariaDB berjalan || <code>systemctl is-active mariadb</code> || active
|-
| Postfix berjalan || <code>systemctl is-active postfix</code> || active
|-
| Port SMTP terbuka || <code>ss -tlnp | grep :25</code> || LISTEN :25
|-
| Port Submission terbuka || <code>ss -tlnp | grep :587</code> || LISTEN :587
|-
| 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 593:
</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
| 1 || DNS aktif || <code>systemctl is-active bind9</code> || active
|-
|-
| 110 || TCP || Dovecot POP3 || Ambil email (POP3)
| 2 || MX record || <code>dig MX belajar.local</code> || mailserver.belajar.local
|-
|-
| 143 || TCP || Dovecot IMAP || Ambil email (IMAP)
| 3 || Apache aktif || <code>systemctl is-active apache2</code> || active
|-
|-
| 443 || TCP || Apache2 HTTPS || Webmail HTTPS (opsional)
| 4 || Database aktif || <code>systemctl is-active mariadb</code> || active
|-
|-
| 587 || TCP || Postfix Submission || Kirim email dari klien
| 5 || Postfix aktif || <code>systemctl is-active postfix</code> || active
|-
|-
| 993 || TCP || Dovecot IMAPS || IMAP over SSL
| 6 || Port 25 terbuka || <code>ss -tlnp | grep :25</code> || LISTEN
|-
|-
| 995 || TCP || Dovecot POP3S || POP3 over SSL
| 7 || Dovecot aktif || <code>systemctl is-active dovecot</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>
| 8 || Port 143 terbuka || <code>ss -tlnp | grep :143</code> || LISTEN
|-
|-
| 2 || Dovecot 2.4 mail format || <code>mail_location = maildir:~/Maildir</code> || <code>mail_driver = maildir</code> + <code>mail_path = ~/Maildir</code>
| 9 || Kirim email Telnet || <code>telnet localhost 25</code> || 220 banner muncul
|-
|-
| 3 || Socket Postfix-Dovecot || Tidak ada konfigurasi socket || <code>service auth { unix_listener /var/spool/postfix/private/auth }</code>
| 10 || Email masuk || <code>ls /home/user2/Maildir/new/</code> || ada file
|-
|-
| 4 || Urutan restart service || Restart bersamaan || Dovecot dulu, baru Postfix
| 11 || Webmail bisa diakses || Browser ke <code>/roundcube</code> || halaman login muncul
|-
| 5 || Log di Debian 13 || <code>tail -f /var/log/mail.log</code> || <code>journalctl -u postfix --no-pager</code>
|-
| 6 || Format perintah DATA SMTP || Langsung isi tanpa header || From/To/Subject wajib, lalu baris kosong, lalu isi
|-
| 7 || Postfix compatibility || Tidak dikonfigurasi || <code>compatibility_level = 3.6</code>
|-
| 8 || IP Address contoh || 192.168.1.100 || 192.168.111.103
|}
|}
''— 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
 
''— Tutorial Mail Server untuk SMK TKJ — Edisi Pemula —''
''Dibuat untuk pembelajaran praktikum Administrasi Infrastruktur Jaringan''

Revisi per 22 April 2026 04.10

TUTORIAL INSTALASI MAIL SERVER

Debian 13 di Proxmox CT — Edisi Pemula TKJ Panduan praktis untuk siswa SMK Jurusan Teknik Komputer dan Jaringan

Komponen yang Dipelajari: Apache2 • BIND9 • Postfix • Dovecot • Roundcube Spesifikasi Lab: HDD 8 GB | RAM 512 MB | Proxmox Container | IP: 192.168.111.103

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

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
# Aktifkan Swap (agar tidak kehabisan memori)
fallocate -l 512M /swapfile
chmod 600 /swapfile
mkswap /swapfile
swapon /swapfile
echo "/swapfile none swap sw 0 0" >> /etc/fstab

# Cek swap sudah aktif
free -h

Langkah 4: Aktifkan Firewall

# Buka port yang dibutuhkan
ufw allow 22/tcp    # SSH
ufw allow 25/tcp    # SMTP
ufw allow 53        # DNS
ufw allow 80/tcp    # HTTP
ufw allow 110/tcp   # POP3
ufw allow 143/tcp   # IMAP
ufw allow 443/tcp   # HTTPS
ufw allow 587/tcp   # Submission
ufw allow 993/tcp   # IMAPS
ufw allow 995/tcp   # POP3S

# Aktifkan firewall
ufw enable
ufw status

🔧 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;
};

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";
};

Langkah 4: Buat File Zone Forward

cp /etc/bind/db.local /etc/bind/db.belajar.local
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

Langkah 5: Buat File Zone Reverse

cp /etc/bind/db.127 /etc/bind/db.192.168.111
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.

Langkah 6: Set DNS Lokal & Restart

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

Isi:

nameserver 192.168.111.103
search belajar.local
# 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

🌐 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

Amankan database:

mysql_secure_installation

Jawab pertanyaan:

  1. Password root saat ini: (tekan Enter, kosongkan)
  2. Set password baru? Y → masukkan password
  3. Hapus user anonim? Y
  4. Blokir root login dari jarak jauh? Y
  5. Hapus database test? Y
  6. Reload privilege? Y

Langkah 4: Buat Database untuk Roundcube

mysql -u root -p

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;

⚠️ Catatan: Ganti password123 dengan password yang lebih aman!

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

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

Langkah 4: Restart Postfix

systemctl restart postfix
systemctl enable postfix

# Cek port sudah terbuka
ss -tlnp | grep -E ':25|:587'

📬 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

Langkah 3: Konfigurasi Format Mail

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

Cari dan ubah:

mail_location = maildir:~/Maildir

Langkah 4: Konfigurasi Autentikasi

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

Pastikan baris ini aktif (tanpa tanda #):

!include auth-system.conf.ext

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

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'

👤 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

— Tutorial Mail Server untuk SMK TKJ — Edisi Pemula — Dibuat untuk pembelajaran praktikum Administrasi Infrastruktur Jaringan