Ports and Sockets Reference¶
Complete reference of network ports and Unix sockets used by Mailborder.
Overview¶
Mailborder uses a combination of:
- TCP Ports - Network services (SMTP, HTTP, etc.)
- Unix Sockets - Inter-process communication (IPC)
- Internal Ports - Daemon communication
- External Ports - Public-facing services
TCP Ports¶
Public-Facing Ports¶
Ports that should be accessible from external networks.
| Port | Service | Protocol | Purpose | Firewall |
|---|---|---|---|---|
| 25 | SMTP | TCP | Email receiving | ALLOW |
| 80 | HTTP | TCP | Web interface (redirect to HTTPS) | ALLOW |
| 443 | HTTPS | TCP | Secure web interface | ALLOW |
| 587 | SMTP Submission | TCP | Authenticated email sending (optional) | OPTIONAL |
| 465 | SMTPS | TCP | SMTP over SSL (deprecated, optional) | OPTIONAL |
Port 25 - SMTP¶
Service: Postfix SMTP daemon Direction: Inbound Required: Yes (for receiving email)
# Test connectivity
telnet mailborder.example.com 25
# Expected response
220 mailborder.example.com ESMTP Postfix
Firewall rule (iptables):
Firewall rule (UFW):
Port 80 - HTTP¶
Service: Nginx web server Direction: Inbound Required: Yes (for initial access and Let's Encrypt)
Configuration: Redirects to HTTPS automatically
server {
listen 80;
server_name mailborder.example.com;
return 301 https://$server_name$request_uri;
}
Firewall rule:
Port 443 - HTTPS¶
Service: Nginx web server (SSL/TLS) Direction: Inbound Required: Yes (for web interface)
Test:
Firewall rule:
Port 587 - SMTP Submission (Optional)¶
Service: Postfix submission service Direction: Inbound Required: Only if users send mail through Mailborder
Configuration:
# /etc/postfix/master.cf
submission inet n - y - - smtpd
-o smtpd_tls_security_level=encrypt
-o smtpd_sasl_auth_enable=yes
-o smtpd_recipient_restrictions=permit_sasl_authenticated,reject
Firewall rule:
Internal Ports¶
Ports used for internal daemon communication.
| Port | Service | Binding | Purpose |
|---|---|---|---|
| 10031 | mb-filter | 127.0.0.1 | Email content filtering |
| 10032 | mb-milter | 127.0.0.1 | Postfix milter protocol |
| 11332 | Rspamd | 127.0.0.1 | Spam scanning milter |
| 11333 | Rspamd Controller | 127.0.0.1 | Rspamd web interface |
| 3310 | ClamAV | 127.0.0.1 | Antivirus scanning |
| 3306 | MariaDB | 127.0.0.1 | Database server |
| 6379 | Redis | 127.0.0.1 | Cache and sessions |
Port 10031 - mb-filter¶
Service: Mailborder email filtering daemon Binding: 127.0.0.1 (localhost only) Protocol: SMTP-like (Postfix content filter)
Configuration: /etc/postfix/main.cf
Test:
Firewall: No external access needed
Port 10032 - mb-milter¶
Service: Mailborder milter daemon Binding: 127.0.0.1 (localhost only) Protocol: Milter protocol
Configuration: /etc/postfix/main.cf
Check status:
Port 11332 - Rspamd Milter¶
Service: Rspamd spam scanner Binding: 127.0.0.1 (localhost only) Protocol: Milter protocol
Configuration: /etc/postfix/main.cf
Test:
Port 11333 - Rspamd Controller¶
Service: Rspamd web interface Binding: 127.0.0.1 (localhost only) Access: Through Nginx reverse proxy
Configuration: /etc/rspamd/local.d/worker-controller.inc
Access via browser:
(Proxied through Nginx)
Port 3310 - ClamAV¶
Service: ClamAV antivirus daemon Binding: 127.0.0.1 (localhost only) Protocol: ClamAV protocol
Test:
Configuration: /etc/clamav/clamd.conf
Port 3306 - MariaDB¶
Service: MariaDB database server Binding: 127.0.0.1 (localhost only) Required: Yes
Configuration: /etc/mysql/mariadb.conf.d/50-server.cnf
Test:
Security: - Never expose to public internet - Use strong passwords - Enable SSL for remote connections (clustering only)
Port 6379 - Redis¶
Service: Redis cache server Binding: 127.0.0.1 (localhost only) Required: Yes (for sessions and caching)
Configuration: /etc/redis/redis.conf
Test:
Cluster Communication Ports¶
Only needed for multi-server deployments.
| Port | Service | Direction | Purpose |
|---|---|---|---|
| 10050 | mb-cluster | Both | Cluster synchronization |
| 3306 | MariaDB | Inbound | Database replication |
| 6379 | Redis | Inbound | Redis replication (optional) |
Port 10050 - Cluster Sync¶
Service: Mailborder cluster daemon Direction: Bidirectional (main ↔ child nodes) Required: Only for clustering
Configuration:
sudo mb-config set cluster.enabled true
sudo mb-config set cluster.port 10050
sudo mb-config set cluster.bind "0.0.0.0"
Firewall (only allow cluster IPs):
Unix Domain Sockets¶
Unix sockets provide fast, secure inter-process communication.
PHP-FPM Socket¶
Path: /var/run/php/mailborder.sock Owner: mailborder:www-data Permissions: 0660
Purpose: PHP-FPM process communication
Configuration: /etc/php/8.2/fpm/pool.d/mailborder.conf
listen = /var/run/php/mailborder.sock
listen.owner = mailborder
listen.group = www-data
listen.mode = 0660
Nginx configuration:
Check:
mb-rpcd Socket¶
Path: /var/run/mailborder/mb-rpcd.sock Owner: mailborder:mailborder Permissions: 0660
Purpose: RPC daemon communication
Configuration:
Check:
ClamAV Socket¶
Path: /var/run/clamav/clamd.sock Owner: clamav:clamav Permissions: 0666
Purpose: Antivirus scanning
Configuration: /etc/clamav/clamd.conf
Test:
Redis Socket (Optional)¶
Path: /var/run/redis/redis.sock Alternative to: TCP port 6379
Advantages: - Faster than TCP - More secure (filesystem permissions)
Configuration: /etc/redis/redis.conf
PHP configuration:
Port Verification¶
Check All Ports¶
List listening ports:
Example output:
tcp 0 0 0.0.0.0:25 0.0.0.0:* LISTEN 1234/master
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 5678/nginx
tcp 0 0 0.0.0.0:443 0.0.0.0:* LISTEN 5678/nginx
tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN 2345/mysqld
tcp 0 0 127.0.0.1:6379 0.0.0.0:* LISTEN 3456/redis-server
tcp 0 0 127.0.0.1:10031 0.0.0.0:* LISTEN 4567/mb-filter
tcp 0 0 127.0.0.1:11332 0.0.0.0:* LISTEN 6789/rspamd
Using ss (modern alternative):
Check Unix Sockets¶
List Unix sockets:
Check socket connections:
Port Connectivity Tests¶
External port test (from remote machine):
Expected output:
Connection to mailborder.example.com 25 port [tcp/smtp] succeeded!
Connection to mailborder.example.com 443 port [tcp/https] succeeded!
Internal port test (from localhost):
Firewall Configuration¶
UFW (Uncomplicated Firewall)¶
Basic configuration:
# Reset firewall
sudo ufw --force reset
# Default policies
sudo ufw default deny incoming
sudo ufw default allow outgoing
# Allow SSH (important - don't lock yourself out!)
sudo ufw allow 22/tcp
# Allow Mailborder services
sudo ufw allow 25/tcp # SMTP
sudo ufw allow 80/tcp # HTTP
sudo ufw allow 443/tcp # HTTPS
# Enable firewall
sudo ufw enable
# Check status
sudo ufw status verbose
Rate limiting (prevent brute force):
Allow specific IPs only:
# Only allow admin access from office IP
sudo ufw allow from 203.0.113.0/24 to any port 22
# Only allow SMTP from specific mail servers
sudo ufw allow from 198.51.100.0/24 to any port 25
iptables (Advanced)¶
SMTP rules:
# Allow SMTP
sudo iptables -A INPUT -p tcp --dport 25 -j ACCEPT
# Rate limit SMTP connections (prevent spam floods)
sudo iptables -A INPUT -p tcp --dport 25 -m limit --limit 100/minute -j ACCEPT
sudo iptables -A INPUT -p tcp --dport 25 -j DROP
Web interface rules:
# Allow HTTP/HTTPS
sudo iptables -A INPUT -p tcp --dport 80 -j ACCEPT
sudo iptables -A INPUT -p tcp --dport 443 -j ACCEPT
Connection tracking:
# Allow established connections
sudo iptables -A INPUT -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
Save rules:
Security Recommendations¶
Port Exposure¶
Minimize public exposure: 1. Only expose necessary ports (25, 80, 443) 2. Bind internal services to 127.0.0.1 3. Use Unix sockets where possible 4. Disable unused services
Example secure binding:
Rate Limiting¶
Protect against abuse:
# UFW rate limiting
sudo ufw limit 25/tcp
sudo ufw limit 443/tcp
# Fail2ban (automated blocking)
sudo apt install fail2ban
Fail2ban configuration:
# /etc/fail2ban/jail.local
[postfix]
enabled = true
port = smtp
filter = postfix
logpath = /var/log/mail.log
maxretry = 5
bantime = 3600
Monitoring¶
Monitor port usage:
# Real-time connection monitoring
sudo watch -n 1 'ss -tunap'
# Connection count by port
sudo netstat -an | awk '{print $4}' | sort | uniq -c | sort -rn
Log monitoring:
# Watch SMTP connections
sudo tail -f /var/log/mail.log
# Watch web access
sudo tail -f /var/log/nginx/mailborder-access.log
Change Default Ports (Optional)¶
Move SSH to non-standard port:
# /etc/ssh/sshd_config
Port 2222
sudo systemctl restart sshd
sudo ufw allow 2222/tcp
sudo ufw delete allow 22/tcp
Don't Change Standard Ports
Don't change SMTP (25) or HTTPS (443) - these are expected by mail servers and users.
Troubleshooting¶
Port Already in Use¶
Check what's using a port:
Example output:
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
master 1234 root 13u IPv4 12345 0t0 TCP *:smtp (LISTEN)
Kill process using port:
Cannot Connect to Port¶
Check if service is running:
Check if port is listening:
Check firewall:
Check from external:
Permission Denied on Socket¶
Check socket permissions:
Fix permissions:
sudo chown mailborder:mailborder /var/run/mailborder/mb-rpcd.sock
sudo chmod 660 /var/run/mailborder/mb-rpcd.sock
Verify group membership:
Port Conflict¶
Two services trying to use same port:
# Find conflicting service
sudo netstat -tulpn | grep :25
# Stop one service
sudo systemctl stop conflicting-service
Port Summary Table¶
Quick Reference¶
| Port | Service | Public | Internal | Socket Alternative |
|---|---|---|---|---|
| 25 | SMTP | ✓ | ||
| 80 | HTTP | ✓ | ||
| 443 | HTTPS | ✓ | ||
| 587 | Submission | Optional | ||
| 3306 | MariaDB | ✓ | ||
| 3310 | ClamAV | ✓ | clamd.sock | |
| 6379 | Redis | ✓ | redis.sock | |
| 10031 | mb-filter | ✓ | ||
| 10032 | mb-milter | ✓ | ||
| 11332 | Rspamd | ✓ | ||
| 11333 | Rspamd Web | ✓ |
Minimal Configuration¶
For basic deployment (no clustering): - Public: 25, 80, 443 - Internal: 3306, 6379, 10031, 11332, 3310 - Sockets: PHP-FPM, mb-rpcd, clamd
See Also¶
- Configuration Files - Service configuration
- Network Configuration - Network setup guide
- System Requirements - Network requirements