Tuesday, August 19, 2025

Configuring Email and DNS Servers on a Germany VPS

1. Introduction

When you rent a Germany VPS, you can host not only websites but also email and DNS services. Setting up your own mail server and DNS server gives you full control over domains, email accounts, and DNS records. This is useful for businesses that want to manage their own infrastructure with improved privacy, security, and branding.



2. Preparing Your VPS

Before starting, ensure:

  • OS installed: Ubuntu, Debian, or CentOS are common choices.

  • Root or sudo access to your VPS.

  • Domain name purchased and pointed to your VPS IP.

  • Basic server setup done (update packages, configure firewall, set hostname).

Example (Ubuntu):

sudo apt update && sudo apt upgrade -y
sudo hostnamectl set-hostname mail.yourdomain.com

3. Setting Up DNS Server (BIND9 Example)

DNS is crucial for email delivery and domain resolution.

Install BIND9 (Debian/Ubuntu)

sudo apt install bind9 bind9utils bind9-doc -y

Configure Zone Files

Edit /etc/bind/named.conf.local:

zone "yourdomain.com" {
    type master;
    file "/etc/bind/zones/yourdomain.com.db";
};

Create the zone file /etc/bind/zones/yourdomain.com.db:

$TTL 3600
@   IN  SOA ns1.yourdomain.com. admin.yourdomain.com. (
        2025081901 ; Serial
        3600       ; Refresh
        1800       ; Retry
        1209600    ; Expire
        86400 )    ; Minimum TTL

@   IN  NS    ns1.yourdomain.com.
@   IN  NS    ns2.yourdomain.com.
@   IN  A     123.45.67.89       ; VPS IP
ns1 IN  A     123.45.67.89
ns2 IN  A     123.45.67.90
mail IN  A    123.45.67.89
@    IN  MX 10 mail.yourdomain.com.

Restart BIND:

sudo systemctl restart bind9

4. Setting Up Mail Server

There are multiple stacks, but the most common combination is Postfix + Dovecot + SpamAssassin.

Install Postfix (MTA)

sudo apt install postfix -y

During setup, select:

  • Internet Site

  • Enter yourdomain.com

Install Dovecot (IMAP/POP3)

sudo apt install dovecot-core dovecot-imapd -y

Configure Mailboxes

Edit /etc/postfix/main.cf:

myhostname = mail.yourdomain.com
mydomain = yourdomain.com
myorigin = $mydomain
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
mynetworks = 127.0.0.0/8
inet_interfaces = all
home_mailbox = Maildir/

Restart Postfix & Dovecot:

sudo systemctl restart postfix dovecot

5. Securing Your Mail Server

  • Install Certbot (Let's Encrypt) for SSL/TLS:

    sudo apt install certbot python3-certbot-nginx -y
    certbot certonly --standalone -d mail.yourdomain.com
    
  • Update Postfix and Dovecot configs to use certificates.

6. Essential DNS Records for Email

To avoid spam issues, set:

  • MX Record → Points to mail.yourdomain.com

  • SPF Record (TXT) →

    v=spf1 mx ~all
    
  • DKIM → Generate keys with opendkim.

  • DMARC (TXT) →

    v=DMARC1; p=quarantine; rua=mailto:admin@yourdomain.com
    

7. Testing Your Setup

  • Use tools like dig or nslookup to test DNS:

    dig MX yourdomain.com
    
  • Send a test email via CLI:

    echo "Test email" | mail -s "Hello" you@example.com
    
  • Check spam filters (Gmail/Outlook headers).

8. Maintenance & Best Practices

  • Enable firewall rules (open ports 25, 465, 587, 143, 993, 53).

  • Regularly update VPS and mail server packages.

  • Monitor logs (/var/log/mail.log).

  • Use fail2ban to block brute-force attacks.

9. Conclusion

By setting up a DNS server with BIND9 and a mail server with Postfix/Dovecot on your Germany VPS, you gain full control over domain resolution and email communication. This setup is secure, scalable, and ideal for businesses that value data privacy.

👉 If you want a ready-to-use VPS solution in Germany, you can check providers like 99RDP which offer pre-configured VPS hosting, saving you setup time.


No comments:

Post a Comment

Admin RDP vs Traditional Remote Desktop Software: Pros and Cons

In the digital age, remote access has become a necessity for businesses, IT professionals, and individuals who need to manage systems, perfo...