Server Solutions
Dedicated Server Rental Meet your physical server needs with dedicated server rental Explore Now
Virtual Servers Scalable, high-availability server rental services with our high-performance cloud server solutions. Explore Now
İlkbyte Cloud Fully developed by Netinternet, flexible and scalable cloud servers with cloud technology Explore Now
GPU-Based AI Infrastructure High-performance GPU solutions created on a project basis for your AI and machine learning projects Explore Now
Server & Hardware Procurement Server and hardware procurement services with equipment suitable for your projects Explore Now
Customized Infrastructure Solutions Custom-designed infrastructure solutions and technical consulting services for your unique needs Explore Now
Hosting Services
Cabinet Rental Dedicated 15U, 24U and 48U smart cabinet systems allocated for you Explore Now
Server Colocation Individual server hosting service in shared cabinet systems Explore Now
Premium Connectivity Fast and reliable internet access with multi-carrier, multi-IXP and high-capacity Anti-DDoS protection Explore Now
Telecom Data Center Circuit Low-cost and high-performance internet access through a dedicated data center tariff Explore Now
Cross-Connect Direct connection between network carriers with low latency and high performance Explore Now
IP Address Pricing IP address and ASN rental services with RIPE LIR management services Explore Now
Managed Services
Managed Server Installation, configuration, regular maintenance, updates and 24/7 monitoring of your server operating system Explore Now
Managed Infrastructure End-to-end management of your entire IT infrastructure including data center, storage, virtualization and backup Explore Now
Managed Network Professional management and monitoring of network devices (router, switch, firewall) configuration, optimization and performance Explore Now
Managed Cloud (Public / Private) Professional management of your public and private cloud infrastructures to meet your cloud needs Explore Now
Managed Security 24/7 monitoring, analysis and response services against cyber security threats Explore Now
Managed Backup & Disaster Recovery Backup and disaster recovery plans, implementation, operation to ensure your data security and business continuity Explore Now
License Rental
cPanel Licenses cPanel software license rental solutions Explore Now
Plesk Licenses Plesk software license rental solutions Explore Now
DirectAdmin Licenses DirectAdmin software license rental solutions Explore Now
LiteSpeed Licenses LiteSpeed software license rental solutions Explore Now
CloudLinux Licenses CloudLinux software license rental solutions Explore Now
Cyber Security
HEIMWALL Fully developed by Netinternet, protect against cyber attacks with our Web Application Firewall solution Explore Now →
AntiDDoS High-capacity volumetric Anti-DDoS protection provided free by default on all our services Explore Now →
VPN Solutions Secure, encrypted tunnel connections for your remote offices and employees with our managed VPN solutions Explore Now →
Layer4 Stateless Firewall Layer4 stateless firewall solution for filtering and directing incoming traffic Explore Now →
SSL Certificates Secure connection solutions with free and paid SSL/TLS certificate options Explore Now →
Penetration Tests Penetration tests performed by third parties in cooperation with TSE-approved testing firms Explore Now →
Corporate Email
Corporate Email Solutions Fully domestic, KVKK compliant, 100% compatible with Outlook and all mail programs, professional, uninterrupted email service Explore Now →
Bulk Email Sending Manageable bulk email sending services with high delivery rates for your marketing campaigns Explore Now →
Email Archiving Secure archiving of all your email traffic to protect corporate memory and comply with legal requirements Explore Now →
Free Email Migration Service Wherever your email service is, we migrate you to Netinternet corporate email solution for free! Explore Now →
Traditional Web Hosting
cPanel Web Hosting Fast and reliable hosting packages with easy setup and management using cPanel, the world's most popular hosting management panel. Explore Now →
cPanel Reseller Hosting Fully customizable cPanel-based reseller hosting solution for starting your own hosting business Explore Now →
DirectAdmin Reseller Hosting Scalable and cost-effective reseller hosting powered by lightweight DirectAdmin control panel Explore Now →
Free Hosting Migration Service Professional migration services to move your existing systems to Netinternet data center infrastructure Explore Now →
Domain Names
Domain Registration Services Domain registration and easy management at the most affordable prices in all popular extensions (.com, .net, .org, etc.) Explore Now →
Domain Transfer Services Transfer your domains to Netinternet for professional domain management services Explore Now →
Domain Reseller Flexible and reliable reseller program and integration services for offering domain registration to your customers Explore Now →
Free Hosting with Domain Free hosting service for domains registered or transferred to Netinternet Explore Now →
Hosting & Cloud Service Providers High-density infrastructures, multi-tenant architectures and SLA-focused sustainable data center solutions for hosting and cloud providers Explore Now →
E-Commerce Companies High-performance, secure and uninterrupted e-commerce infrastructures resilient to sudden traffic surges during campaign periods Explore Now →
Software Developers Developer-friendly infrastructure solutions with CI/CD compatible, API-supported, automation-ready flexible resource management Explore Now →
SaaS Providers Scalable, high-availability and continuity-focused cloud infrastructures suitable for SaaS architectures serving many users. Explore Now →
AI & R&D GPU-based high-performance and scalable infrastructures for big data processing, model training and high computation tasks Explore Now →
Agencies & Marketing Multi-client management compatible, quick setup, high-performance and flexible web hosting infrastructures Explore Now →
Media & Broadcasting High bandwidth and low latency infrastructure solutions for live streaming, video and heavy content traffic Explore Now →
Banks & Fintech Regulation-compliant, Tier-3/Tier-4 standard, highly secure financial infrastructures ensuring uninterrupted service Explore Now →
Government & Education Long-term, sustainable and secure infrastructure solutions compliant with regulations and data security requirements Explore Now →
Manufacturing / Industry Low-latency and high-availability infrastructure solutions compatible with Industry 4.0, IoT and production automation systems Explore Now →
Healthcare Organizations Highly secure and uninterrupted health informatics infrastructures prioritizing patient data privacy and continuity Explore Now →
HEIMWALL – Web Application Firewall Protect your web applications against advanced attacks with our 100% domestic WAF platform HEIMWALL Explore Now →
Ilkbyte - Cloud Server Service Scalable and high-performance cloud servers deployable in seconds with our domestically developed orchestration infrastructure Explore Now →
Netrafix - Bandwidth Monitoring Manage 5651 compliant logging and bandwidth billing (Burst, Traffic Quota, 95th Percentile) in one platform with sFlow, NetFlow and IPFIX supported Netrafix Explore Now →
Secure Internet - For ISPs Keep your DNS traffic in your own network with 100% domestic DNS software developed for authorized ISPs Explore Now →
DirectIP - IP Management System 100% domestic IP management platform developed by Netinternet for centralized IP address, subnet, VLAN and DHCP management Explore Now →
RuleDNS - Rule-Based DNS Management Dynamically manage DNS responses with rule-based RuleDNS, easily integrate CDN and services with API support Explore Now →
Documents / Whitepapers Developer-focused technical documentation covering all API endpoints, usage scenarios and automation examples Explore Now →
API Documentation Developer-focused technical documentation covering API endpoints, usage scenarios and automation examples for platform integration Explore Now →
Peering Policies Reference policies transparently explaining our network architecture, traffic exchange principles and peering criteria Explore Now →
Frequently Asked Technical Questions Clear and actionable answers to the most frequently asked technical questions about infrastructure, security and operations Explore Now →
System Status Status page transparently sharing real-time status, planned maintenance and past outages of all platforms and services Explore Now →
Our Physical Data Center
Our Physical Data Center Our corporate data center facility designed with high security standards and redundant power and cooling infrastructure Explore Now →
Power, Cooling, Security Facility architecture designed for critical infrastructures with redundant power lines, climate systems and multi-layered physical security Explore Now →
Internet Access Points Low-latency and high-availability backbone connections through multiple operators and internet exchange points Explore Now →
Network Infrastructure
Network Infrastructure Uninterrupted connectivity infrastructure with multi-carrier connections, redundant backbone and high-capacity network architecture Explore Now →
Network Policies Sustainable network operation policies with transparently defined rules for traffic management, peering, security and capacity usage Explore Now →
Planning and Processes Scalable and controlled network management approach with pre-designed network capacity planning, growth scenarios and operational processes Explore Now →
Certificates and Documents
Our Certifications We provide auditable and sustainable infrastructure standards with our certifications for information security and service continuity Explore Now →
Security Policy We ensure protection of infrastructure and data with our security policies covering information security, access control and risk management Explore Now →
KVKK Compliance Data processing and storage structure compliant with KVKK and related regulations with defined technical and administrative measures for personal data protection. Explore Now →
Quality Policy Our quality management policies within the scope of ISO 9001 for continuous improvement of service quality. Explore Now →
Service Management Policy Our policies and standards governing IT service management processes within the scope of ISO/IEC 20000-1. Explore Now →
Business Continuity Policy Our ISO 22301 compliant policies and procedures ensuring business continuity against possible outage scenarios. Explore Now →
Incident Management Policy Our incident management processes and action plans for the detection, response and resolution of security incidents. Explore Now →
Supplier Security Policy Our policy governing information security requirements and risk assessment processes in supplier relationships. Explore Now →
Disclosure Text Text prepared within the scope of our disclosure obligation regarding the processing of your personal data under KVKK. Explore Now →
Cookie Policy Our policy regarding cookies and data collection practices used on our website. Explore Now →
Hosting Provider and Legal Obligation Policy Legal obligations we fulfill as a hosting provider under Law No. 5651. Explore Now →
Blog Posts Technical analyses, sector evaluations and current content about data center, network, cyber security and cloud technologies Explore Now →
Case Studies Reference case studies describing needs encountered, solutions applied and outcomes achieved in real projects Explore Now →
Events and Announcements Events we attend and organize, technical meetings, launches and current announcements about Netinternet Explore Now →
Back to Blog

Postfix, Spamassassin and Policyd Installation

Abdullah
Abdullah Altunbaş
Author
15.04.2022
1300 views

The main purpose of these two-page articles is to stop mail spam attacks from compromised machines via PHP socket opening method and to prevent our mail servers from being blacklisted. The tools we use to achieve this are all Open Source projects that are still being actively developed.

To briefly explain the structures we use and their functions: we used the relay server concept to control and log different machines under a single structure. The main programs used in this structure are Postfix as MTA, Spamassassin which automatically checks the content of emails, and Policyd Cluebringer which handles the bulk of the work.

Policyd, a Postfix plugin, with its lightweight structure checks only the headers of incoming mail without looking at the content, verifies whether the sender is our customer, and allows mail to be sent if the user is authorized in the system. As you can imagine, with this structure we can block outbound mails at a rate 60% higher by blocking mails not defined in the system, while delivering registered users’ mails without any issues.

Note: Ubuntu 15.04 was used in this installation.


1 Postfix, Spamassassin, Policyd Installation and Configuration


1.1 Redirecting Exim Cpanel Server


nano /etc/exim.conf

Edit the smart route line if it exists, or add it yourself:


smart_route:
driver = manualroute
domains = !+local_domains
transport = remote_smtp

This ensures all incoming port traffic on the Exim MTA system is forwarded to the other machine

route_data = <RELAY SERVER IP>


1.1.1 Testing the Redirect


echo “This is the body of the email” | mail -s “This is the subject line” user@example.com

Send a mail to any address using this command and listen on the relay server machine with tcpdump. If output appears on the page, the redirect was done correctly.


tcpdump host <CPanel IP>

If we can receive packets from our server here, we can proceed to the Relay server where the main operations will be performed.


1.2 Postfix Installation


1.2.1 Prerequisites for Postfix Installation


  • Root privileges for installation
  • The mailutils package containing mail commands like mailx for testing Postfix:
    apt-get install mailutils

  1. Downloading Postfix

    apt-get install postfix

    1. Configuring Postfix - Editing main.cf


      sudo nano /etc/postfix/main.cf

      smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
      myhostname = SERVERNAME
      alias_maps = hash:/etc/aliases
      alias_database = hash:/etc/aliases
      mydestination = localdomain, localhost, localhost.localdomain, localhost
      relayhost =
      mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128, 31.192.215.72
      mailbox_command = procmail -a “$EXTENSION”
      mailbox_size_limit = 0
      recipient_delimiter = +
      inet_interfaces = all

      sudo service postfix restart

    2. Testing the system


      echo “This is the body of the email” | mail -s “This is the subject line” user@example.com

1.3 Spamassassin Installation


apt-get install spamassassin spamc

groupadd spamd
useradd -g spamd -s /bin/false -d /var/log/spamassassin spamd

mkdir /var/log/spamassassin
chown spamd:spamd /var/log/spamassassin

1.3.1 Activating Spamassassin


nano /etc/default/spamassassin

Change ENABLED=0 to ENABLED=1


Change CRON=0 to CRON=1


SAHOME=“/var/log/spamassassin/”
OPTIONS=“–create-prefs –max-children 5 –username spamd -H ${SAHOME} -s ${SAHOME}spamd.log”

service spamassassin start

1.3.2 Integrating Spamassassin with Postfix


nano /etc/postfix/master.cf

Replace: #smtp inet n - - - - smtpd


With: smtp inet n - - - - smtpd -o content_filter=spamassassin


spamassassin unix - n n - - pipe user=spamd argv=/usr/bin/spamc -f -e /usr/sbin/sendmail -oi -f ${sender} ${recipient}

service postfix restart

1.3.3 Customizing Spamassassin Configuration


nano /etc/spamassassin/local.cf

rewrite_header Subject [***** SPAM SCORE ****]
required_score 5.0
use_bayes 1
bayes_auto_learn 1

service spamassassin restart

tail -f /var/log/spamassassin/spamd.log

1.4 Policyd Installation


apt-get install postfix-cluebringer

1.4.3 Installing Required Perl Modules


apt-get install mysql-server mysql-client
/usr/bin/perl -MCPAN -e ‘install Net::Server’
/usr/bin/perl -MCPAN -e ‘install Net::CIDR’
apt-get install libconfig-inifiles-perl
apt-get install libcache-fastmmap-perl
/usr/bin/perl -MCPAN -e ‘install Mail::SPF ‘

1.4.4 Preparing the MySQL Database


mysql –version

cd
mkdir policyd-cluebringer
cd policyd-cluebringer
wget http://download.policyd.org/v2.0.14/cluebringer-v2.0.14.tar.xz
unxz -c clue
| tar xv
cd clue*
cd database
for i in core.tsql access_control.tsql quotas.tsql amavis.tsql checkhelo.tsql checkspf.tsql greylisting.tsql
do
./convert-tsql mysql55 $i
done > policyd.mysql

1.4.5 Activating the Database


mysql -p
mysql> create database cluebringer;
mysql> use cluebringer;
mysql> CREATE USER ‘cluebringer’@‘localhost’ IDENTIFIED BY ‘mypassword’;
mysql> GRANT ALL PRIVILEGES ON cluebringer.* TO ‘cluebringer’@‘localhost’;
exit

mysql -u root -p cluebringer < policyd.mysql

1.4.6 Configuring Cluebringer for Database


nano /etc/cluebringer/cluebringer.conf

DSN=DBI:mysql:dbname=cluebringer;host=localhost
DB_Type=mysql
DB_Host=localhost
DB_Port=3306
DB_Name=cluebringer
Username=cluebringer
Password=mypassword

service postfix-cluebringer start
service postfix-cluebringer status

1.4.7 Integrating Cluebringer with Postfix


nano /etc/postfix/main.cf

smtpd_recipient_restrictions = check_policy_service inet:127.0.0.1:10031, permit_mynetworks
smtpd_end_of_data_restrictions = check_policy_service inet:127.0.0.1:10031, permit_mynetworks

nano /etc/postfix/master.cf

policy-spf  unix  -       n       n       -       -       spawn
user=nobody argv=/usr/sbin/postfix-policyd-spf-perl

1.4.8 Cluebringer WebUI Configuration


nano /etc/cluebringer/cluebringer-webui.conf

$DB_DSN=“mysql:host=localhost;dbname=cluebringer”;
$DB_USER=“cluebringer”;
$DB_PASS=“mypassword”;

cd /var/www/html
ln -s /usr/share/postfix-cluebringer-webui/webui/

apt-get install php5-mysql

1.5 Final Notes


  • Our server is now practically operational. All further configurations depend on your server’s situation and how you define permissions in Policyd.

1.6 References


Abdullah

Abdullah Altunbaş

Content Writer

Netinternet Bilişim Teknolojileri A.Ş.'de teknik konularda liderlik yapıyorum. 15 yıldır bu alanda çalışıyorum ve özellikle sistem yönetimi, ağ teknolojileri ve yazılım geliştirme konularına odaklanıyorum.

Comments

0

No comments yet. Be the first to comment!

Leave a Comment

* Your comment will be published after approval.