<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>La Fabulosa Vida de un IT</title>
	<atom:link href="https://www.luzem.com/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.luzem.com</link>
	<description>Aventuras y desventuras de un  IT</description>
	<lastBuildDate>Tue, 07 Feb 2017 23:54:46 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=4.7.3</generator>
	<item>
		<title>SAMBA group Permissions Centos 7</title>
		<link>https://www.luzem.com/2017/02/08/samba-group-permissions-centos-7/</link>
		<comments>https://www.luzem.com/2017/02/08/samba-group-permissions-centos-7/#respond</comments>
		<pubDate>Tue, 07 Feb 2017 23:50:38 +0000</pubDate>
		<dc:creator><![CDATA[Luzem]]></dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[centos 7]]></category>
		<category><![CDATA[rhel 7]]></category>
		<category><![CDATA[samba]]></category>
		<category><![CDATA[setGID]]></category>

		<guid isPermaLink="false">https://www.luzem.com/?p=4118</guid>
		<description><![CDATA[Mary, Eve, Peter and Julian are coworkers in a new startup. their share all documents in a samba share because they&#8217;re using cutting edge technologies. One shared folder is mapped to a network drive inside these unit there are 4 folders, billing, marketing, projects and contracts, permisions are defined by the next matrix They are &#8230; <p class="link-more"><a href="https://www.luzem.com/2017/02/08/samba-group-permissions-centos-7/" class="more-link">Continue reading<span class="screen-reader-text"> "SAMBA group Permissions Centos 7"</span></a></p>]]></description>
				<content:encoded><![CDATA[<p>Mary, Eve, Peter and Julian are coworkers in a new startup.</p>
<p>their share all documents in a samba share because they&#8217;re using cutting edge technologies.</p>
<p>One shared folder is mapped to a network drive inside these unit there are 4 folders, billing, marketing, projects and contracts, permisions are defined by the next matrix</p>
<p><a href="https://www.luzem.com/wp-content/uploads/2017/02/Permissions_Matrix.png"><img class="aligncenter size-medium wp-image-4121" src="https://www.luzem.com/wp-content/uploads/2017/02/Permissions_Matrix-300x64.png" alt="" width="300" height="64" srcset="https://www.luzem.com/wp-content/uploads/2017/02/Permissions_Matrix-300x64.png 300w, https://www.luzem.com/wp-content/uploads/2017/02/Permissions_Matrix.png 410w" sizes="(max-width: 300px) 100vw, 300px" /></a>They are a little special and they need to have all folders inside the network unit, because they waste a lot of time searching for server folders.</p>
<p>So let&#8217;s go to configure this samba server under Centos 7.</p>
<p><strong>1.- we will need to install several packages</strong></p>
<pre class="brush: bash; title: ; notranslate">

yum -y update

yum install epel-release

yum install samba samba-client samba-common vim

</pre>
<p><strong>2.- Open several ports and enable services</strong></p>
<pre class="brush: bash; title: ; notranslate">

systemctl enable smb.service
systemctl enable nmb.service
systemctl start smb.service
systemctl start nmb.service
firewall-cmd --permanent --zone=public --add-service=samba
firewall-cmd --reload

</pre>
<p><strong>3.- Create users</strong></p>
<p>Each member of group needs an user</p>
<pre class="brush: bash; title: ; notranslate">

adduser   -s /sbin/nologin mary
adduser   -s /sbin/nologin eve
adduser   -s /sbin/nologin peter
adduser   -s /sbin/nologin julian

</pre>
<p><strong>4.- Create Groups</strong></p>
<p>each folder needs a group</p>
<pre class="brush: bash; title: ; notranslate">

groupadd billing
groupadd marketing
groupadd projects
groupadd contracts

</pre>
<p><strong>5.- Join Groups and users</strong></p>
<p>We will need to join users and groups</p>
<pre class="brush: bash; title: ; notranslate">

usermod -a -G billing mary
usermod -a -G marketing mary
usermod -a -G marketing eve
usermod -a -G projects eve
usermod -a -G projects peter
usermod -a -G contracts peter
usermod -a -G contracts julian
usermod -a -G billing julian

</pre>
<p><strong>6.- Create samba config</strong></p>
<p>we will edit our samba config, shared folder will be at /media/shared</p>
<pre class="brush: bash; title: ; notranslate">

vim /etc/samba/smb.conf

</pre>
<p>our config file should be like these</p>
<pre class="brush: plain; title: ; notranslate">

[global]
workgroup = SAMBA
security = user
name = THESERVER
passdb backend = tdbsam

[shared]
comment = shared folder
path = /media/shared
guest ok = no
guest only = no
write list = @billing, @marketing, @projects, @contracts
valid users = @billing, @marketing, @projects, @contracts
create mask = 660
directory mask = 2770
</pre>
<p>we need to inform selinux that /media/shared directory will be user by samba process</p>
<pre class="brush: bash; title: ; notranslate">

chcon -t samba_share_t /media/shared/

</pre>
<p><strong>7 Create directory structure</strong></p>
<p>we need to create our directory structure inside /media/shared and give correct permissions.</p>
<pre class="brush: bash; title: ; notranslate">

mkdir billing
mkdir marketing
mkdir projects
mkdir contracts

chgrp billing billing/

chgrp contracts contracts/

chgrp marketing marketing/

chgrp  projects projects/

</pre>
<p><strong>and now here it&#8217;s the magic</strong></p>
<p><strong>all directories needs to have read and write permisions for group</strong></p>
<pre class="brush: bash; title: ; notranslate">

chmod g+rw *

</pre>
<p><strong>and we will enable Set Group ID for all directories</strong></p>
<pre class="brush: bash; title: ; notranslate">

chmod g+s *

</pre>
<p>with Set Group ID SETGID all files created in each directory will have the same group that parent directory</p>
<p><strong>8 Create password for users</strong></p>
<p>each user needs to have a password to access to shared folder</p>
<pre class="brush: bash; title: ; notranslate">

smbpasswd -a mary

smbpasswd -a eve

smbpasswd -a peter

smbpasswd -a julian

</pre>
<p>Test if everything is working</p>
<p>Enjoy</p>
]]></content:encoded>
			<wfw:commentRss>https://www.luzem.com/2017/02/08/samba-group-permissions-centos-7/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Installing Zabbix Agent onto a Sinology DS216J</title>
		<link>https://www.luzem.com/2017/02/05/installing-zabbix-agent-onto-a-sinology-ds216j/</link>
		<comments>https://www.luzem.com/2017/02/05/installing-zabbix-agent-onto-a-sinology-ds216j/#respond</comments>
		<pubDate>Sun, 05 Feb 2017 11:53:09 +0000</pubDate>
		<dc:creator><![CDATA[Luzem]]></dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[DS216J]]></category>
		<category><![CDATA[Sinology]]></category>
		<category><![CDATA[Zabbix]]></category>

		<guid isPermaLink="false">https://www.luzem.com/?p=4103</guid>
		<description><![CDATA[Nowadays small storage servers are a cheap solution for store backups and SME storage server. Recently  Small business with various Sinology Servers in different locations asked me if there any way to control a few parameters like free storage space. Quickly I remember that zabbix could be a good solution for this scenario, I get &#8230; <p class="link-more"><a href="https://www.luzem.com/2017/02/05/installing-zabbix-agent-onto-a-sinology-ds216j/" class="more-link">Continue reading<span class="screen-reader-text"> "Installing Zabbix Agent onto a Sinology DS216J"</span></a></p>]]></description>
				<content:encoded><![CDATA[<p>Nowadays small storage servers are a cheap solution for store backups and SME storage server.</p>
<p>Recently  Small business with various Sinology Servers in different locations asked me if there any way to control a few parameters like free storage space.</p>
<p>Quickly I remember that zabbix could be a good solution for this scenario, I get a Sinology DS216J and start checking if where posible to install a zabbix agent inside.</p>
<p>Like Qnap these devices are small ARM processors with a customized linux distribution installed.</p>
<p>The process was simply, Just attach a hard disk and update to latest firmware, remember newer is always better.</p>
<p><a href="https://www.luzem.com/wp-content/uploads/2017/02/Sinology.jpg"><img class="aligncenter size-medium wp-image-4106" src="https://www.luzem.com/wp-content/uploads/2017/02/Sinology-270x300.jpg" alt="" width="270" height="300" srcset="https://www.luzem.com/wp-content/uploads/2017/02/Sinology-270x300.jpg 270w, https://www.luzem.com/wp-content/uploads/2017/02/Sinology-768x853.jpg 768w, https://www.luzem.com/wp-content/uploads/2017/02/Sinology-922x1024.jpg 922w" sizes="(max-width: 270px) 100vw, 270px" /></a>After First steps, we will need to get a terminal access.</p>
<p>This is easy</p>
<p>Login as admin in your sinology web interface an go to Control Panel -&gt; Advanced Mode -&gt; Terminal &amp; SNMP and enable SSH service</p>
<p><a href="https://www.luzem.com/wp-content/uploads/2017/02/Sinology_enable_ssh.jpg"><img class="aligncenter size-medium wp-image-4108" src="https://www.luzem.com/wp-content/uploads/2017/02/Sinology_enable_ssh-300x173.jpg" alt="" width="300" height="173" srcset="https://www.luzem.com/wp-content/uploads/2017/02/Sinology_enable_ssh-300x173.jpg 300w, https://www.luzem.com/wp-content/uploads/2017/02/Sinology_enable_ssh-768x442.jpg 768w, https://www.luzem.com/wp-content/uploads/2017/02/Sinology_enable_ssh.jpg 991w" sizes="(max-width: 300px) 100vw, 300px" /></a>from a linux terminal or  using putty we will login in the sinology</p>
<pre class="brush: bash; title: ; notranslate">

ssh admin@'sinology ip'

</pre>
<p>for example ssh admin@192.168.100.1</p>
<p>now we are inside the nas linux, first we will need to change to root user</p>
<pre class="brush: bash; title: ; notranslate">

sudo su -

</pre>
<p><a href="https://www.luzem.com/wp-content/uploads/2017/02/sinology_root_login.png"><img class="aligncenter size-medium wp-image-4111" src="https://www.luzem.com/wp-content/uploads/2017/02/sinology_root_login-300x191.png" alt="" width="300" height="191" srcset="https://www.luzem.com/wp-content/uploads/2017/02/sinology_root_login-300x191.png 300w, https://www.luzem.com/wp-content/uploads/2017/02/sinology_root_login.png 736w" sizes="(max-width: 300px) 100vw, 300px" /></a></p>
<p>now we can install Entware-ng that is a package repository only a few steps are needed</p>
<p>create a dir to store packages</p>
<pre class="brush: bash; title: ; notranslate">

mkdir -p /volume1/@entware-ng/opt

</pre>
<p>change /opt dir to the previous created</p>
<pre class="brush: bash; title: ; notranslate">

rm -rf /opt
ln -sf /volume1/@entware-ng/opt /opt

</pre>
<p>now we will execute the repo installer, in our case we are runing an armv7</p>
<pre class="brush: bash; title: ; notranslate">

wget -O - http://pkg.entware.net/binaries/armv7/installer/entware_install.sh | /bin/sh

</pre>
<p>next step is integrade entware with our profile</p>
<p>just edit <code>/etc/profile</code> and append these line at the end</p>
<p>. /opt/etc/profile</p>
<p>now we should reboot our nas and login again as admin</p>
<p>and start zabbix installation</p>
<pre class="brush: bash; title: ; notranslate">

opkg update

</pre>
<p>and we can install zabbix agent</p>
<pre class="brush: bash; title: ; notranslate">

opkg install zabbix-agentd

</pre>
<p>your zabbix configuration file will be at</p>
<p>/opt/etc/zabbix_agentd.conf</p>
<p>and you can start and stop zabbix agent launching this command</p>
<pre class="brush: bash; title: ; notranslate">

/opt/etc/init.d/S07zabbix_agentd start

/opt/etc/init.d/S07zabbix_agentd stop

</pre>
<p>&nbsp;</p>
<p>references:</p>
<p><a href="https://github.com/Entware-ng/Entware-ng/wiki/Install-on-Synology-NAS">https://github.com/Entware-ng/Entware-ng/wiki/Install-on-Synology-NAS</a></p>
]]></content:encoded>
			<wfw:commentRss>https://www.luzem.com/2017/02/05/installing-zabbix-agent-onto-a-sinology-ds216j/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Edgerouter lite ipsec site-to-site with dynamic ip in both places</title>
		<link>https://www.luzem.com/2016/10/19/edgerouter-lite-ipsec-site-to-site-with-dynamic-ip-in-both-places/</link>
		<comments>https://www.luzem.com/2016/10/19/edgerouter-lite-ipsec-site-to-site-with-dynamic-ip-in-both-places/#comments</comments>
		<pubDate>Wed, 19 Oct 2016 20:31:16 +0000</pubDate>
		<dc:creator><![CDATA[Luzem]]></dc:creator>
				<category><![CDATA[Aparatitos]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[dynamic]]></category>
		<category><![CDATA[edgemax]]></category>
		<category><![CDATA[ipsec]]></category>
		<category><![CDATA[site to site]]></category>
		<category><![CDATA[vpn]]></category>

		<guid isPermaLink="false">https://www.luzem.com/?p=4097</guid>
		<description><![CDATA[One of my clients needs to renew an very old router, We choose an Edgerouter lite because has a incredible price, performance is more than enough for client internet capacity and the customer needs a VPN between two offices Both locations have dynamic ip, so we choose to use a dynamic dns service ( no-ip &#8230; <p class="link-more"><a href="https://www.luzem.com/2016/10/19/edgerouter-lite-ipsec-site-to-site-with-dynamic-ip-in-both-places/" class="more-link">Continue reading<span class="screen-reader-text"> "Edgerouter lite ipsec site-to-site with dynamic ip in both places"</span></a></p>]]></description>
				<content:encoded><![CDATA[<p>One of my clients needs to renew an very old router, We choose an Edgerouter lite because has a incredible price, performance is more than enough for client internet capacity and the customer needs a VPN between two offices</p>
<p><a href="https://www.luzem.com/wp-content/uploads/2016/10/EdgeRouter_lite.png"><img class="aligncenter size-medium wp-image-4100" src="https://www.luzem.com/wp-content/uploads/2016/10/EdgeRouter_lite-300x111.png" alt="Edgerouter lite" width="300" height="111" srcset="https://www.luzem.com/wp-content/uploads/2016/10/EdgeRouter_lite-300x111.png 300w, https://www.luzem.com/wp-content/uploads/2016/10/EdgeRouter_lite-768x285.png 768w, https://www.luzem.com/wp-content/uploads/2016/10/EdgeRouter_lite-1024x380.png 1024w, https://www.luzem.com/wp-content/uploads/2016/10/EdgeRouter_lite-1200x445.png 1200w" sizes="(max-width: 300px) 100vw, 300px" /></a>Both locations have dynamic ip, so we choose to use a dynamic dns service ( no-ip , dyndns, afraid &#8230;).</p>
<p>After configure NAT, PPPOE, port forwading, DHCP and various services, I decide to configure an ipsec site-to-site conection.</p>
<p>First i updated Edgerouter to latest firmware version  1.9.0 (new is always better)</p>
<p>I used gui wizard and doesn&#8217;t work, I follow serveral guides and doesn&#8217;t work I played with CLI and nothing worked, my VPN doesnt start.</p>
<p>After reading some documentation of StrongSwan I found the solution.</p>
<p>after configure site-to-site using web GUI y opened a CLI and launch a couple of command</p>
<p>Router A (factory.ddns.site)<br />
set vpn ipsec site-to-site peer office.ddns.site authentication id fqdn:factory.ddns.site<br />
set vpn ipsec site-to-site peer office.ddns.site authentication remote-id fqdn:office.ddns.site</p>
<p>Router B (office.ddns.site)<br />
set vpn ipsec site-to-site peer factory.ddns.site authentication id fqdn:office.ddns.site<br />
set vpn ipsec site-to-site peer factory.ddns.site authentication remote-id fqdn:factory.ddns.site</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>https://www.luzem.com/2016/10/19/edgerouter-lite-ipsec-site-to-site-with-dynamic-ip-in-both-places/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Centos 7 recover root password</title>
		<link>https://www.luzem.com/2016/04/24/centos-7-recover-root-password/</link>
		<comments>https://www.luzem.com/2016/04/24/centos-7-recover-root-password/#respond</comments>
		<pubDate>Sun, 24 Apr 2016 13:57:54 +0000</pubDate>
		<dc:creator><![CDATA[Luzem]]></dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[centos 7]]></category>
		<category><![CDATA[password]]></category>
		<category><![CDATA[rd.break]]></category>
		<category><![CDATA[recover]]></category>
		<category><![CDATA[rhel 7]]></category>
		<category><![CDATA[root]]></category>

		<guid isPermaLink="false">https://www.luzem.com/?p=4073</guid>
		<description><![CDATA[Sometimes you need to reset root password from a Centos 7 system. Here I will show an easy way, not the only one. First you&#8217;ll need access to grub boot screen, if system it&#8217;s running you can send an Ctrl+Alt+Supr key combination at this point we can press the key e to edit boot sequence &#8230; <p class="link-more"><a href="https://www.luzem.com/2016/04/24/centos-7-recover-root-password/" class="more-link">Continue reading<span class="screen-reader-text"> "Centos 7 recover root password"</span></a></p>]]></description>
				<content:encoded><![CDATA[<p>Sometimes you need to reset root password from a Centos 7 system.</p>
<p>Here I will show an easy way, not the only one.</p>
<p>First you&#8217;ll need access to grub boot screen, if system it&#8217;s running you can send an Ctrl+Alt+Supr key combination</p>
<p><a href="https://www.luzem.com/wp-content/uploads/2016/04/grub_load.png"><img class="aligncenter size-medium wp-image-4077" src="https://www.luzem.com/wp-content/uploads/2016/04/grub_load-300x167.png" alt="grub load screen" width="300" height="167" srcset="https://www.luzem.com/wp-content/uploads/2016/04/grub_load-300x167.png 300w, https://www.luzem.com/wp-content/uploads/2016/04/grub_load.png 719w" sizes="(max-width: 300px) 100vw, 300px" /></a>at this point we can press the key e to edit boot sequence</p>
<p><a href="https://www.luzem.com/wp-content/uploads/2016/04/grub_edit_centos_7.png"><img class="aligncenter size-medium wp-image-4080" src="https://www.luzem.com/wp-content/uploads/2016/04/grub_edit_centos_7-300x167.png" alt="edit grub centos 7" width="300" height="167" srcset="https://www.luzem.com/wp-content/uploads/2016/04/grub_edit_centos_7-300x167.png 300w, https://www.luzem.com/wp-content/uploads/2016/04/grub_edit_centos_7.png 720w" sizes="(max-width: 300px) 100vw, 300px" /></a>we need to move down to the line linux16</p>
<p><a href="https://www.luzem.com/wp-content/uploads/2016/04/edit_grub_centos_7_rd_break.png"><img class="aligncenter size-medium wp-image-4082" src="https://www.luzem.com/wp-content/uploads/2016/04/edit_grub_centos_7_rd_break-300x167.png" alt="edit grub centos linux16" width="300" height="167" srcset="https://www.luzem.com/wp-content/uploads/2016/04/edit_grub_centos_7_rd_break-300x167.png 300w, https://www.luzem.com/wp-content/uploads/2016/04/edit_grub_centos_7_rd_break.png 718w" sizes="(max-width: 300px) 100vw, 300px" /></a>we should append rd.break at the end of line</p>
<p><a href="https://www.luzem.com/wp-content/uploads/2016/04/edit_grub_centos_7_append_rd_break.png"><img class="aligncenter size-medium wp-image-4083" src="https://www.luzem.com/wp-content/uploads/2016/04/edit_grub_centos_7_append_rd_break-300x167.png" alt="edit grub centos 7 append rd.break" width="300" height="167" srcset="https://www.luzem.com/wp-content/uploads/2016/04/edit_grub_centos_7_append_rd_break-300x167.png 300w, https://www.luzem.com/wp-content/uploads/2016/04/edit_grub_centos_7_append_rd_break.png 720w" sizes="(max-width: 300px) 100vw, 300px" /></a>and press Ctrl+X to boot with line modifications.</p>
<p>If we edit all correctly we will have a shell in emergency mode</p>
<p><a href="https://www.luzem.com/wp-content/uploads/2016/04/centos_7_emercy_mode.png"><img class="aligncenter size-medium wp-image-4086" src="https://www.luzem.com/wp-content/uploads/2016/04/centos_7_emercy_mode-300x225.png" alt="centos 7 emergency mode" width="300" height="225" srcset="https://www.luzem.com/wp-content/uploads/2016/04/centos_7_emercy_mode-300x225.png 300w, https://www.luzem.com/wp-content/uploads/2016/04/centos_7_emercy_mode-768x576.png 768w, https://www.luzem.com/wp-content/uploads/2016/04/centos_7_emercy_mode.png 1024w" sizes="(max-width: 300px) 100vw, 300px" /></a>in rescue mode mount point / can be accessed under /sysroot directory, but it&#8217;s on readonly, we need to remount with write permissions.</p>
<blockquote><p>mount -o remount,rw /sysroot</p></blockquote>
<p>afther this we will do a chroot in this dir to access to all commands</p>
<blockquote><p>chroot /sysroot/</p></blockquote>
<p>now we can change root password executing</p>
<blockquote><p>passwd</p></blockquote>
<p><a href="https://www.luzem.com/wp-content/uploads/2016/04/reset_passwd_centos_7_chroot.png"><img class="aligncenter size-medium wp-image-4088" src="https://www.luzem.com/wp-content/uploads/2016/04/reset_passwd_centos_7_chroot-300x223.png" alt="reset_passwd_centos_7_chroot" width="300" height="223" srcset="https://www.luzem.com/wp-content/uploads/2016/04/reset_passwd_centos_7_chroot-300x223.png 300w, https://www.luzem.com/wp-content/uploads/2016/04/reset_passwd_centos_7_chroot-768x571.png 768w, https://www.luzem.com/wp-content/uploads/2016/04/reset_passwd_centos_7_chroot.png 1020w" sizes="(max-width: 300px) 100vw, 300px" /></a>finally we need to force our system to relabel selinux file context because in emergency mode selinux it&#8217;s not enabled</p>
<blockquote><p>touch .autorelabel</p></blockquote>
<p>finally we need to exit from chroot</p>
<blockquote><p>exit</p></blockquote>
<p>and reboot our system to make a normal boot</p>
<blockquote><p>reboot</p></blockquote>
<p>now you should have root access using edited password</p>
]]></content:encoded>
			<wfw:commentRss>https://www.luzem.com/2016/04/24/centos-7-recover-root-password/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Windows 2003 Server Physical to Virt KVM</title>
		<link>https://www.luzem.com/2016/02/16/windows-2003-server-physical-to-virt-kvm/</link>
		<comments>https://www.luzem.com/2016/02/16/windows-2003-server-physical-to-virt-kvm/#respond</comments>
		<pubDate>Mon, 15 Feb 2016 23:04:47 +0000</pubDate>
		<dc:creator><![CDATA[Luzem]]></dc:creator>
				<category><![CDATA[Sistemas Operativos]]></category>
		<category><![CDATA[0x0000007B]]></category>
		<category><![CDATA[kvm]]></category>
		<category><![CDATA[physical to virt]]></category>
		<category><![CDATA[proxmox]]></category>
		<category><![CDATA[windows 2003 server]]></category>

		<guid isPermaLink="false">http://luzem.dyndns.org/?p=4056</guid>
		<description><![CDATA[I&#8217;m not a big fan of windows servers, but sometimes small bussiness have an old computer running an outdated windows server in a more outdated hardware, deal with this systems is not a pleasant experience, old psu and hard disk with a lot of hours are the gates of a  disaster, if you can virtualize &#8230; <p class="link-more"><a href="https://www.luzem.com/2016/02/16/windows-2003-server-physical-to-virt-kvm/" class="more-link">Continue reading<span class="screen-reader-text"> "Windows 2003 Server Physical to Virt KVM"</span></a></p>]]></description>
				<content:encoded><![CDATA[<p>I&#8217;m not a big fan of windows servers, but sometimes small bussiness have an old computer running an outdated windows server in a more outdated hardware, deal with this systems is not a pleasant experience, old psu and hard disk with a lot of hours are the gates of a  disaster, if you can virtualize the OS, you don&#8217;t have to deal with outdated hardware.</p>
<p><a href="https://www.luzem.com/wp-content/uploads/2016/02/mill_cpu_server.jpg" rel="attachment wp-att-4059"><img class="aligncenter size-medium wp-image-4059" src="https://www.luzem.com/wp-content/uploads/2016/02/mill_cpu_server-300x225.jpg" alt="Old Fileserver" width="300" height="225" srcset="https://www.luzem.com/wp-content/uploads/2016/02/mill_cpu_server-300x225.jpg 300w, https://www.luzem.com/wp-content/uploads/2016/02/mill_cpu_server-768x576.jpg 768w, https://www.luzem.com/wp-content/uploads/2016/02/mill_cpu_server.jpg 1024w" sizes="(max-width: 300px) 100vw, 300px" /></a></p>
<p>Virtualization   provides a base hardware where you system can run, and this isolates your os &lt;&#8211;&gt; physical server relationship.</p>
<p>In a recent case I found an old Pentium D executing W2003 in a degraded intel smart raid ( Fake raid controller ), If one hard disk  has died the other one will follow same path.</p>
<p><a href="https://www.luzem.com/wp-content/uploads/2016/02/fake_raid.jpg" rel="attachment wp-att-4061"><img class="aligncenter size-medium wp-image-4061" src="https://www.luzem.com/wp-content/uploads/2016/02/fake_raid-300x300.jpg" alt="fake raid" width="300" height="300" srcset="https://www.luzem.com/wp-content/uploads/2016/02/fake_raid-300x300.jpg 300w, https://www.luzem.com/wp-content/uploads/2016/02/fake_raid-150x150.jpg 150w, https://www.luzem.com/wp-content/uploads/2016/02/fake_raid-768x768.jpg 768w, https://www.luzem.com/wp-content/uploads/2016/02/fake_raid.jpg 1017w" sizes="(max-width: 300px) 100vw, 300px" /></a>unfortunately kvm doesn&#8217;t emulate fake raid controller that means that when you start your virtualized legacy server it will fail showinga blue screen because is searching for a no present controller.</p>
<p><a href="https://www.luzem.com/wp-content/uploads/2016/02/0x0000007B.gif" rel="attachment wp-att-4058"><img class="aligncenter size-medium wp-image-4058" src="https://www.luzem.com/wp-content/uploads/2016/02/0x0000007B-300x123.gif" alt="0x0000007B" width="300" height="123" /></a>this is a big problem you should make some steps to avoid BSOD and another hassles.</p>
<p>First you will need to load all IDE references into windows registry, this step is easy, just donwload  <a href="https://www.luzem.com/wp-content/uploads/2016/02/Mergeide.zip" rel="">Mergeide</a> file, uncompress and open mergeide.reg file (<a href="https://support.microsoft.com/en-us/kb/324103">more info</a>).</p>
<p>If system was installed directly against raid controller you will need to add some files, <span style="text-decoration: underline;"><strong>Atapi.sys, Intelide.sys, Pciide.sys,  Pciidex.sys</strong></span> because aren&#8217;t installed and OS will be unable to connect to IDE devices</p>
<p>these files should be in %SystemRoot%\System32\Drivers folder.</p>
<p>if not, you can get from  %SystemRoot%\Driver Cache\I386\Driver.cab.  Just extract  <span style="text-decoration: underline;"><strong>Atapi.sys, Intelide.sys, Pciide.sys,  Pciidex.sys</strong></span> files on %SystemRoot%\System32\Drivers folder.</p>
<p>Reboot your old server, check that is still working in the old server, and now you can migrate it. Using clonezilla for example.</p>
<p>Good Luck with your migration</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>https://www.luzem.com/2016/02/16/windows-2003-server-physical-to-virt-kvm/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Configure a Centos 7 postfix mail server with virtual users</title>
		<link>https://www.luzem.com/2015/06/20/configure-centos-7-postfix-virtual-users/</link>
		<comments>https://www.luzem.com/2015/06/20/configure-centos-7-postfix-virtual-users/#comments</comments>
		<pubDate>Sat, 20 Jun 2015 00:09:49 +0000</pubDate>
		<dc:creator><![CDATA[Luzem]]></dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[amavis]]></category>
		<category><![CDATA[centos 7]]></category>
		<category><![CDATA[clamav]]></category>
		<category><![CDATA[DKIM]]></category>
		<category><![CDATA[DMARC]]></category>
		<category><![CDATA[dovecot]]></category>
		<category><![CDATA[dovecot SASL]]></category>
		<category><![CDATA[fail2ban]]></category>
		<category><![CDATA[fresclam]]></category>
		<category><![CDATA[IMAP]]></category>
		<category><![CDATA[IMAPS]]></category>
		<category><![CDATA[lmtp]]></category>
		<category><![CDATA[MariaDB]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[nginx]]></category>
		<category><![CDATA[Perfect Forward Secrecy]]></category>
		<category><![CDATA[pfs]]></category>
		<category><![CDATA[POP3]]></category>
		<category><![CDATA[POP3S]]></category>
		<category><![CDATA[postfix]]></category>
		<category><![CDATA[postfixadmin]]></category>
		<category><![CDATA[rhel 7]]></category>
		<category><![CDATA[selinux]]></category>
		<category><![CDATA[sieve]]></category>
		<category><![CDATA[spamassasin]]></category>
		<category><![CDATA[SPF]]></category>
		<category><![CDATA[STARTTLS]]></category>

		<guid isPermaLink="false">http://luzem.dyndns.org/?p=3315</guid>
		<description><![CDATA[Configure a mail server is one of top sysadmins nightmares, here i will try to make your painful  journey a bit less unpleasant. Starting from Centos 7 minimal install. If in any moment something doesn&#8217;t work just leave a comment and i will try to give you some feedback Before run this guide ensure that: &#8230; <p class="link-more"><a href="https://www.luzem.com/2015/06/20/configure-centos-7-postfix-virtual-users/" class="more-link">Continue reading<span class="screen-reader-text"> "Configure a Centos 7 postfix mail server with virtual users"</span></a></p>]]></description>
				<content:encoded><![CDATA[<p>Configure a mail server is one of top sysadmins nightmares, here i will try to make your painful  journey a bit less unpleasant.</p>
<p>Starting from Centos 7 minimal install.</p>
<p><span style="color: #99cc00;">If in any moment something doesn&#8217;t work just leave a comment and i will try to give you some feedback</span></p>
<p>Before run this guide ensure that:</p>
<ul>
<li>Your server has an public ip</li>
<li>Your ISP will configure a reverse dns for your public ip</li>
<li>You can modify DNS records for all domains that you can attach to your new mailserver</li>
</ul>
<p>&nbsp;</p>
<p><strong>Step 1: Enable extra repositories<br />
</strong></p>
<pre class="brush: plain; title: ; notranslate">

yum install epel-release

yum -y install http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm

yum -y update

</pre>
<p><strong>Step 2: install packages</strong></p>
<pre class="brush: plain; title: ; notranslate">

yum -y install perl-MailTools perl-MIME-EncWords perl-Email-Valid perl-Test-Pod roundcubemail dovecot dovecot-mysql  dovecot-pigeonhole  perl-Mail-Sender perl-Log-Log4perl imapsync offlineimap amavisd-new clamav perl-Razor-Agent mariadb-server opendkim vim wget crypto-utils mod_ssl.x86_64 nginx php php-mysql php-fpm  clamav-update php-imap.x86_64 NetworkManager-tui mailx lrzip lzop lz4 arj  unzoo cabextract p7zip fail2ban php-mcrypt.x86_64

</pre>
<pre class="brush: plain; title: ; notranslate">

yum install http://pkgs.repoforge.org/unrar/unrar-5.0.3-1.el7.rf.x86_64.rpm

</pre>
<p><strong>Step 3: Change your servers hostname</strong></p>
<p>To avoid problems with hostname resolution the easy way is use NotworkManager-tui to set you hostname to a FQDN, when you configure your MX registers these point to a hostname, like mail.mydomain.com select your desired FQDN and execute</p>
<pre class="brush: plain; title: ; notranslate">

nmtui

</pre>
<p>this will show nmtui dialog</p>
<p><a href="https://www.luzem.com/wp-content/uploads/2015/03/nmtui_main_screen.png"><img class="aligncenter size-full wp-image-3431" src="https://www.luzem.com/wp-content/uploads/2015/03/nmtui_main_screen.png" alt="nmtui main screen" width="275" height="286" /></a>select Set system hosname</p>
<p><a href="https://www.luzem.com/wp-content/uploads/2015/03/nmtui_set_hostname_dialo.png"><img class="aligncenter size-medium wp-image-3432" src="https://www.luzem.com/wp-content/uploads/2015/03/nmtui_set_hostname_dialo-300x114.png" alt="nmtui set hostname dialog" width="300" height="114" srcset="https://www.luzem.com/wp-content/uploads/2015/03/nmtui_set_hostname_dialo-300x114.png 300w, https://www.luzem.com/wp-content/uploads/2015/03/nmtui_set_hostname_dialo.png 504w" sizes="(max-width: 300px) 100vw, 300px" /></a>put your desired hostname and click OK</p>
<p>finaly exit nmtui</p>
<p>and apply changues</p>
<pre class="brush: plain; title: ; notranslate">

systemctl restart systemd-hostnamed

</pre>
<p><strong>Step 4: Verify postifx local delivery</strong></p>
<p>At this step we will ensure that postfix can send email to local users firstly we will add a two new users joe and alfred</p>
<pre class="brush: plain; title: ; notranslate">

useradd -d /home/joe -M -N -s /sbin/nologin joe

</pre>
<p>we will send a local mail</p>
<pre class="brush: plain; title: ; notranslate">

echo &amp;amp;quot;Hello&amp;amp;quot; | mail -s &amp;amp;quot;test&amp;amp;quot; joe@localhost

</pre>
<p>and verify if mail has been delivered</p>
<pre class="brush: plain; title: ; notranslate">

tail /var/log/maillog

</pre>
<pre class="brush: plain; title: ; notranslate">
May  6 18:57:34 localhost postfix/pickup[1705]: 3D20F1000ED: uid=0 from=&amp;amp;lt;root&amp;amp;gt;
May  6 18:57:34 localhost postfix/cleanup[2444]: 3D20F1000ED: message-id=&amp;amp;lt;20150506165734.3D20F1000ED@mail.yourfqdn.com&amp;amp;gt;
May  6 18:57:34 localhost postfix/qmgr[1706]: 3D20F1000ED: from=&amp;amp;lt;root@mail.yourfqdn.com&amp;amp;gt;, size=494, nrcpt=1 (queue active)
May  6 18:57:34 localhost postfix/local[2446]: 3D20F1000ED: to=&amp;amp;lt;joe@localhost.yourfqdn.com&amp;amp;gt;, orig_to=&amp;amp;lt;joe@localhost&amp;amp;gt;, relay=local, delay=0.11, delays=0.07/0.03/0/0.01, dsn=2.0.0, status=sent (delivered to mailbox)
May  6 18:57:34 localhost postfix/qmgr[1706]: 3D20F1000ED: removed
</pre>
<p>if it&#8217;s delivered next step is add a domain like centostestmail.com</p>
<pre class="brush: plain; title: ; notranslate">

vim /etc/postfix/main.cf

</pre>
<p>edit myhostname property near line 77</p>
<p>myhostname= yourfqdndomain</p>
<p>near line  164</p>
<p>mydestination = $myhostname, localhost.$mydomain, localhost, centostestmail.com</p>
<p>finaly execute</p>
<pre class="brush: plain; title: ; notranslate">

systemctl restart postfix.service

</pre>
<p>verify that postfix is running</p>
<pre class="brush: plain; title: ; notranslate">

systemctl status postfix.service

</pre>
<p>if postfix is running we will verify if postfix delivers mail to adress with domain centostestmail.com</p>
<pre class="brush: plain; title: ; notranslate">

echo &amp;amp;quot;Hello&amp;amp;quot; | mail -s &amp;amp;quot;test&amp;amp;quot; joe@centostestmail.com

</pre>
<p>verify if mail has been delivered</p>
<pre class="brush: plain; title: ; notranslate">

tail /var/log/maillog

</pre>
<pre class="brush: plain; title: ; notranslate">
ay  6 19:58:01 mail postfix/pickup[2818]: 9AC9D10025A: uid=0 from=&amp;amp;lt;root&amp;amp;gt;
May  6 19:58:01 mail postfix/cleanup[2829]: 9AC9D10025A: message-id=&amp;amp;lt;20150506175801.9AC9D10025A@mail.yourfqdn.com&amp;amp;gt;
May  6 19:58:01 mail postfix/qmgr[2819]: 9AC9D10025A: from=&amp;amp;lt;root@mail.yourfqdn.com&amp;amp;gt;, size=459, nrcpt=1 (queue active)
May  6 19:58:01 mail postfix/local[2831]: 9AC9D10025A: to=&amp;amp;lt;joe@centostestmail.com&amp;amp;gt;, relay=local, delay=0.14, delays=0.1/0.04/0/0.01, dsn=2.0.0, status=sent (delivered to mailbox)
May  6 19:58:01 mail postfix/qmgr[2819]: 9AC9D10025A: removed
</pre>
<p>if your log appears like example we can move to the next step</p>
<p><strong>Step 5: Configure Clam Antivirus</strong></p>
<p>If you want to run a mail server you will be a happy sysadmin if you put an antivirus inspecting incoming mail.  Minimize viruses risk is a plus. In my case I will use clam.</p>
<pre class="brush: plain; title: ; notranslate">

setsebool -P antivirus_use_jit on

</pre>
<p>we need to configure how clam refreshes his database</p>
<pre class="brush: plain; title: ; notranslate">

vim /etc/sysconfig/freshclam

</pre>
<p>comment or remove last line</p>
<pre class="brush: plain; title: ; notranslate">
#  FRESHCLAM_DELAY=disabled-warn    # REMOVE ME
</pre>
<p>now we will make a edit clamav config file</p>
<pre class="brush: plain; title: ; notranslate">

vim /etc/freshclam.conf

</pre>
<p>remove the line that puts</p>
<p>example</p>
<p>finally update your viruses database</p>
<pre class="brush: plain; title: ; notranslate">

freshclam

</pre>
<p>after we get an updated antivirus we should check if it&#8217;s working as expected for these purposes there&#8217;s a string called EICAR that should be detected as a virus always.</p>
<p>download EICAR string</p>
<pre class="brush: plain; title: ; notranslate">

wget  http://www.eicar.org/download/eicar.com

</pre>
<p>analyze EICAR string</p>
<pre class="brush: plain; title: ; notranslate">

clamscan --infected --remove eicar.com

</pre>
<p>output should be like these</p>
<pre class="brush: plain; title: ; notranslate">
eicar.com: Eicar-Test-Signature FOUND
eicar.com: Removed.

----------- SCAN SUMMARY -----------
Known viruses: 3802265
Engine version: 0.98.6
Scanned directories: 0
Scanned files: 1
Infected files: 1
Data scanned: 0.00 MB
Data read: 0.00 MB (ratio 0.00:1)
Time: 27.957 sec (0 m 27 s)

</pre>
<p><strong>Step 6: Configure basic settings in spamassasin</strong></p>
<p>At this point we have an antivirus in our server that is&#8217;s updated every 3 hours, viruses is a problem for our users but the BIG problem is spam, most of your users incoming mail will be spam, and our users will complaining about that they can work because lost his precious time removing spam in his incoming mail, another part will be losing her time buying magical blue pills, expensive watches and helping African kings moving her money outside Africa.</p>
<p>Anyway first step is configure selinux</p>
<pre class="brush: plain; title: ; notranslate">

setsebool -P spamassassin_can_network on

</pre>
<p>enable spamassasin service</p>
<pre class="brush: plain; title: ; notranslate">

systemctl start spamassassin.service
systemctl status spamassassin.service
systemctl enable spamassassin.service

</pre>
<p>update spamassasin definitions</p>
<pre class="brush: plain; title: ; notranslate">

sa-update

</pre>
<p>a cron task is added when you install spamassin that will update spamassasin definitions is located at  /etc/cron.d/sa-update</p>
<p><strong>Step 7: Integrate spamassasin and clamav with amavisd</strong></p>
<p>At this point clamav and spamassasin are isolated services for integrate these elements we will use amavisd he will be responsive of deliver mails in order of get a virus and spam check.</p>
<p>Clamav is not a lightweight service instead launch a local copy for every mail, we load a service to be ready faster.</p>
<p>we need to provide some config files</p>
<pre class="brush: plain; title: ; notranslate">

cp /usr/share/doc/clamav-server*/clamd.sysconfig /etc/sysconfig/clamd.amavisd

</pre>
<p>we need to adapt config file to our actual configuration</p>
<pre class="brush: plain; title: ; notranslate">

vi /etc/sysconfig/clamd.amavisd

</pre>
<pre class="brush: plain; title: ; notranslate">
CLAMD_CONFIGFILE=/etc/clamd.d/amavisd.conf
CLAMD_SOCKET=/var/run/clamd.amavisd/clamd.sock
</pre>
<p>we will create a couple of new files</p>
<pre class="brush: plain; title: ; notranslate">

vi /etc/tmpfiles.d/clamd.amavisd.conf

</pre>
<p>add this content</p>
<pre class="brush: plain; title: ; notranslate">
d /var/run/clamd.amavisd 0755 amavis amavis -
</pre>
<pre class="brush: plain; title: ; notranslate">

vi /usr/lib/systemd/system/clamd@.service

</pre>
<p>with this content</p>
<pre class="brush: plain; title: ; notranslate">
[Unit]
Description = clamd scanner (%i) daemon
After = syslog.target nss-lookup.target network.target
[Service]
Type = simple
ExecStart = /usr/sbin/clamd -c /etc/clamd.d/%i.conf --nofork=yes
Restart = on-failure
PrivateTmp = true
[Install]
WantedBy=multi-user.target
</pre>
<p>now we can enable clamd@amavisd service</p>
<pre class="brush: plain; title: ; notranslate">

systemctl start clamd@amavisd

systemctl enable clamd@amavisd

</pre>
<p>now we need configure amavisd service</p>
<pre class="brush: plain; title: ; notranslate">

vim /etc/amavisd/amavisd.conf

</pre>
<p>at line 16 set number of amavisd childrens</p>
<p>more childres uses more ram but delivers more mail at once, one amavisd children consumes near 40% of cpu in a low end server, be careful if you receive a lot of mails at once can be a big punch in your cpu have too many childrens</p>
<p>$max_servers = &lt;a number&gt;</p>
<p>at line 20 set $mydomain we need to put step 3 domain name</p>
<p>$mydomain = &#8216;desireddomain.com&#8217;;</p>
<p>at line 152 aprox set your hostname</p>
<p>$myhostname= &#8216;mail.desireddomain.com&#8217;;</p>
<pre class="brush: plain; title: ; notranslate">

systemctl start amavisd.service

</pre>
<p>after this we must search in file /var/log/maillog strings like these</p>
<p>Mar 19 17:51:48 mail amavis[21284]: ANTI-SPAM-SA code    loaded</p>
<p>Mar 19 17:51:48 mail amavis[21284]: Using primary internal av scanner code for ClamAV-clamd</p>
<p>to ensure that amavisd detects our antivirus and spamassasin</p>
<p>next step is enable service</p>
<pre class="brush: plain; title: ; notranslate">

systemctl enable amavisd.service

</pre>
<p><strong>Step 8:Integrate postfix with amavisd</strong></p>
<p>Amavisd will pass all incoming mail to our antivirus and antispam and verify that we are receiving a clean mail, but at this moment we have postfix and amavisd isolated, we need make a small integration.</p>
<pre class="brush: plain; title: ; notranslate">

vim /etc/postfix/main.cf

</pre>
<p>append this line at the end</p>
<pre class="brush: plain; title: ; notranslate">
content_filter=smtp-amavis:[127.0.0.1]:10024
</pre>
<pre class="brush: plain; title: ; notranslate">

vim /etc/postfix/master.cf

</pre>
<p>append these lines at the end</p>
<pre class="brush: plain; title: ; notranslate">
smtp-amavis unix -      -       n       -       6       smtp
        -o smtp_data_done_timeout=1200
        -o smtp_send_xforward_command=yes
        -o disable_dns_lookups=yes
127.0.0.1:10025 inet n  -       n      -        -       smtpd
        -o content_filter=
        -o local_recipient_maps=
        -o relay_recipient_maps=
        -o smtpd_restriction_classes=
        -o smtpd_client_restrictions=
        -o smtpd_helo_restrictions=
        -o smtpd_sender_restrictions=
        -o smtpd_recipient_restrictions=permit_mynetworks,reject
        -o mynetworks=127.0.0.0/8
        -o strict_rfc821_envelopes=yes
        -o smtpd_error_sleep_time=0
        -o smtpd_soft_error_limit=1001
        -o smtpd_hard_error_limit=1000
</pre>
<p>&nbsp;</p>
<p>in line smtp-avavis unix &#8211; &#8211; n &#8211; &lt;number&gt; smtp</p>
<p>try that number value be the same that amavisd children</p>
<p>restart postfix service</p>
<pre class="brush: plain; title: ; notranslate">

systemctl stop postfix.service

systemctl start postfix.service

</pre>
<p>now we need to check that our  postfix and amavisd service are integrated, the easy way is send an spam mail and a virus mail, one with gtube string another with eicar</p>
<p>we need to put EICAR and GTUBE strings in a mail.</p>
<p><a title="EICAR string" href="http://www.eicar.org/86-0-Intended-use.html" target="_blank">EICAR String</a></p>
<p><a title="Gtube String" href="http://spamassassin.apache.org/gtube/" target="_blank">Gtube String</a></p>
<p><a href="https://www.luzem.com/wp-content/uploads/2015/03/test_spam_virus_mail.png"><img class="aligncenter wp-image-3495 size-large" src="https://www.luzem.com/wp-content/uploads/2015/03/test_spam_virus_mail-1024x36.png" alt="test spam and virus mail" width="660" height="23" srcset="https://www.luzem.com/wp-content/uploads/2015/03/test_spam_virus_mail-1024x36.png 1024w, https://www.luzem.com/wp-content/uploads/2015/03/test_spam_virus_mail-300x11.png 300w, https://www.luzem.com/wp-content/uploads/2015/03/test_spam_virus_mail.png 1126w" sizes="(max-width: 660px) 100vw, 660px" /></a></p>
<p>after send this couple of test you need to check in /var/log/maillog and output like these</p>
<pre class="brush: plain; title: ; notranslate">
May  7 00:20:14 mail postfix/pickup[4434]: 578BA100322: uid=0 from=&amp;amp;lt;root&amp;amp;gt;
May  7 00:20:14 mail postfix/cleanup[4458]: 578BA100322: message-id=&amp;amp;lt;20150506222014.578BA100322@mail.yourfqdn.com&amp;amp;gt;
May  7 00:20:14 mail postfix/qmgr[4435]: 578BA100322: from=&amp;amp;lt;root@mail.yourfqdn.com&amp;amp;gt;, size=527, nrcpt=1 (queue active)
May  7 00:20:15 mail amavis[2388]: (02388-02) Blocked SPAM {DiscardedOpenRelay,Quarantined}, &amp;amp;lt;root@mail.yourfqdn.com&amp;amp;gt; -&amp;amp;gt; &amp;amp;lt;joe@centostestmail.com&amp;amp;gt;, Message-ID: &amp;amp;lt;20150506222014.578BA100322@mail.yourfqdn.com&amp;amp;gt;, mail_id: TcgB4ovK5t1h, Hits: 999.999, size: 527, 1596 ms
May  7 00:20:15 mail postfix/smtp[4460]: 578BA100322: to=&amp;amp;lt;joe@centostestmail.com&amp;amp;gt;, relay=127.0.0.1[127.0.0.1]:10024, delay=1.6, delays=0.03/0/0.01/1.6, dsn=2.7.0, status=sent (250 2.7.0 Ok, discarded, id=02388-02 - spam)
May  7 00:20:15 mail postfix/qmgr[4435]: 578BA100322: removed
May  7 00:20:22 mail postfix/pickup[4434]: 4D335100323: uid=0 from=&amp;amp;lt;root&amp;amp;gt;
May  7 00:20:22 mail postfix/cleanup[4458]: 4D335100323: message-id=&amp;amp;lt;20150506222022.4D335100323@mail.yourfqdn.com&amp;amp;gt;
May  7 00:20:22 mail postfix/qmgr[4435]: 4D335100323: from=&amp;amp;lt;root@mail.yourfqdn.com&amp;amp;gt;, size=527, nrcpt=1 (queue active)
May  7 00:20:22 mail clamd[1084]: /var/spool/amavisd/tmp/amavis-20150507T001929-02391-G5h5_dlo/parts/p002: Eicar-Test-Signature FOUND
May  7 00:20:22 mail clamd[1084]: /var/spool/amavisd/tmp/amavis-20150507T001929-02391-G5h5_dlo/parts/p001: Eicar-Test-Signature FOUND
May  7 00:20:22 mail amavis[2391]: (02391-02) Blocked INFECTED (Eicar-Test-Signature) {DiscardedOpenRelay,Quarantined}, &amp;amp;lt;root@mail.yourfqdn.com&amp;amp;gt; -&amp;amp;gt; &amp;amp;lt;joe@centostestmail.com&amp;amp;gt;, Message-ID: &amp;amp;lt;20150506222022.4D335100323@mail.yourfqdn.com&amp;amp;gt;, mail_id: yIy3drLObXjq, Hits: -, size: 527, 134 ms
May  7 00:20:22 mail postfix/smtp[4460]: 4D335100323: to=&amp;amp;lt;joe@centostestmail.com&amp;amp;gt;, relay=127.0.0.1[127.0.0.1]:10024, delay=0.16, delays=0.02/0/0.01/0.13, dsn=2.7.0, status=sent (250 2.7.0 Ok, discarded, id=02391-02 - INFECTED: Eicar-Test-Signature)
May  7 00:20:22 mail postfix/qmgr[4435]: 4D335100323: removed
</pre>
<p><strong>Step 9: Configure mariadb</strong></p>
<p>At this point we have a working postfix mail server with antivirus and antispam, at this point we can add local user accounts and they will get a mail account. But i prefer to have all users in a database and foget to have hundreds of accounts</p>
<pre class="brush: plain; title: ; notranslate">

vim /etc/my.cnf.d/server.cnf

</pre>
<pre class="brush: plain; title: ; notranslate">
#
# These groups are read by MariaDB server.
# Use it for options that only the server (but not clients) should see
#
# See the examples of server my.cnf files in /usr/share/mysql/
#

# this is read by the standalone daemon and embedded servers
[server]
innodb_file_per_table
innodb_file_format = Barracuda
# this is only for the mysqld standalone daemon
[mysqld]

# this is only for embedded server
[embedded]

# This group is only read by MariaDB-5.5 servers.
# If you use the same .cnf file for MariaDB of different versions,
# use this group for options that older servers don't understand
[mysqld-5.5]

# These two groups are only read by MariaDB servers, not by MySQL.
# If you use the same .cnf file for MySQL and MariaDB,
# you can put MariaDB-only options here
[mariadb]

[mariadb-5.5]

</pre>
<p>enable mariadb service</p>
<pre class="brush: plain; title: ; notranslate">

systemctl  enable mariadb.service

</pre>
<p>Start mariadb database server</p>
<pre class="brush: plain; title: ; notranslate">

systemctl  start mariadb.service

</pre>
<p>secure mariadb installation</p>
<pre class="brush: plain; title: ; notranslate">

mysql_secure_installation

</pre>
<p>follow screen instructions</p>
<p>Optional: if you will need access to database open port using this command</p>
<pre class="brush: plain; title: ; notranslate">

firewall-cmd --permanent --add-service=mysql
firewall-cmd --reload

</pre>
<p>Remember configure a backup script for your database</p>
<p><strong>Step 10: Generate SSL Certificate</strong></p>
<pre class="brush: plain; title: ; notranslate">

genkey --days 3650 mail.yourdamain.com

</pre>
<p>follow on screen instructions and this will generate two files.</p>
<p>private part of certificate at</p>
<p>/etc/pki/tls/certs/mail.yourdomain.com.0.csr</p>
<p>and public part of certificate at</p>
<p>/etc/pki/tls/private/mail.yourdomain.com.key</p>
<p>you should get your certificate signed by a certification autority search for one pay and follor certification authority instructions <img src="https://s.w.org/images/core/emoji/2.2.1/72x72/1f641.png" alt="🙁" class="wp-smiley" style="height: 1em; max-height: 1em;" /></p>
<p><strong>Step 11: Create a user account and a folder were store  mails</strong></p>
<pre class="brush: plain; title: ; notranslate">

mkdir /var/vmail

chmod 770 /var/vmail/

useradd -r -u 101 -g mail -d /var/vmail/ -s /sbin/nologin -c &amp;amp;quot;Virtual Mailbox&amp;amp;quot; vmail

chown vmail:mail /var/vmail/

</pre>
<p><strong>Step 12: Configure nginx</strong></p>
<p>Fist step is verify that nginx server is installed and working</p>
<pre class="brush: plain; title: ; notranslate">

systemctl enable nginx.service
systemctl start nginx.service

firewall-cmd --permanent --zone=public --add-service=http
firewall-cmd --permanent --zone=public --add-service=https
firewall-cmd --reload

</pre>
<p>select your favorite webbrowser and navigate to your server ip</p>
<p>you should see something like this</p>
<p><a href="https://www.luzem.com/wp-content/uploads/2014/10/welcome_nginx.png"><img class="aligncenter size-medium wp-image-3126" src="https://www.luzem.com/wp-content/uploads/2014/10/welcome_nginx-300x106.png" alt="welcome nginx" width="300" height="106" srcset="https://www.luzem.com/wp-content/uploads/2014/10/welcome_nginx-300x106.png 300w, https://www.luzem.com/wp-content/uploads/2014/10/welcome_nginx.png 557w" sizes="(max-width: 300px) 100vw, 300px" /></a></p>
<p><strong>Step 13: Configure php</strong></p>
<pre class="brush: plain; title: ; notranslate">

vim  /etc/php.ini

</pre>
<p>line 763 should be</p>
<p>cgi.fix_pathinfo=0</p>
<p>line 878 should be your timezone</p>
<p>search here <a href="http://php.net/manual/en/timezones.php">http://php.net/manual/en/timezones.php</a></p>
<p>date.timezone = Continent/Country</p>
<p><strong>Step 14: Configure PostfixAdmin</strong></p>
<p>in my case i will create a domain like mailadmin.yourdomain.com</p>
<p>we have to download postfixadmin</p>
<pre class="brush: plain; title: ; notranslate">

wget http://downloads.sourceforge.net/project/postfixadmin/postfixadmin/postfixadmin-2.92/postfixadmin-2.92.tar.gz

</pre>
<p>and move to a valid ubication</p>
<pre class="brush: plain; title: ; notranslate">

mv postfixadmin-2.92.tar.gz /var/www

cd /var/www

tar xzvf postfixadmin-2.92.tar.gz

rm postfixadmin-2.92.tar.gz

mv postfixadmin-2.92/ postfixadmin.yourdomain.com

chown -R  nginx:nginx postfixadmin.yourdomain.com

mkdir /var/lib/php/postfixadmin.yourdomain.com

</pre>
<p>disable php-fpm default socket</p>
<pre class="brush: plain; title: ; notranslate">

mv  /etc/php-fpm.d/www.conf /etc/php-fpm.d/www.conf.dis

</pre>
<p>create a php-fpm postfixadmin socket</p>
<pre class="brush: plain; title: ; notranslate">

vim /etc/php-fpm.d/postfixadmin.yourdomain.com.conf

</pre>
<pre class="brush: plain; title: ; notranslate">
[postfixadmin.yourdomain.com]
listen = /var/run/php-fpm/postfixadmin.yourdomain.com.socket
listen.allowed_clients = 127.0.0.1
user = nginx
group = nginx
pm = dynamic
pm.max_children = 50
pm.start_servers = 5
pm.min_spare_servers = 3
pm.max_spare_servers = 35
slowlog = /var/log/php-fpm/postfixadmin.log
rlimit_files = 1024
rlimit_core = 0
chdir = /var/www/postfixadmin.yourdomain.com
php_flag[display_errors] = off
php_admin_value[error_log] = /var/log/php-fpm/postfixadmin.yourdomain.com-error.log
php_admin_flag[log_errors] = on
php_admin_value[memory_limit] = 128M
php_value[session.save_handler] = files
php_value[session.save_path] = /var/lib/php/postfixadmin.yourdomain.com
</pre>
<p>start php-fpm service</p>
<pre class="brush: plain; title: ; notranslate">

systemctl start  php-fpm.service

</pre>
<p>check if php-fpm has started</p>
<pre class="brush: plain; title: ; notranslate">

systemctl status  php-fpm.service

</pre>
<p>output should appear like these</p>
<pre class="brush: plain; title: ; notranslate">
php-fpm.service - The PHP FastCGI Process Manager
   Loaded: loaded (/usr/lib/systemd/system/php-fpm.service; disabled)
   Active: active (running) since Thu 2015-05-07 00:52:05 CEST; 2s ago
 Main PID: 5499 (php-fpm)
   Status: ;Ready to handle connections;
   CGroup: /system.slice/php-fpm.service
           ├─5499 php-fpm: master process (/etc/php-fpm.conf)
           ├─5501 php-fpm: pool postfixadmin.yourdomain.com
           ├─5502 php-fpm: pool postfixadmin.yourdomain.com
           ├─5503 php-fpm: pool postfixadmin.yourdomain.com
           ├─5504 php-fpm: pool postfixadmin.yourdomain.com
           └─5505 php-fpm: pool postfixadmin.yourdomain.com

May 07 00:52:05 yourfqdn systemd[1]: Started The PHP FastCGI Process Manager.

</pre>
<p>enable php-fpm service to start at boot</p>
<pre class="brush: plain; title: ; notranslate">

systemctl enable  php-fpm.service

</pre>
<p>Next we need to create postfix user database from a shell execute:</p>
<pre class="brush: plain; title: ; notranslate">

mysql -u root -p -e &amp;amp;quot;CREATE DATABASE postfix;&amp;amp;quot;

mysql -u root -p -e &amp;amp;quot;CREATE USER postfix@localhost IDENTIFIED BY 'put_here_your_password';&amp;amp;quot;

mysql -u root -p -e &amp;amp;quot;GRANT ALL PRIVILEGES ON postfix . * TO postfix@localhost;&amp;amp;quot;

</pre>
<p>at this point we need to create a host for postfixadmin in nginx</p>
<p>I will use a selfsigned certificate for https you can pay a certification authority to bypass bad certificate errors in your browser</p>
<pre class="brush: plain; title: ; notranslate">

genkey --days 3650 postfixadmin.yourdomain.com

</pre>
<p>follow screen instructions, if you put a password in your keys every time that you reboot your system you will need to put that</p>
<p><em><span style="color: #99cc00;">trick- collecting random data could take a lot of time, to acelerate this process you can dowload a linux distro iso to acelerate this process, it reads data from network card</span></em></p>
<pre class="brush: plain; title: ; notranslate">

vim /etc/nginx/conf.d/put_here_your_postfixadmin_domain.conf

</pre>
<p>&nbsp;</p>
<pre class="brush: plain; title: ; notranslate">
server {

  listen 80;
  server_name postfixadmin.yourfqdn.com;
  error_log  /var/log/nginx/postfixadmin.yourfqdn.com.error.log warn;
  access_log  /var/log/nginx/postfixadmin.yourfqdn.com.access.log;

  return 301 https://$server_name$request_uri; # enforce https

}

server {

   listen          443 ssl;
   server_name     postfixadmin.yourfqdn.com;

 error_log /var/log/nginx/postfixadmin.yourfqdn.com.secure.error.log warn;
 access_log /var/log/nginx/postfixadmin.yourfqdn.com.secure.access.log;
   root            /var/www/postfixadmin.yourfqdn.com;
   index           index.php;
   charset         utf-8;

   ## SSL settings
   ssl_certificate           //etc/pki/tls/certs/postfixadmin.yourfqdn.com.crt;
   ssl_certificate_key       /etc/pki/tls/private/postfixadmin.yourfqdn.com.key;
   ssl_protocols             TLSv1.2;
   ssl_ciphers               &amp;amp;quot;EECDH+ECDSA+AESGCM:EECDH+aRSA+AESGCM:!aNULL:!eNULL:!LOW:!3DES:!MD5:!EXP:!PSK:!SRP:!DSS:!RC4&amp;amp;quot;;
   ssl_prefer_server_ciphers on;
   ssl_session_cache         shared:SSL:10m;
   ssl_session_timeout       10m;
   ssl_ecdh_curve            secp521r1;

   add_header Strict-Transport-Security max-age=31536000;
   # add_header X-Frame-Options DENY;

   # auth_basic &amp;amp;quot;Restricted area&amp;amp;quot;;
   # auth_basic_user_file /etc/nginx/passwd;

   location / {
      try_files $uri $uri/ index.php;
   }

   location ~* \.php$ {
        try_files $uri =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        include       fastcgi_params;
        fastcgi_pass  unix:/var/run/php-fpm/postfixadmin.yourfqdn.com.socket;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
   }

}

</pre>
<p style="text-align: center;"><span style="text-decoration: underline;"><span style="color: #ff0000; text-decoration: underline;"><strong> </strong></span></span></p>
<p>we need to allow in selinux communication between nginx and php-fpm</p>
<pre class="brush: plain; title: ; notranslate">

setsebool -P httpd_can_network_connect on

</pre>
<p>and allow selinux that permits nginx to write files in server</p>
<pre class="brush: plain; title: ; notranslate">

setsebool -P httpd_unified on

</pre>
<p>and allow php-fpm to write session files</p>
<pre class="brush: plain; title: ; notranslate">

chown nginx:nginx /var/lib/php/postfixadmin.yourdomain.com

</pre>
<p>now configure postfixadmin parameters</p>
<pre class="brush: plain; title: ; notranslate">

vim /var/www/postfixadmin.yourdomain.com/config.inc.php

</pre>
<p>it&#8217;s self explanatory but you will need to changue these parameters</p>
<pre class="brush: php; title: ; notranslate">

$CONF['configured'] = true;

$CONF['setup_password'] = 'puthereastrongpassword';

$CONF['database_type'] = 'mysqli';
$CONF['database_host'] = 'localhost';
$CONF['database_user'] = 'postfix';
$CONF['database_password'] = 'yourpassword';
$CONF['database_name'] = 'postfix';

$CONF['emailcheck_resolve_domain']='NO';

$CONF['default_aliases'] = array (
    'abuse' =&amp;amp;gt; 'abuse@amaindomainthatyouwilluse.com',
    'hostmaster' =&amp;amp;gt; 'hostmaster@amaindomainthatyouwilluse.com',
    'postmaster' =&amp;amp;gt; 'postmaster@amaindomainthatyouwilluse.com',
    'webmaster' =&amp;amp;gt; 'webmaster@amaindomainthatyouwilluse.com'
);

</pre>
<p>we will need restart nginx again to enable postfixadmin site</p>
<pre class="brush: plain; title: ; notranslate">

systemctl restart nginx.service

</pre>
<p>now we can setup our postfixadmin instance</p>
<p>open in your browser</p>
<p>https://postfixadmin.yourdomain.com/setup.php</p>
<p><a href="https://www.luzem.com/wp-content/uploads/2015/05/postfixadmin_setup.png"><img class="aligncenter size-medium wp-image-3810" src="https://www.luzem.com/wp-content/uploads/2015/05/postfixadmin_setup-300x150.png" alt="postfixadmin setup" width="300" height="150" srcset="https://www.luzem.com/wp-content/uploads/2015/05/postfixadmin_setup-300x150.png 300w, https://www.luzem.com/wp-content/uploads/2015/05/postfixadmin_setup.png 589w" sizes="(max-width: 300px) 100vw, 300px" /></a>fill all data and follow instructions</p>
<p>finally access to  https://postfixadmin.yourdomain.com and login in order to configure your domains</p>
<p><a href="https://www.luzem.com/wp-content/uploads/2015/05/postfixadmin_main_screen.png"><img class="aligncenter size-medium wp-image-3813" src="https://www.luzem.com/wp-content/uploads/2015/05/postfixadmin_main_screen-300x168.png" alt="postfixadmin main screen" width="300" height="168" srcset="https://www.luzem.com/wp-content/uploads/2015/05/postfixadmin_main_screen-300x168.png 300w, https://www.luzem.com/wp-content/uploads/2015/05/postfixadmin_main_screen.png 587w" sizes="(max-width: 300px) 100vw, 300px" /></a></p>
<p>we will create one test domain like newcentostestmail.com</p>
<p>in tab Domain List we will select new domain</p>
<p><a href="https://www.luzem.com/wp-content/uploads/2015/05/postixadmin_add_domain.png"><img class="aligncenter size-medium wp-image-3815" src="https://www.luzem.com/wp-content/uploads/2015/05/postixadmin_add_domain-300x262.png" alt="postixadmin add domain" width="300" height="262" srcset="https://www.luzem.com/wp-content/uploads/2015/05/postixadmin_add_domain-300x262.png 300w, https://www.luzem.com/wp-content/uploads/2015/05/postixadmin_add_domain.png 636w" sizes="(max-width: 300px) 100vw, 300px" /></a>after add new domain we will create a mailbox</p>
<p>go to Domain List -&gt; Domain List</p>
<p>click on newcentostestmail.com</p>
<p>an Add Mailbox and create joe@newcentostestmail.com mailbox</p>
<p><a href="https://www.luzem.com/wp-content/uploads/2015/05/postfixadmin_create_mailbox.png"><img class="aligncenter size-medium wp-image-3818" src="https://www.luzem.com/wp-content/uploads/2015/05/postfixadmin_create_mailbox-300x289.png" alt="postfixadmin create mailbox" width="300" height="289" srcset="https://www.luzem.com/wp-content/uploads/2015/05/postfixadmin_create_mailbox-300x289.png 300w, https://www.luzem.com/wp-content/uploads/2015/05/postfixadmin_create_mailbox.png 570w" sizes="(max-width: 300px) 100vw, 300px" /></a>finally we have created a mailbox we need to link our database with postfix</p>
<p><strong>step 15: Cleanup some test config</strong></p>
<p>Do you want to have a user in your system called joe? you don&#8217;t</p>
<pre class="brush: plain; title: ; notranslate">

userdel joe

</pre>
<p>Do you want map mails from @centostestmail.com? neither</p>
<p>remove centostestmail.com from mydestination values</p>
<pre class="brush: plain; title: ; notranslate">

vim /etc/postfix/main.cf

</pre>
<p>at line 164 approx leave these values for mydestination</p>
<pre class="brush: plain; title: ; notranslate">
mydestination = $myhostname, localhost.$mydomain, localhost
</pre>
<p>restart postfix</p>
<pre class="brush: plain; title: ; notranslate">

systemctl restart postfix

</pre>
<p><strong>step 16: Connect postfix with mariadb:</strong></p>
<p>we have a database that contains a domain list and and a list of emails we need that postfix can access to database in order to read all data</p>
<p>because postfix and other components only will need read permisions we will create a only read user</p>
<pre class="brush: plain; title: ; notranslate">

mysql -u root -p -e &amp;amp;quot;CREATE USER postfixread@localhost IDENTIFIED BY 'put_here_your_password';&amp;amp;quot;

mysql -u root -p -e &amp;amp;quot;GRANT SELECT ON postfix . * TO postfixread@localhost ;&amp;amp;quot;

</pre>
<p>we will need to link three elements domains, mailboxes and aliases</p>
<p>we will start with domains</p>
<pre class="brush: plain; title: ; notranslate">

vim /etc/postfix/mysql-virtual_domains_maps.cf

</pre>
<p>using this content</p>
<pre class="brush: plain; title: ; notranslate">
hosts = localhost
user = postfixread
password = put_here_your_password
dbname = postfix
query = SELECT domain FROM domain WHERE domain='%s' AND backupmx = '0' AND active = '1'
</pre>
<pre class="brush: plain; title: ; notranslate">

vim /etc/postfix/mysql-relay_domains_maps.cf

</pre>
<p>using this content</p>
<pre class="brush: plain; title: ; notranslate">
hosts = localhost
user = postfixread
password = put_here_your_password
dbname = postfix
query = SELECT domain FROM domain WHERE domain='%s' and backupmx = '1'
</pre>
<p>next step are mailboxes</p>
<pre class="brush: plain; title: ; notranslate">

vim /etc/postfix/mysql-virtual_mailbox_maps.cf

</pre>
<p>with this content</p>
<pre class="brush: plain; title: ; notranslate">
hosts = localhost
user = postfixread
password = put_here_your_password
dbname = postfix
query = SELECT maildir FROM mailbox WHERE username='%s' AND active = '1'
</pre>
<pre class="brush: plain; title: ; notranslate">

vim /etc/postfix/mysql-virtual_mailbox_limit_maps.cf

</pre>
<pre class="brush: plain; title: ; notranslate">
hosts = localhost
user = postfixread
password = put_here_your_password
dbname = postfix
query = SELECT quota FROM mailbox WHERE username='%s' and active=1
</pre>
<p>and finally we need to configure aliases</p>
<pre class="brush: plain; title: ; notranslate">

vim /etc/postfix/mysql-virtual_alias_maps.cf

</pre>
<pre class="brush: plain; title: ; notranslate">
hosts = localhost
user = postfixread
password = put_here_your_password
dbname = postfix
query = SELECT goto FROM alias WHERE address='%s' AND active = '1'
</pre>
<p>now we need to link our sql queries with postfix config file</p>
<pre class="brush: plain; title: ; notranslate">

vim /etc/postfix/main.cf

</pre>
<p>at line 297 we need to paste this</p>
<pre class="brush: plain; title: ; notranslate">
relay_domains = proxy:mysql:/etc/postfix/mysql-relay_domains_maps.cf
</pre>
<p>at line 399 we need to paste this,</p>
<pre class="brush: plain; title: ; notranslate">
virtual_alias_maps = proxy:mysql:/etc/postfix/mysql-virtual_alias_maps.cf,
                     regexp:/etc/postfix/virtual_regexp
virtual_mailbox_base = /var/vmail
virtual_mailbox_domains = proxy:mysql:/etc/postfix/mysql-virtual_domains_maps.cf
virtual_mailbox_maps = proxy:mysql:/etc/postfix/mysql-virtual_mailbox_maps.cf
virtual_mailbox_limit_maps = proxy:mysql:/etc/postfix/mysql-virtual_mailbox_limit_maps.cf
virtual_minimum_uid = 101
virtual_uid_maps = static:101
virtual_gid_maps = static:12

proxy_read_maps = $local_recipient_maps $mydestination $virtual_alias_maps $virtual_alias_domains $virtual_mailbox_maps $virtual_mailbox_domains $relay_recipient_maps $relay_domains $canonical_maps $sender_canonical_maps $recipient_canonical_maps $relocated_maps $transport_maps $mynetworks $smtpd_sender_login_maps $sender_bcc_maps $recipient_bcc_maps $smtp_generic_maps $lmtp_generic_maps $alias_maps $virtual_mailbox_limit_maps
</pre>
<p>finally we need to create virtual_regexp file</p>
<pre class="brush: plain; title: ; notranslate">

touch /etc/postfix/virtual_regexp

</pre>
<p>if we restart postfix no problems should appear</p>
<pre class="brush: plain; title: ; notranslate">

systemctl restart postfix.service

</pre>
<p>if we check our maillog file</p>
<pre class="brush: plain; title: ; notranslate">

tail -f /var/log/maillog

</pre>
<p>we should see something like this</p>
<pre class="brush: plain; title: ; notranslate">
May  9 17:07:56 mail postfix/postfix-script[2967]: starting the Postfix mail system
May  9 17:07:56 mail postfix/master[2969]: daemon started -- version 2.10.1, configuration /etc/postfix
</pre>
<p>postfix has started and aparently it has been linked to our database but it&#8217;s better verify this</p>
<p>for this we will use postfixadmin but before we need to allow write in our virtual mail storage folder because our directory is not labeled</p>
<pre class="brush: plain; title: ; notranslate">

chcon -R -t mail_spool_t /var/vmail

</pre>
<p>now we will send a test email to a created mailbox in postfixadmin</p>
<pre class="brush: plain; title: ; notranslate">

echo &amp;amp;quot;Hello&amp;amp;quot; | mail -s &amp;amp;quot;test&amp;amp;quot; joe@newcentostestmail.com

</pre>
<p>in your maillog you should view something like these</p>
<pre class="brush: plain; title: ; notranslate">

tail /var/log/maillog

</pre>
<pre class="brush: plain; title: ; notranslate">
May  9 17:10:03 mail postfix/pickup[2970]: 1FD7C10041D: uid=0 from=&amp;amp;lt;root&amp;amp;gt;
May  9 17:10:03 mail postfix/cleanup[2992]: 1FD7C10041D: message-id=&amp;amp;lt;20150509151003.1FD7C10041D@mail.yourfqdn.com&amp;amp;gt;
May  9 17:10:03 mail postfix/qmgr[2971]: 1FD7C10041D: from=&amp;amp;lt;root@mail.yourfqdn.com&amp;amp;gt;, size=462, nrcpt=1 (queue active)
May  9 17:10:04 mail postfix/smtpd[3000]: connect from localhost[127.0.0.1]
May  9 17:10:04 mail postfix/smtpd[3000]: 295DD1004F0: client=localhost[127.0.0.1]
May  9 17:10:04 mail postfix/cleanup[2992]: 295DD1004F0: message-id=&amp;amp;lt;20150509151003.1FD7C10041D@mail.yourfqdn.com&amp;amp;gt;
May  9 17:10:04 mail postfix/qmgr[2971]: 295DD1004F0: from=&amp;amp;lt;root@mail.yourfqdn.com&amp;amp;gt;, size=943, nrcpt=1 (queue active)
May  9 17:10:04 mail amavis[2722]: (02722-01) Passed CLEAN {RelayedOpenRelay}, &amp;amp;lt;root@mail.yourfqdn.com&amp;amp;gt; -&amp;amp;gt; &amp;amp;lt;joe@newcentostestmail.com&amp;amp;gt;, Message-ID: &amp;amp;lt;20150509151003.1FD7C10041D@mail.yourfqdn.com&amp;amp;gt;, mail_id: Yppl42y970Wc, Hits: -0.001, size: 462, queued_as: 295DD1004F0, 975 ms
May  9 17:10:04 mail postfix/smtp[2997]: 1FD7C10041D: to=&amp;amp;lt;joe@newcentostestmail.com&amp;amp;gt;, relay=127.0.0.1[127.0.0.1]:10024, delay=1.2, delays=0.19/0.04/0.04/0.96, dsn=2.0.0, status=sent (250 2.0.0 from MTA(smtp:[127.0.0.1]:10025): 250 2.0.0 Ok: queued as 295DD1004F0)
May  9 17:10:04 mail postfix/qmgr[2971]: 1FD7C10041D: removed
May  9 17:10:04 mail postfix/virtual[3003]: 295DD1004F0: to=&amp;amp;lt;joe@newcentostestmail.com&amp;amp;gt;, relay=virtual, delay=0.09, delays=0.02/0.04/0/0.03, dsn=2.0.0, status=sent (delivered to maildir)
May  9 17:10:04 mail postfix/qmgr[2971]: 295DD1004F0: removed

</pre>
<p>Hurrah we have virtual mail</p>
<p>your sent mail should be at /var/vmail/newcentostestmail.com/joe/new</p>
<p><strong>step 17: open smtp port, 25, and enable remote access in postfix</strong></p>
<p>Our mailserver accepts connections from port 25 but only in localhost interface, that means that we can&#8217;t receive mail from a outside server and our users can&#8217;t send email from theirs applications.</p>
<p>firs of all we need to tell to postfix that listens from all interfaces</p>
<pre class="brush: plain; title: ; notranslate">

vim /etc/postfix/main.cf

</pre>
<p>at line 116 replace content with this</p>
<pre class="brush: plain; title: ; notranslate">
inet_interfaces = all
</pre>
<p>and restart postfix</p>
<pre class="brush: plain; title: ; notranslate">

systemctl restart postfix.service

</pre>
<p>postfix is listening at port 25 but firewalld is blocking any attemp from outside, we need to open port 25 in firewalld we just need to execute these commands</p>
<pre class="brush: plain; title: ; notranslate">

firewall-cmd --permanent --zone=public --add-service=smtp

firewall-cmd --reload

</pre>
<p>at this moment postfix should be contacted from any computer in the internet.</p>
<p>users, spammers, phishers and west Europe sexy women are ready to send tons of emails, we should check that this is correct.</p>
<p>from <strong><em>another</em></strong> computer execute this command</p>
<pre class="brush: plain; title: ; notranslate">

telnet &amp;amp;lt;mailserver ip&amp;amp;gt; 25

</pre>
<p>and you should get this output</p>
<pre class="brush: plain; title: ; notranslate">
Trying mailserver_ip...
Connected to mailserver_ip.
Escape character is '^]'.
220 mail.yourfqdn.com ESMTP Postfix

</pre>
<p>Eureka we can receive mails from a lot of people.</p>
<p><strong>step 18: enable smtp security</strong></p>
<p>At this moment if   user try send an email using your new server, it only has support for smtp that is a plain protocol, that means that is really easy read communication contents and get his password. we don&#8217;t want this for us.</p>
<p>A long time ago, at the beginning of secure smtp times, that&#8217;s 1997. Some people decided that best way to  secure smtp will be wrap it over a ssl or tls connection, that means that all connections should be realized starting a ssl/tls session since first data packet.</p>
<p>To differentiate secure and insecure smtp servers the best way it use a port for insecure smtp,  25, and another for secure connections 465. This strategy is a bit irritating because if another server want deliver a email in a secure mode it should verify if port 465 it&#8217;s opened.</p>
<p>Two years after some people  decided that the best way  should be implement STARTTLS this allows to  secure our communication  over a plain  textcommunication at  port 25.</p>
<p><span style="text-decoration: underline;">using port 465 smtmps is deprecated and you shouldn&#8217;t give support.</span></p>
<p>if you remember at step 6 you generated a certificate located at</p>
<p>/etc/pki/tls/private/mail.yourdomain.com.key<br />
/etc/pki/tls/certs/mail.yourdomain.com.0.csr</p>
<p>it&#8217;s recommendable have our certificate signed by and certification authority,  sorry you must pay <img src="https://s.w.org/images/core/emoji/2.2.1/72x72/1f641.png" alt="🙁" class="wp-smiley" style="height: 1em; max-height: 1em;" />  . Otherwise you can generate a self-signed certificate which will you a lot of security warnings in mail clients.</p>
<pre class="brush: plain; title: ; notranslate">
openssl x509 -req -days 365 -in /etc/pki/tls/certs/mail.yourdomain.com.0.csr -signkey /etc/pki/tls/private/mail.yourdomain.com.key -out /etc/pki/tls/certs/mail.yourdomain.com.crt

</pre>
<p>we need to tell to postfix where are these certificates and enable smtps</p>
<pre class="brush: plain; title: ; notranslate">

vim /etc/postfix/main.cf



</pre>
<p>at the end of the file we need to append this content at the end of file</p>
<pre class="brush: plain; title: ; notranslate">
smtpd_tls_key_file = /etc/pki/tls/private/mail.yourfqdn.com.key
smtpd_tls_cert_file = /etc/pki/tls/certs/mail_yourfqdn_com.crt
smtpd_tls_CAfile = /etc/pki/tls/certs/intermediate.mail.yourfqdn.com.cer

</pre>
<p>postfix also needs to know that we want to use starttls appending this line</p>
<pre class="brush: plain; title: ; notranslate">
smtpd_tls_security_level = may
</pre>
<p>Once when we have our certificate variables setted we need restart our postfix service</p>
<pre class="brush: plain; title: ; notranslate">

systemctl restart postfix.service

</pre>
<p>and check /var/log/maillog output</p>
<pre class="brush: plain; title: ; notranslate">

tail  /var/log/maillog

</pre>
<pre>May  9 17:22:12 mail postfix/postfix-script[3614]: starting the Postfix mail system
May  9 17:22:12 mail postfix/master[3616]: daemon started -- version 2.10.1, configuration /etc/postfix</pre>
<p>&nbsp;</p>
<p>now we need to verify that our smtp port supports STARTTLS this can be done from another computer using telnet.</p>
<pre class="brush: plain; title: ; notranslate">

telnet mailserverip 25

</pre>
<pre>Trying ...
Connected to .
Escape character is '^]'.
220 mail.yourfqdn.com ESMTP Postfix
ehlo testing
250-mail.mail.yourfqdn.com
250-PIPELINING
250-SIZE 10240000
250-VRFY
250-ETRN
250-STARTTLS
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN</pre>
<p>You should have a line that puts 250-STARTTLS startttls is enabled</p>
<p>now we will check if ssl works</p>
<pre class="brush: plain; title: ; notranslate">

openssl s_client -starttls smtp -crlf -connect your_server_ip:25

</pre>
<p>this command should give info about your ssl certificate</p>
<p><strong>step 19: Secure smtp ssl</strong></p>
<p>Unfortunately during last months openssl and his protocols appears to be broken, this security problems should be resolved using two ways:</p>
<ul>
<li>maintain your Openssl packages updated.</li>
<li>disable broken protocols and cyphers.</li>
</ul>
<p>if you&#8217;re following this guide I assume that you know  how to use yum update, next step is about cyphers and broken protocols.</p>
<p>openssl supports these protocols:</p>
<ul>
<li><span style="color: #ff0000;">SSLv2 broken</span></li>
<li><span style="color: #ff0000;">SSLv3 broken <a style="color: #ff0000;" title="SSLv3 broken" href="https://poodle.io" target="_blank">https://poodle.io</a>/</span></li>
<li><span style="color: #ff6600;"><span style="color: #ff0000;">TLS 1.0 Use for interoperability purposes where needed Has known issues that cannot be mitigated</span><br />
</span></li>
<li><span style="color: #339966;"><span style="color: #ff6600;">TLS 1.1 Use for interoperability purposes where needed  Does not support modern cipher suites.</span><br />
</span></li>
<li><span style="color: #339966;">TLS 1.2 Recommended version. Supports the modern AEAD cipher suites.<br />
</span></li>
</ul>
<p>These protocols use different ciphers</p>
<ul>
<li>Minimal encryption should be 128bits.</li>
<li>ADH  Anonymous Diffie-Hellman doesn&#8217;t provide authentication</li>
<li>NULL no encryption no party</li>
<li>Export key exchange suites can be broken easily</li>
<li>RC4 is prohibited <a title="Prohibiting RC4 Cipher Suites" href="http://tools.ietf.org/html/rfc7465" target="_blank">RFC7465</a></li>
<li>3DES uses 112bits it&#8217;s strong but have performance problems avoid it</li>
</ul>
<p>At this moment your STARTTLS configuration allow insecure protocols and insecure ciphers we need to fix this.</p>
<p>Simply append these content in your main.cf file</p>
<pre>#Disable sslv2 ad SSLv3
smtpd_tls_protocols= !SSLv2, !SSLv3
smtpd_tls_mandatory_protocols= !SSLv2, !SSLv3

#set minimum TLS ciphers grade for tls
smtpd_tls_mandatory_ciphers = high

#use server ciphers instead client preference
tls_preempt_cipherlist = yes

#ciphers to exclude
smtpd_tls_mandatory_exclude_ciphers = aNULL, MD5 , DES, ADH, RC4, PSD, SRP, 3DES, eNULL</pre>
<p>with this configuration you just avoided SSLv2, SSLv3 and remove insecure ciphers from TLS1.1</p>
<p>You should be tuned about security problems with openSSL.</p>
<p><strong>step 20: enable Perfect forward secrecy  in postfix<br />
</strong></p>
<p>We have secured our SSL/TLS configuration? Yes</p>
<p>we can do more for our security? Yes</p>
<p>HOW? enabling Perfect forward secrecy.</p>
<p>perfect forward secrecy generates a  public  keys per session that means theoretically if our private key is compromised your information is secret.</p>
<p>There are two options</p>
<p>Prime-field groups (EDH) &#8211; Server uses a large prime number and a generator</p>
<p>Elliptic-curve groups (EECDH) &#8211; Instead a large prime serve uses a elliptic curve algorithm</p>
<p>To configure EDH we need to create  some keys</p>
<pre class="brush: plain; title: ; notranslate">

openssl gendh -out /etc/postfix/dh_512.pem -2 512

openssl gendh -out /etc/postfix/dh_1024.pem -2 1024

openssl gendh -out /etc/postfix/dh_2048.pem -2 2048

</pre>
<p>append this lines in your /etc/postfix/main.cf</p>
<pre class="brush: plain; title: ; notranslate">

vim /etc/postfix/main.cf

</pre>
<pre>#Perfect forwatd secrecy Prime Field Groups EDH
smtpd_tls_dh1024_param_file = ${config_directory}/dh_2048.pem
smtpd_tls_dh512_param_file = ${config_directory}/dh_512.pem</pre>
<p>now we can restart postfix service</p>
<pre class="brush: plain; title: ; notranslate">

systemctl reload postfix.service

</pre>
<p>for security reasons we should generate a new group of prime numbers daily or hourly, we will create a bash script in order to generate these prime numbers every day</p>
<pre class="brush: plain; title: ; notranslate">

vim /etc/cron.daily/postfix_pfs_edh_regenerate

</pre>
<p>and copy this content</p>
<pre class="brush: bash; title: ; notranslate">
#!/bin/bash
cd /etc/postfix
umask 022
for legth in 512 1024 2048
do
openssl dhparam -out dh_$legth.tmp $legth &amp;amp;amp;&amp;amp;amp; mv dh_$legth.tmp dh_$legth.pem
chmod 644 dh_$legth.pem
done
</pre>
<p>and give correct permissions</p>
<blockquote><p>chmod 700 /etc/cron.daily/postfix_pfs_edh_regenerate</p></blockquote>
<p>To configure EECDH we should add these lines in main.cf</p>
<blockquote><p>vim /etc/postfix/main.cf</p></blockquote>
<pre>#Perfect forward secrecy Elliptic-curve Groups EECDH
smtpd_tls_eecdh_grade = strong
tls_eecdh_strong_curve = prime256v1
tls_eecdh_ultra_curve = secp384r1</pre>
<p>now we can restart postfix service</p>
<blockquote><p>systemctl restart postfix.service</p></blockquote>
<p><strong>Step 21: enable POP and IMAP services</strong></p>
<p>Our users need to read their incoming mail in laptops, mobile devices, fridges&#8230;.</p>
<p>with smtp user can send mails but can&#8217;t read new emails and maintain philosophical conversations about last season most viewed soap opera.</p>
<p>Receiving emails from server can be done using POP, IMAP or both</p>
<p>In my case i preffer use only IMAP but i will both configurations</p>
<p>POP is older than IMAP if your users reads email from multiple devices IMAP should be better, check users email volume and number of devices to select what configuration fits better for each one, new soap operas are really intense.</p>
<p>For provide POP and IMAP connectivity we will use dovecot, Dovecot also includes SASL support for centralized logins, Tradicionally tutorials uses cyrus-sasl to implement authentication, but dovecot includes a SASL implementation, i will try to use it instead include cyrus-sasl package.</p>
<p>Dovecot configuration files are located at /etc/dovecot/conf.d</p>
<p><strong> Step  22: create config files to Link dovecot with MariaDB user database</strong></p>
<p>With postfixadmin we create a mariadb database, we should give access to dovecot in order to get these data</p>
<p>we need a file with needed queries to provide data about users</p>
<blockquote><p>vim /etc/dovecot/conf.d/dovecot-mysql.conf.ext</p></blockquote>
<pre class="brush: plain; title: ; notranslate">
driver = mysql
connect = host=localhost dbname=postfix user=postfixread password=yourpassword

password_query = SELECT username as user, password, concat('/var/vmail/', maildir) as userdb_home,  concat('maildir:/var/vmail/', maildir) as userdb_mail, 101 as userdb_uid, 12 as userdb_gid FROM mailbox  WHERE username = '%u' AND active = '1'

user_query = SELECT concat('/var/vmail/', maildir) as home, concat('maildir:/var/vmail/', maildir) as mail,  101 AS uid, 12 AS gid, CONCAT('*:bytes=', quota) as quota_rule FROM mailbox WHERE  username = '%u' AND active = '1'

</pre>
<p>also we need a file to provide information about accounts quota</p>
<blockquote><p>vim /etc/dovecot/conf.d/dovecot-mysql-quota.conf.ext</p></blockquote>
<pre class="brush: plain; title: ; notranslate">
connect = host=localhost dbname=postfix user=postfixread password=your_password
map {
  pattern = priv/quota/storage
  table = quota2
  username_field = username
  value_field = bytes
}
map {
  pattern = priv/quota/messages
  table = quota2
  username_field = username
  value_field = messages
}

</pre>
<p>with these files dovecot will query  mariadb info about users and mailbox quotas.</p>
<p><strong>step 23: configure dovecot ssl protocols<br />
</strong></p>
<p>now we will configure some setting in dovecot main config file</p>
<blockquote><p><strong>vim /etc/dovecot/dovecot.conf</strong></p></blockquote>
<p>line 24 tells dovecot what protocols  should serve it needs to be like</p>
<pre class="brush: plain; title: ; notranslate">
protocols = imap pop3
</pre>
<p>line 30 is what interfaces where dovecot will be listening</p>
<pre class="brush: plain; title: ; notranslate">
listen = *, ::
</pre>
<p>line 67 defines behavior when reboot dovecot service</p>
<pre class="brush: plain; title: ; notranslate">
shutdown_clients = yes
</pre>
<p>now we will restart dovecot service</p>
<blockquote><p> systemctl restart dovecot.service</p></blockquote>
<p>and verify if service has started correctly</p>
<blockquote><p><strong>tail /var/log/maillog</strong></p></blockquote>
<p>you should see a line like these</p>
<pre class="brush: plain; title: ; notranslate">
May 10 15:42:02 mail dovecot: master: Dovecot v2.2.10 starting up for imap (core dumps disabled)
</pre>
<p><strong> step 24: Configure Dovecot users authentification</strong></p>
<p>Now dovecot is listening in desired ports, but blocked by firewalld, before open these ports we need to do some modifications</p>
<p>When a user request their emails using pop3 or imap, he will need to pass his username and password, there are several ways to send login information:</p>
<p>plain: passed as clear text, secure if is send over a TLS/SSL conection</p>
<p>login: another clear text mechanism, used by outlook clients, secure if is send over a TLS/SSL conection</p>
<p>CRAM-MD5: not clear text, uses HMAC-MD5</p>
<p>these are main supported  authentication protocols</p>
<p>by default dovecot only uses PLAIN mechanism, to add more mechanism we need to edit /etc/dovecot/conf.d/10-auth.conf file</p>
<blockquote><p>vim /etc/dovecot/conf.d/10-auth.conf</p></blockquote>
<p>at line 100 the content should be these:</p>
<pre class="brush: plain; title: ; notranslate">
auth_mechanisms = plain login cram-md5
</pre>
<p>now dovecot should support all these auth_mechanisms but we need to restart our dovecot service to check that</p>
<blockquote><p> systemctl restart dovecot.service</p></blockquote>
<p>and verify if service has restarted correctly</p>
<blockquote><p><strong>tail /var/log/maillog</strong></p></blockquote>
<p>you should see a line like these</p>
<pre class="brush: plain; title: ; notranslate">
May 10 15:44:57 mail dovecot: master: Warning: Killed with signal 15 (by pid=1 uid=0 code=kill)
May 10 15:44:57 mail dovecot: master: Dovecot v2.2.10 starting up for imap (core dumps disabled)
</pre>
<p><strong>step 25: configure Dovecot SSL</strong></p>
<p>like postfix dovecot needs to configure SSL. Dovecot supports these modes:</p>
<ul>
<li><span style="color: #ff0000;">POP3: insecure port 110</span></li>
<li>POP3 with StartTLS: secure port 110</li>
<li>POP3S:  POP3 wraped over a TLS/SSL connection 995</li>
<li><span style="color: #ff0000;">IMAP: insecure port 143</span></li>
<li>IMAP  with StartTLS: secure port 143</li>
<li>IMAPS: IMAP wraped over a TLS/SSL connection 993</li>
</ul>
<p>some people disable port 110 and port 143 because some email clients make a plain login even if communication over port 143 indicates that only use of    StartTLS is avaliable.</p>
<p>What you should do with 110 and 143 is your decision, it depends of what kind of email clients you support. In mi case I will configure POP3 with StartTLS, POP3S, IMAP with StartTLS and IMAPS</p>
<p>We need to provide info about certificates to dovecot</p>
<blockquote><p>vim /etc/dovecot/conf.d/10-ssl.conf</p></blockquote>
<p>and replace certificates configuration chains</p>
<pre class="brush: plain; title: ; notranslate">
ssl_key = &amp;amp;lt;/etc/pki/tls/private/mail.yourdomain.com.key
ssl_cert = &amp;amp;lt;/etc/pki/tls/certs/mail_yourdomaiun_com.crt
ssl_ca = &amp;amp;lt;/etc/pki/tls/certs/intermediate.mail.yourdomain.com.cer
</pre>
<p>as you learn configuring postfix certificates providing only certificates allow using insecure protocols, we should hardening dovecot configuration near line 52</p>
<blockquote><p>vim /etc/dovecot/conf.d/10-ssl.conf</p></blockquote>
<pre class="brush: plain; title: ; notranslate">
# SSL protocols to use
ssl_protocols = !SSLv2 !SSLv3
# SSL ciphers to use
ssl_cipher_list = EECDH+ECDSA+AESGCM:EECDH+aRSA+AESGCM:EECDH+ECDSA+SHA384:EECDH+ECDSA+SHA256:EECDH+aRSA+SHA384:EECDH+aRSA+SHA256:EECDH+aRSA+RC4:EECDH:EDH+aRSA:!aNULL:!eNULL:!LOW:!3DES:!MD5:!EXP:!PSK:!SRP:!DSS:!RC4

# Prefer the server's order of ciphers over client's.
ssl_prefer_server_ciphers = yes
</pre>
<p><strong>step 26: configure Dovecot mailbox location<br />
</strong></p>
<p>Now dovecot uses secure ssl ciphers but need to know were are located accounts mailboxes, this configuration options are located in:</p>
<p>/etc/dovecot/conf.d/10-mail.conf</p>
<p>edit this file</p>
<blockquote><p>vim /etc/dovecot/conf.d/10-mail.conf</p></blockquote>
<p>and configure these parameters</p>
<pre class="brush: plain; title: ; notranslate">
mail_location = maildir:/var/vmail/%d/%n/:INDEX=/var/vmail/%d/%n/indexes
mail_uid =101
mail_gid =12
first_valid_uid = 101
last_valid_uid = 101
first_valid_gid = 12
last_valid_gid = 12
</pre>
<p>now dovecot knows where are located mailboxes</p>
<p><strong>step 27: configure Dovecot pop3 pop3s imap and imaps<br />
</strong></p>
<p>Now dovecot needs to know what protocols will  serve and how</p>
<blockquote><p>vim /etc/dovecot/conf.d/10-master.conf</p></blockquote>
<p>&nbsp;</p>
<pre class="brush: plain; title: ; notranslate">
service imap-login {
  inet_listener imap {
    port = 143
  }
  inet_listener imaps {
    port = 993
    ssl = yes
  }

service pop3-login {
  inet_listener pop3 {
    port = 110
  }
  inet_listener pop3s {
    port = 995
    ssl = yes
  }
}

service auth {

  unix_listener /var/spool/postfix/private/auth {
    mode = 0666
    user = vmail
    group = mail
  }

</pre>
<p>we need to advertise to dovecot that we will only accept login over encrypted connections</p>
<blockquote><p>vim /etc/dovecot/conf.d/10-auth.conf</p></blockquote>
<pre class="brush: plain; title: ; notranslate">
disable_plaintext_auth = yes
</pre>
<p>and new need to link dovecot with mariadb</p>
<blockquote><p>vim /etc/dovecot/conf.d/auth-sql.conf.ext</p></blockquote>
<pre class="brush: plain; title: ; notranslate">
# Authentication for SQL users. Included from 10-auth.conf.
#
# &amp;amp;lt;doc/wiki/AuthDatabase.SQL.txt&amp;amp;gt;

passdb {
  driver = sql

  # Path for SQL configuration file, see example-config/dovecot-sql.conf.ext
  args = /etc/dovecot/conf.d/dovecot-mysql.conf.ext
}

# &amp;amp;quot;prefetch&amp;amp;quot; user database means that the passdb already provided the
# needed information and there's no need to do a separate userdb lookup.
# &amp;amp;lt;doc/wiki/UserDatabase.Prefetch.txt&amp;amp;gt;
#userdb {
#  driver = prefetch
#}

userdb {
  driver = sql
  args = /etc/dovecot/conf.d/dovecot-mysql.conf.ext
}

# If you don't have any user-specific settings, you can avoid the user_query
# by using userdb static instead of userdb sql, for example:
# &amp;amp;lt;doc/wiki/UserDatabase.Static.txt&amp;amp;gt;
#userdb {
  #driver = static
  #args = uid=vmail gid=vmail home=/var/vmail/%u
#}

</pre>
<blockquote><p>vim /etc/dovecot/conf.d/10-auth.conf</p></blockquote>
<pre class="brush: plain; title: ; notranslate">
#!include auth-system.conf.ext
!include auth-sql.conf.ext
</pre>
<p>at this point we have a basical dovecot service running</p>
<blockquote><p>systemctl restart dovecot.service</p></blockquote>
<p>but we dont enable service if we restart our computer we don&#8217;t have dovecot enabled</p>
<blockquote><p>systemctl enable dovecot.service</p></blockquote>
<p><strong>step 28: open Dovecot ports in firewall<br />
</strong></p>
<p>dovecot is ready but we need to open ports in firewall</p>
<blockquote><p>firewall-cmd &#8211;permanent &#8211;zone=public &#8211;add-service=pop3s</p>
<p>firewall-cmd &#8211;permanent &#8211;zone=public &#8211;add-port=110/tcp</p>
<p>firewall-cmd &#8211;permanent &#8211;zone=public &#8211;add-service=imaps</p>
<p>firewall-cmd &#8211;permanent &#8211;zone=public &#8211;add-port=143/tcp<br />
firewall-cmd &#8211;reload</p></blockquote>
<p><strong>step 29: configure postfix smtp authentcation</strong></p>
<p>when we configured dovecot we configure embebed sasl authentication, now we will integrate dovecot auth in postfix</p>
<p>we need to append these lines to our main.cf file</p>
<blockquote><p>vim  /etc/postfix/main.cf</p></blockquote>
<pre class="brush: plain; title: ; notranslate">
smtpd_sasl_type = dovecot
smtpd_sasl_path = private/auth
smtpd_sasl_auth_enable = yes
smtpd_relay_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination
</pre>
<p><strong>step 30: avoid plain logins in smtp connections<br />
</strong></p>
<p>Security parameters appear to be well configured, but if we leave configuration in hand of users, they will try to use plain login, this is easily to sniff we avoid these options</p>
<blockquote><p>vim /etc/postfix/main.cf</p></blockquote>
<p>and append these lines</p>
<pre class="brush: plain; title: ; notranslate">
#disallow plain login
smtpd_tls_auth_only = yes
</pre>
<p>&nbsp;</p>
<p><strong>step 31: enable smtp submission port</strong></p>
<p>At this moment we know that our smtp service should run only in port 25, unfortunately some Internet Service Providers decided that the best way to  stop spam is deny conections to smtp port. If you leave only port 25 opened some users can&#8217;t send email because their ISP deny connections. To solve this problem we can enable  SMTP submission port, 587. and forget phone calls from users complaining about that they can&#8217;t send email from cafes, or their homes.</p>
<p>we need to modify file  /etc/postfix/master.cf</p>
<blockquote><p>vim /etc/postfix/master.cf</p></blockquote>
<p>and remove comments in these lines</p>
<pre class="brush: plain; title: ; notranslate">
submission inet n       -       n       -       -       smtpd
  -o syslog_name=postfix/submission
  -o smtpd_tls_security_level=encrypt
  -o smtpd_sasl_auth_enable=yes
  -o smtpd_reject_unlisted_recipient=no
  -o smtpd_client_restrictions=$mua_client_restrictions
  -o smtpd_helo_restrictions=$mua_helo_restrictions
  -o smtpd_sender_restrictions=$mua_sender_restrictions
  -o smtpd_recipient_restrictions=permit_sasl_authenticated,reject
  -o milter_macro_daemon_name=ORIGINATING

</pre>
<p>we also need to define mua variables</p>
<p>vim /etc/postfix/main.cf</p>
<pre class="brush: plain; title: ; notranslate">

mua_client_restrictions = permit_sasl_authenticated,reject
mua_helo_restrictions = permit_sasl_authenticated,reject
mua_sender_restrictions = permit_sasl_authenticated,reject

</pre>
<p>now we will restart postifx service</p>
<blockquote><p> systemctl restart postfix.service</p></blockquote>
<p>and we should get one output like these is /var/log/maillog</p>
<blockquote><p>tail -f /var/log/maillog</p></blockquote>
<pre class="brush: plain; title: ; notranslate">
May 10 16:08:51 mail postfix/postfix-script[13671]: stopping the Postfix mail system
May 10 16:08:51 mail postfix/master[3802]: terminating on signal 15
May 10 16:08:52 mail postfix/postfix-script[13752]: starting the Postfix mail system
May 10 16:08:52 mail postfix/master[13754]: daemon started -- version 2.10.1, configuration /etc/postfix

</pre>
<p>we need to open smtp submission port too</p>
<blockquote><p>firewall-cmd &#8211;permanent &#8211;zone=public &#8211;add-port=587/tcp</p>
<p>firewall-cmd &#8211;reload</p></blockquote>
<p><strong> Step 32: Test configuration against a mail client<br />
</strong></p>
<p>In my case I will use Thunderbird, there are a lot of mail clients. If you use self signed certificates you should search in google, duck duck go or another web searcher how it&#8217;s the client behavior.</p>
<p>Configuring this data is easy.</p>
<ul>
<li>all your servers will be your fully qualified domain name,</li>
<li>your username will be the email account</li>
<li>and the password will be that you put in postfixadmin</li>
</ul>
<p>check and send some emails between accounts, don&#8217;t send to hotmail or gmail probabily it will appear in spam.</p>
<p>it should work.</p>
<p>if doesn&#8217;t work check /var/log/maillog output or leave a comment</p>
<p><strong>step 33:link amavisd-new with mariadb database</strong></p>
<p>amavisd neew to know what domains is serving we need to link Mariadb database with amavisd-new.</p>
<p>In order to maintain a security lever we will create a view and a new user that only can access to this view.</p>
<p>we will append these lines in amavisd config file</p>
<blockquote><p>vim /etc/amavisd/amavisd.conf</p></blockquote>
<pre class="brush: perl; title: ; notranslate">
@lookup_sql_dsn = (
    ['DBI:mysql:database=postfix;host=127.0.0.1;port=3306', 'postfixread', 'yourpassword']
);

$sql_select_policy =  'SELECT &amp;amp;quot;Y&amp;amp;quot; AS local FROM domain WHERE CONCAT(&amp;amp;quot;@&amp;amp;quot;, domain) IN (%k)';

</pre>
<p>amavisd default config will discard spam mail we want to changue this behavior</p>
<blockquote><p>vim /etc/amavisd/amavisd.conf</p></blockquote>
<p>and edit final_spam_destiny variable</p>
<pre class="brush: perl; title: ; notranslate">
$final_spam_destiny       = D_PASS;  #!!!  D_DISCARD / D_REJECT
</pre>
<p>now amavisd will deliver spam messages to inbox and knows what domains are hosted with postfixadmin.</p>
<p>Amavisd sends a copy of email to spamassasin and reads spamassasin results, this means that  if spamassasin modifies email subject these will not appears in our detected email. we should modify several parameters in amavis config file to always write spamassasing analysis results.</p>
<blockquote><p>vim /etc/amavisd/amavisd.conf</p></blockquote>
<p>just modify these values</p>
<pre class="brush: perl; title: ; notranslate">
$sa_tag_level_deflt  = -9999;  # add spam info headers if at, or above that level
$sa_tag2_level_deflt = 6.2;  # add 'spam detected' headers at that level
$sa_kill_level_deflt = 6.9;  # triggers spam evasive actions (e.g. blocks mail)
$sa_dsn_cutoff_level = 10;   # spam level beyond which a DSN is not sent
$sa_crediblefrom_dsn_cutoff_level = 18; # likewise, but for a likely valid From

</pre>
<p>We will  reconfigure some parameters in spamassasin</p>
<p>&nbsp;</p>
<p><strong>step 34: Configure spamassasin</strong></p>
<blockquote><p>vim /etc/mail/spamassassin/local.cf</p></blockquote>
<p>should be like these</p>
<pre class="brush: plain; title: ; notranslate">
required_hits 5.0
report_safe 0
required_score 5
remove_header ham Status
remove_header ham Level

</pre>
<p>We can link spamassasing with a mariadb database that force us to create a database</p>
<blockquote><p>mysql -u root -p</p></blockquote>
<pre class="brush: sql; title: ; notranslate">
CREATE DATABASE mail_spamassassin;
CREATE USER 'spamassassin'@'localhost' IDENTIFIED BY 'new_password';
GRANT ALL PRIVILEGES ON `mail_spamassassin` . * TO 'spamassassin'@'localhost';
FLUSH PRIVILEGES;
quit;
</pre>
<p>we need to create several tables</p>
<blockquote><p>mysql -u root -p mail_spamassassin</p></blockquote>
<pre class="brush: sql; title: ; notranslate">

CREATE TABLE bayes_expire (
  id int(11) NOT NULL default '0',
  runtime int(11) NOT NULL default '0',
  KEY bayes_expire_idx1 (id)
) ENGINE=InnoDB;

CREATE TABLE bayes_global_vars (
  variable varchar(30) NOT NULL default '',
  value varchar(200) NOT NULL default '',
  PRIMARY KEY  (variable)
) ENGINE=InnoDB;

INSERT INTO bayes_global_vars VALUES ('VERSION','3');

CREATE TABLE bayes_seen (
  id int(11) NOT NULL default '0',
  msgid varchar(200) binary NOT NULL default '',
  flag char(1) NOT NULL default '',
  PRIMARY KEY  (id,msgid)
) ENGINE=InnoDB;

CREATE TABLE bayes_token (
  id int(11) NOT NULL default '0',
  token binary(5) NOT NULL default '',
  spam_count int(11) NOT NULL default '0',
  ham_count int(11) NOT NULL default '0',
  atime int(11) NOT NULL default '0',
  PRIMARY KEY  (id, token),
  INDEX bayes_token_idx1 (id, atime)
) ENGINE=InnoDB;

CREATE TABLE bayes_vars (
  id int(11) NOT NULL AUTO_INCREMENT,
  username varchar(200) NOT NULL default '',
  spam_count int(11) NOT NULL default '0',
  ham_count int(11) NOT NULL default '0',
  token_count int(11) NOT NULL default '0',
  last_expire int(11) NOT NULL default '0',
  last_atime_delta int(11) NOT NULL default '0',
  last_expire_reduce int(11) NOT NULL default '0',
  oldest_token_age int(11) NOT NULL default '2147483647',
  newest_token_age int(11) NOT NULL default '0',
  PRIMARY KEY  (id),
  UNIQUE bayes_vars_idx1 (username)
) ENGINE=InnoDB;

CREATE TABLE awl (
  username varchar(100) NOT NULL default '',
  email varbinary(255) NOT NULL default '',
  ip varchar(40) NOT NULL default '',
  count int(11) NOT NULL default '0',
  totscore float NOT NULL default '0',
  signedby varchar(255) NOT NULL default '',
  PRIMARY KEY (username,email,signedby,ip)
) ENGINE=InnoDB;

quit;
</pre>
<p>once when we have created these tables we need to link spamassasin with these tables</p>
<p><span style="text-decoration: underline;">Auto-Whitelists linking</span></p>
<p>we need to enable autowhitelist check in spamassasin config</p>
<blockquote><p> vim /etc/mail/spamassassin/v310.pre</p></blockquote>
<p>edit line 45 removing comment</p>
<pre class="brush: plain; title: ; notranslate">
# AWL - do auto-whitelist checks
#
loadplugin Mail::SpamAssassin::Plugin::AWL
</pre>
<p>and configure database access</p>
<blockquote><p>vim /etc/mail/spamassassin/auto-whitelist.cf</p></blockquote>
<pre class="brush: plain; title: ; notranslate">
auto_whitelist_factory Mail::SpamAssassin::SQLBasedAddrList

user_awl_dsn                 DBI:mysql:mail_spamassassin:localhost
user_awl_sql_username        spamassassin
user_awl_sql_password        yourpassword

use_auto_whitelist 1
</pre>
<p><span style="text-decoration: underline;">Bayesian Storage Module</span></p>
<blockquote><p>vim /etc/mail/spamassassin/bayesian-storage.cf</p></blockquote>
<pre class="brush: plain; title: ; notranslate">
bayes_store_module                 Mail::SpamAssassin::BayesStore::SQL

bayes_sql_dsn                 DBI:mysql:mail_spamassassin:localhost
bayes_sql_username            spamassassin
bayes_sql_password            yourpassword

use_bayes          1
bayes_auto_learn   1
bayes_auto_expire  1
</pre>
<p>at this point we will restart spamassassin service</p>
<blockquote><p>systemctl restart spamassassin.service</p></blockquote>
<p>we should see a log like this in /var/log/maillog</p>
<pre class="brush: plain; title: ; notranslate">
May 11 12:18:30 mail spamd[23346]: logger: removing stderr method
May 11 12:18:36 mail spamd[23348]: spamd: server started on IO::Socket::IP [127.0.0.1]:783, IO::Socket::IP [::1]:783 (running version 3.4.0)
May 11 12:18:36 mail spamd[23348]: spamd: server pid: 23348
May 11 12:18:36 mail spamd[23348]: spamd: server successfully spawned child process, pid 23354
May 11 12:18:36 mail spamd[23348]: spamd: server successfully spawned child process, pid 23355
May 11 12:18:36 mail spamd[23348]: prefork: child states: IS
May 11 12:18:36 mail spamd[23348]: prefork: child states: II
</pre>
<p>Now we will give a spam message to spamassassin to start learning</p>
<blockquote><p> sa-learn &#8211;spam /usr/share/doc/spamassassin-3.4.0/sample-spam.txt</p></blockquote>
<p>output should be like these</p>
<pre class="brush: plain; title: ; notranslate">
Learned tokens from 1 message(s) (1 message(s) examined)
</pre>
<p>this acction will add some data into database if we loged on mariadb</p>
<p>and execute a</p>
<pre class="brush: sql; title: ; notranslate">
select * from mail_spamassassin.bayes_vars;
</pre>
<p>we should see one record.</p>
<p><strong>step 35: Sending spam to a dedicated folder in each account</strong></p>
<p>When someone send spam it will appear in our inbox with text ***SPAM***  in the subject.</p>
<p><a href="https://www.luzem.com/wp-content/uploads/2015/04/spam_inbox.png"><img class="aligncenter size-medium wp-image-3743" src="https://www.luzem.com/wp-content/uploads/2015/04/spam_inbox-300x41.png" alt="inbox spam detected" width="300" height="41" srcset="https://www.luzem.com/wp-content/uploads/2015/04/spam_inbox-300x41.png 300w, https://www.luzem.com/wp-content/uploads/2015/04/spam_inbox.png 488w" sizes="(max-width: 300px) 100vw, 300px" /></a>if stats about 99% of received email are right, that means that we will get 99 ***Spam*** mails before get a valid one. Leaving a lot of Spam a inbox could be irritating for our users.</p>
<p>One smart solution used by providers like Google, Microsoft or Yahoo is deliver spam in a dedicated folder.  Probably your users are familiarized with these behavior.</p>
<p>In our actual configuration deliver email to mailbox is managed by postfix virtual domain agent delivery <a href="http://www.postfix.org/virtual.8.html">VIRTUAL(8)</a> , virtual agent can&#8217;t deliver email to spam folder. We need to use one alternative like Dovecot.</p>
<p>With dovecot acting as local delivery we can use sieve  filters to manage messages location.</p>
<p>For local delivery Dovecot offers two options, LDA and LMTP</p>
<ul>
<li>LDA works like a binary command, each time that postfix sends a email lda deliver is called.</li>
<li>LMTP is like a long-running process started by Dovecot.</li>
</ul>
<p>obviously  LMTP is better and is the option that we should use.</p>
<p>We need to change delivery agent in postfix. This requires some configuration changes in dovecot.</p>
<p>&nbsp;</p>
<blockquote><p>vim /etc/dovecot/conf.d/10-master.conf</p></blockquote>
<p>and fill lmtp settings like these</p>
<pre class="brush: plain; title: ; notranslate">
service lmtp {
   unix_listener /var/spool/postfix/private/dovecot-lmtp {
     group = postfix
     mode = 0600
     user = postfix
    }
  unix_listener lmtp {
    #mode = 0666
   }

  # Create inet listener only if you can't use the above UNIX socket
  #inet_listener lmtp {
    # Avoid making LMTP visible for the entire internet
    #address =
    #port =
  #}
}

</pre>
<p>next step is configure lmtp protocol itself</p>
<blockquote><p> vim /etc/dovecot/conf.d/20-lmtp.conf</p></blockquote>
<p>here you will need to give a postmaster address</p>
<pre class="brush: plain; title: ; notranslate">
protocol lmtp {
postmaster_address = postmaster@yourdomain.com
}
</pre>
<p>finally we will enable lmtp protocol</p>
<blockquote><p>vim /etc/dovecot/dovecot.conf</p></blockquote>
<pre class="brush: plain; title: ; notranslate">

protocols = imap pop3  lmtp

</pre>
<p>our configuration is ready we should restart dovecot service to apply configuration modifications</p>
<blockquote><p>systemctl restart dovecot.service</p></blockquote>
<p>now postfix need to use dovecot lda instead virtual</p>
<p>append these lines in postfix main config file</p>
<blockquote><p>vim /etc/postfix/main.cf</p></blockquote>
<pre class="brush: plain; title: ; notranslate">
#use dovecot lmtp as virtual transport
virtual_transport = lmtp:unix:private/dovecot-lmtp
</pre>
<p>after these modifications we can restart postfix service</p>
<blockquote><p>systemctl restart postfix.service</p></blockquote>
<p>at this point send and email from one virtual account to another, it should work without problems.</p>
<p>in /var/log/maillog it should appear a line like this</p>
<pre class="brush: plain; title: ; notranslate">
dovecot: lmtp(3762, youruser@yourdomain.com): XXXXXXXXXXXXXXXXXX: msgid=XXXXXXXXXXX.YYYYYYYYY@yourdomain.com: saved mail to INBOX
</pre>
<p>Now dovecot is our local delivery agent</p>
<p>before enable sieve plugin we need to ensure that every IMAP user will have a spam folder</p>
<blockquote><p>vim /etc/dovecot/conf.d/15-mailboxes.conf</p></blockquote>
<p>We will create an typical set of folders</p>
<pre class="brush: plain; title: ; notranslate">
##
## Mailbox definitions
##

# NOTE: Assumes &amp;amp;amp;quot;namespace inbox&amp;amp;amp;quot; has been defined in 10-mail.conf.
namespace inbox {

  #mailbox name {
    # auto=create will automatically create this mailbox.
    # auto=subscribe will both create and subscribe to the mailbox.
    #auto = no

    # Space separated list of IMAP SPECIAL-USE attributes as specified by
    # RFC 6154: \All \Archive \Drafts \Flagged \Junk \Sent \Trash
    #special_use =
  #}

  # These mailboxes are widely used and could perhaps be created automatically:
  mailbox Drafts {
    auto = subscribe
    special_use = \Drafts
  }
  mailbox Junk {
    auto = subscribe
    special_use = \Junk
  }
  mailbox Trash {
    auto = subscribe
    special_use = \Trash
  }

  # For \Sent mailboxes there are two widely used names. We'll mark both of
  # them as \Sent. User typically deletes one of them if duplicates are created.
  mailbox Sent {
    auto=subscribe
    special_use = \Sent
  }

  # If you have a virtual &amp;amp;amp;quot;All messages&amp;amp;amp;quot; mailbox:
  #mailbox virtual/All {
  #  special_use = \All
  #}

  # If you have a virtual &amp;amp;amp;quot;Flagged&amp;amp;amp;quot; mailbox:
  #mailbox virtual/Flagged {
  #  special_use = \Flagged
  #}
}

</pre>
<p>restart dovecot service</p>
<blockquote><p>systemctl restart dovecot.service</p></blockquote>
<p>now if we open our mail client, thunderbird, we should see a list of new folders</p>
<p><a href="https://www.luzem.com/wp-content/uploads/2015/05/imap_folders.png"><img class="aligncenter size-full wp-image-3775" src="https://www.luzem.com/wp-content/uploads/2015/05/imap_folders.png" alt="imap folders" width="111" height="103" /></a></p>
<p>after all those steps we can enable sieve plugin</p>
<p>we will create a sieve global filter</p>
<blockquote><p>cd /var/vmail</p>
<p>mkdir sieve</p>
<p>cd sieve</p>
<p>vim globalfilter.sieve</p></blockquote>
<p>fill file with this content</p>
<pre class="brush: plain; title: ; notranslate">
require &amp;amp;quot;fileinto&amp;amp;quot;;
  if exists &amp;amp;quot;X-Spam-Flag&amp;amp;quot; {
          if header :contains &amp;amp;quot;X-Spam-Flag&amp;amp;quot; &amp;amp;quot;NO&amp;amp;quot; {
          } else {
          fileinto &amp;amp;quot;Junk&amp;amp;quot;;      
          stop;
      }
  }
  if header :contains &amp;amp;quot;subject&amp;amp;quot; [&amp;amp;quot;***SPAM***&amp;amp;quot;] {
    fileinto &amp;amp;quot;Junk&amp;amp;quot;;
    stop;
  }

</pre>
<blockquote><p>chown -R vmail:mail /var/vmail/sieve</p></blockquote>
<p>we need to enable sieve services in dovecot</p>
<blockquote><p>vim /etc/dovecot/conf.d/20-managesieve.conf</p></blockquote>
<pre class="brush: plain; title: ; notranslate">

##
## ManageSieve specific settings
##

# Uncomment to enable managesieve protocol:
#protocols = $protocols sieve

# Service definitions

service managesieve-login {
  inet_listener sieve {
    port = 4190
  }

  #inet_listener sieve_deprecated {
  #  port = 2000
  #}

  # Number of connections to handle before starting a new process. Typically
  # the only useful values are 0 (unlimited) or 1. 1 is more secure, but 0
  # is faster. &amp;amp;lt;doc/wiki/LoginProcess.txt&amp;amp;gt;

  service_count = 1

  # Number of processes to always keep waiting for more connections.
  process_min_avail = 0

  # If you set service_count=0, you probably need to grow this.
  vsz_limit = 64M
}

service managesieve {
  # Max. number of ManageSieve processes (connections)
  #process_limit = 1024
}

# Service configuration

protocol sieve {
  # Maximum ManageSieve command line length in bytes. ManageSieve usually does
  # not involve overly long command lines, so this setting will not normally
  # need adjustment
  managesieve_max_line_length = 65536

  # Maximum number of ManageSieve connections allowed for a user from each IP
  # address.
  # NOTE: The username is compared case-sensitively.
  #mail_max_userip_connections = 10

  # Space separated list of plugins to load (none known to be useful so far).
  # Do NOT try to load IMAP plugins here.
  #mail_plugins =

  # MANAGESIEVE logout format string:
  #  %i - total number of bytes read from client
  #  %o - total number of bytes sent to client
  #managesieve_logout_format = bytes=%i/%o

  # To fool ManageSieve clients that are focused on CMU's timesieved you can
  # specify the IMPLEMENTATION capability that Dovecot reports to clients.
  # For example: 'Cyrus timsieved v2.2.13'
  managesieve_implementation_string = Dovecot Pigeonhole

  # Explicitly specify the SIEVE and NOTIFY capability reported by the server
  # before login. If left unassigned these will be reported dynamically
  # according to what the Sieve interpreter supports by default (after login
  # this may differ depending on the user).
  #managesieve_sieve_capability =
  #managesieve_notify_capability =

  # The maximum number of compile errors that are returned to the client upon
  # script upload or script verification.
  managesieve_max_compile_errors = 5

  # Refer to 90-sieve.conf for script quota configuration and configuration of
  # Sieve execution limits.
}

</pre>
<blockquote><p>vim /etc/dovecot/conf.d/90-plugin.conf</p></blockquote>
<pre class="brush: plain; title: ; notranslate">

plugin {
  #setting_name = value
  sieve_global_path = /var/vmail/sieve/globalfilter.sieve
  sieve_max_script_size = 1M
}

</pre>
<p>local delivery should use sieve</p>
<blockquote><p>vim /etc/dovecot/conf.d/20-lmtp.conf</p></blockquote>
<pre class="brush: plain; title: ; notranslate">

protocol lmtp {
  # Space separated list of plugins to load (default is global mail_plugins).
  postmaster_address =  postmaster@yourdomain.com
  mail_plugins = $mail_plugins sieve
}

</pre>
<p>at this point we should restart dovecot to apply these changues</p>
<blockquote><p>systemctl restart dovecot.service</p></blockquote>
<p>check service status if something is bad</p>
<blockquote><p>systemctl status dovecot.service</p></blockquote>
<p>now you can send a gtube string to yourself, it should appear in junk folder</p>
<pre class="brush: plain; title: ; notranslate">

May 12 12:01:07 mail postfix/submission/smtpd[12410]: connect from yourcomputer[yourip]
May 12 12:01:07 mail postfix/submission/smtpd[12410]: 8D6F310095C: client=XEON.cafeingles[yourip], sasl_method=PLAIN, sasl_username=destination@domain.com
May 12 12:01:07 mail postfix/cleanup[12420]: 8D6F310095C: message-id=&amp;amp;lt;5551CF63.8070307@yourfqdnsourcedomain.com&amp;amp;gt;
May 12 12:01:07 mail postfix/qmgr[1977]: 8D6F310095C: from=&amp;amp;lt;destination@domain.com&amp;amp;gt;, size=629, nrcpt=1 (queue active)
May 12 12:01:07 mail postfix/submission/smtpd[12410]: disconnect from XEON.cafeingles[yourip]
May 12 12:01:07 mail amavis[2763]: (02763-08) NOTICE: reconnecting in response to: err=2006, HY000, DBD::mysql::st execute failed: MySQL server has gone away at (eval 129) line 172.
May 12 12:01:08 mail postfix/smtpd[12427]: connect from localhost[127.0.0.1]
May 12 12:01:08 mail postfix/smtpd[12427]: 74AB1100960: client=localhost[127.0.0.1]
May 12 12:01:08 mail postfix/cleanup[12420]: 74AB1100960: message-id=&amp;amp;lt;5551CF63.8070307@yourfqdnsourcedomain.com&amp;amp;gt;
May 12 12:01:08 mail postfix/qmgr[1977]: 74AB1100960: from=&amp;amp;lt;destination@domain.com&amp;amp;gt;, size=1395, nrcpt=1 (queue active)
May 12 12:01:08 mail postfix/smtpd[12427]: disconnect from localhost[127.0.0.1]
May 12 12:01:08 mail amavis[2763]: (02763-08) Passed SPAM {RelayedTaggedInternal,Quarantined}, MYNETS LOCAL [yourip]:36125 &amp;amp;lt;destination@domain.com&amp;amp;gt; -&amp;amp;gt; &amp;amp;lt;destination@domain.com&amp;amp;gt;, Queue-ID: 8D6F310095C, Message-ID: &amp;amp;lt;5551CF63.8070307@yourfqdnsourcedomain.com&amp;amp;gt;, mail_id: PxRBJkjebYHJ, Hits: 999.001, size: 629, queued_as: 74AB1100960, 885 ms
May 12 12:01:08 mail postfix/smtp[12421]: 8D6F310095C: to=&amp;amp;lt;destination@domain.com&amp;amp;gt;, relay=127.0.0.1[127.0.0.1]:10024, delay=0.99, delays=0.04/0.03/0.02/0.89, dsn=2.0.0, status=sent (250 2.0.0 from MTA(smtp:[127.0.0.1]:10025): 250 2.0.0 Ok: queued as 74AB1100960)
May 12 12:01:08 mail postfix/qmgr[1977]: 8D6F310095C: removed
May 12 12:01:08 mail dovecot: lmtp(12429): Connect from local
May 12 12:01:08 mail dovecot: lmtp(12429, destination@domain.com): UOvhIGTPUVWNMAAAiaI7Ow: sieve: msgid=&amp;amp;lt;5551CF63.8070307@yourfqdnsourcedomain.com&amp;amp;gt;: stored mail into mailbox 'Junk'
May 12 12:01:08 mail postfix/lmtp[12428]: 74AB1100960: to=&amp;amp;lt;destination@domain.com&amp;amp;gt;, relay=mail.yourfqdn.com[private/dovecot-lmtp], delay=0.1, delays=0.01/0.03/0.03/0.02, dsn=2.0.0, status=sent (250 2.0.0 &amp;amp;lt;destination@domain.com&amp;amp;gt; UOvhIGTPUVWNMAAAiaI7Ow Saved)
May 12 12:01:08 mail postfix/qmgr[1977]: 74AB1100960: removed
May 12 12:01:08 mail dovecot: lmtp(12429): Disconnect from local: Successful quit
</pre>
<p>and your mail client should show a new mail in junk folder</p>
<p><a href="https://www.luzem.com/wp-content/uploads/2015/05/spam_in_junk_folder.png"><img class="aligncenter size-full wp-image-3850" src="https://www.luzem.com/wp-content/uploads/2015/05/spam_in_junk_folder.png" alt="spam in junk folder" width="195" height="100" /></a></p>
<p><strong>Step 36: Training spamassasin</strong></p>
<p>Our detected spam travels to junk folder, but if forget to train spamassasin we will get a lot of spam in our Inbox folder or false positives in our Junk folder.</p>
<p>To avoid this we can launch sa-learn command but do this by hand is a tedious work. Good sysadmins automatize these task, I make a small script in python, my first python script, to launch sa-learn automatically.</p>
<p>This script will scan each mailbox and check if user has created an extra imap folder, to ignore pop3 only users, adding all mail in junk folder as spam and rest of folders as ham mail.</p>
<p>I created a project in github if you want to colaborate I will accept all help</p>
<p><a href="https://github.com/luzemail/spamAssasingTraining">https://github.com/luzemail/spamAssasingTraining</a></p>
<p>to add this script to our server we will execute a set of commands</p>
<p>&nbsp;</p>
<blockquote><p>cd /var/vmail</p>
<p>wget https://raw.githubusercontent.com/luzemail/spamAssasingTraining/master/trainspamassasin.py</p>
<p>chmod +x trainspamassasin.py</p></blockquote>
<p>now we will add a crontab line to execute this script all days</p>
<blockquote><p>vim /etc/crontab</p></blockquote>
<p>add this line</p>
<pre class="brush: plain; title: ; notranslate">

0  0  *  *  * vmail       /var/vmail/trainspamassasin.py

</pre>
<p>adding a little of python magic helps to forget about what is learning spamassasin.</p>
<p>A small trick to start this is tell to our user that they should create a folder called nospam or whatever you prefer and recommend  users to move false posivitives to this folder and undetected spam to junk folder.</p>
<p>This script scans all mail folders in account and ads all mail as ham except junk folder which is added as spam. You should need to change this behavior feel free to modify this script and colaborate.</p>
<p><strong> Step 37:Enabling greylisting (optional)</strong></p>
<p>One technique to avoid spam is use a greylisting, basically when we receive a mail for first time our mailserver will answer with an internal error forcing to sender, if senders server is well configures it will try in a few minutes to deliver message again and it will be acepted. Spamers doesn&#8217;t resend emails they simply forget our mailserver.</p>
<p>So using a greylisting adds delay receiving mails or they can be undelivered because another server isn&#8217;t well configured.</p>
<p>first we need to install postgrey</p>
<blockquote><p>yum install postgrey</p></blockquote>
<p>postgrey works as a daemon we need to activate it</p>
<blockquote><p>systemctl start postgrey.service</p></blockquote>
<p>and enable service</p>
<blockquote><p>systemctl enable postgrey.service</p></blockquote>
<p>we can check postgrey service status running</p>
<blockquote><p>systemctl status postgrey.service</p></blockquote>
<p>we should get an output like this</p>
<pre class="brush: plain; title: ; notranslate">

postgrey.service - Postfix Greylisting Service
Loaded: loaded (/usr/lib/systemd/system/postgrey.service; disabled)
Active: active (running) since Sat 2015-05-23 15:35:24 CEST; 13s ago
Docs: man:postgrey(8)
Process: 8176 ExecStart=/usr/sbin/postgrey --unix=/var/spool/postfix/postgrey/socket --pidfile=/var/run/postgrey.pid --group=postgrey --user=postgrey --greylist-text=Greylisted for %%s seconds --daemonize $POSTGREY_OPTS (code=exited, status=0/SUCCESS)
Process: 8173 ExecStartPre=/bin/rm -f /var/run/postgrey.pid (code=exited, status=0/SUCCESS)
Main PID: 8177 (/usr/sbin/postg)
CGroup: /system.slice/postgrey.service
└─8177 /usr/sbin/postgrey --unix=/var/spool/postfix/postgrey/socket --pidfile=/var/run/postgrey.pid --group=postgrey --user=postgrey --greylist-text=Greylisted for %s seconds --daemonize --delay=60...

</pre>
<p>now we need to link postgrey with postfix</p>
<p>just edit postfix config file</p>
<blockquote><p>vim /etc/postfix/main.cf</p></blockquote>
<p>and append these lines</p>
<pre class="brush: plain; title: ; notranslate">

smtpd_recipient_restrictions =
permit_mynetworks,
permit_sasl_authenticated,
check_policy_service unix:/var/spool/postfix/postgrey/socket

</pre>
<p>and restart  postfix service</p>
<blockquote><p> systemctl restart postfix.service</p></blockquote>
<p>if you need to modify postgrey behavior you can use these files:</p>
<ul>
<li>/etc/postfix/postgrey_whitelist_clients</li>
<li>/etc/postfix/postgrey_whitelist_recipients</li>
<li>/etc/postfix/postgrey_whitelist_clients.local</li>
</ul>
<p>&nbsp;</p>
<p><strong> Step 38: Configuring smtpd_recipient_restrictions<br />
</strong></p>
<p>Like greylisting we can add some restrictions when receiving email to avoid receive unsolicited mail.</p>
<p>we can add these restriction to our smtpd_sender_restrictions line</p>
<ul>
<li>reject_unknown_address &#8211;&gt; mails without from</li>
<li>reject_unknown_sender_domain &#8211;&gt; no know sender</li>
<li>reject_invalid_hostname &#8211;&gt; when a server make helo with a malformed hostname</li>
<li>reject_unknown_recipient_domain &#8211;&gt; If postfix is not final distination for recipient domain</li>
<li>reject_unauth_pipelining &#8211;&gt; stops mail from bulk mail software that doesn&#8217;t comply ESMTP command pipelining</li>
</ul>
<p>finally we can use RBL&#8217;s, Real time Blackhole lists is a list of know spammers ips that will be rejected by postfix</p>
<p>command is basically</p>
<pre class="brush: plain; title: ; notranslate">

reject_rbl_client server1,

reject_rbl_client server2,

....,

reject_rbl_client servern,

permit

</pre>
<p>this will help you to stop a lot of spam and free system resources.</p>
<p>here you get a list of rbls <a href="http://en.wikipedia.org/wiki/Comparison_of_DNS_blacklists">http://en.wikipedia.org/wiki/Comparison_of_DNS_blacklists</a></p>
<p>here you have an example configuration</p>
<blockquote><p>vim /etc/postfix/main.cf</p></blockquote>
<pre class="brush: plain; title: ; notranslate">

smtpd_recipient_restrictions =
reject_invalid_hostname,
reject_unknown_recipient_domain,
reject_unauth_pipelining,
permit_mynetworks,
reject_unauth_destination,
permit_sasl_authenticated,
check_policy_service unix:/var/spool/postfix/postgrey/socket,
reject_rbl_client zen.spamhaus.org,
reject_rbl_client bl.spamcop.net,
reject_rbl_client dnsbl.sorbs.net,
reject_rbl_client cbl.abuseat.org,
reject_rbl_client b.barracudacentral.org,
reject_rbl_client dnsbl-1.uceprotect.net,
permit

</pre>
<p>and finally restart postfix</p>
<blockquote><p> systemctl restart postfix.service</p></blockquote>
<p><strong> Step 39: Enabling spf<br />
</strong></p>
<p>SPF (Sender Policy Framework) is basically a TXT dns record that indicates what ips and/or domains are authorized to send email.</p>
<p>A minimal spf record should be like this</p>
<pre class="brush: plain; title: ; notranslate">

spf=v1 mx -all

</pre>
<p>if your webserver send emails too</p>
<pre class="brush: plain; title: ; notranslate">

spf=v1 a mx -all

</pre>
<p>if you want to add an ip</p>
<pre class="brush: plain; title: ; notranslate">

spf=v1 a mx ip4:255.255.255.255 -all

</pre>
<p>&nbsp;</p>
<p>in function of what servers will be generating email you should configure your spf records.</p>
<p>Maintain a spf record in your domains is important to avoid that spammers use your domain as as sender part of domain</p>
<p><strong>Step 40: Enabling DKIM<br />
</strong></p>
<p>DKIM, DomainKeys Identified Mail, helps to verify that a received email is sender from a valid mail server. Basically is a digital signature that can be verified using a public key published into senders domain dns record.</p>
<p>We need to generate a public and private key for each domain.</p>
<p>basically for each domain we need to execute a command like this</p>
<p>opendkim-genkey &#8211;bits=4096 &#8211;domain=example.com &#8211;selector=example.com &#8211;restrict</p>
<p>be careful with your dns provider 4096 bits could generate a long public key that couldn&#8217;t fit in your txt box, in this case you can reduce your key length to 2048 or changue dns provider</p>
<p>for generate these keys we should follow these steps:</p>
<p>go to opendkim keys dir</p>
<blockquote><p>cd /etc/opendkim/keys</p></blockquote>
<p>generate one keypair for each domain</p>
<blockquote><p>opendkim-genkey &#8211;bits=4096 &#8211;domain=example.com &#8211;selector=example.com &#8211;restrict</p></blockquote>
<p>this command will create two files</p>
<ul>
<li>domain.com.private your private key</li>
<li>domain.com.txt contains public part in dns record format</li>
</ul>
<p>Note: your should renew your keys every year.</p>
<p>we will to changue private keys ownership</p>
<blockquote><p> chown opendkim:opendkim /etc/opendkim/keys/*.private</p></blockquote>
<p>we need to configure opendkim edit config file</p>
<blockquote><p>vim /etc/opendkim.conf</p></blockquote>
<p>options should be like these</p>
<pre class="brush: plain; title: ; notranslate">
PidFile    /var/run/opendkim/opendkim.pid
Mode    sv
Syslog    yes
SyslogSuccess    yes
LogWhy    yes
UserID    opendkim:opendkim
Socket    inet:8891@localhost
Umask    002
Canonicalization    relaxed/relaxed
Selector    default
MinimumKeyBits 1024
KeyTable    refile:/etc/opendkim/KeyTable
SigningTable    refile:/etc/opendkim/SigningTable
ExternalIgnoreList    refile:/etc/opendkim/TrustedHosts
InternalHosts    refile:/etc/opendkim/TrustedHosts
</pre>
<p>OpenDKim needs a list of host whose mail should signed by Opendkim-</p>
<blockquote><p>vim /etc/opendkim/TrustedHosts</p></blockquote>
<p>content should be like these</p>
<pre class="brush: plain; title: ; notranslate">

127.0.0.1
::1
mail.yourdomain.com

</pre>
<p>mail.yourdomain.com should be your hostname</p>
<p>all mail originated from these host will be signed otherwise is ignored, if you have a relay server you should add these ip.</p>
<p>We will host several domains in our configuration, OpenDkim needs to know a list of domains and keys to sign.</p>
<blockquote><p>vim /etc/opendkim/KeyTable</p></blockquote>
<p>we need to link each domain with one key adding lines like this</p>
<pre class="brush: plain; title: ; notranslate">

default._domainkey.domain1.com domain1.com:default:/etc/opendkim/keys/domain1.com.private
default._domainkey.domain2.com domain2.com:default:/etc/opendkim/keys/domain2.com.private

</pre>
<p>using these list opendkim knows relations between domains and private keys.</p>
<p>now opendkim needs to know relation between mail adress and domains whe should configure SigningTable file</p>
<p>vim /etc/opendkim/SigningTable</p>
<p>if we want to sign all email address we shoild add a line like these</p>
<pre class="brush: plain; title: ; notranslate">

*@domain1.com default._domainkey.domain1.com

*@domain2.com default._domainkey.domain2.com

</pre>
<p>complete with all your domains and restart opendkim</p>
<blockquote><p>systemctl restart opendkim.service</p></blockquote>
<p>now you can check opendkim service status</p>
<blockquote><p> systemctl status opendkim.service</p></blockquote>
<p>output should be like these</p>
<pre class="brush: plain; title: ; notranslate">

opendkim.service - DomainKeys Identified Mail (DKIM) Milter
Loaded: loaded (/usr/lib/systemd/system/opendkim.service; enabled)
Active: active (running) since Wed 2015-05-27 16:26:39 CEST; 1s ago
Docs: man:opendkim(8)
man:opendkim.conf(5)
man:opendkim-genkey(8)
man:opendkim-genzone(8)
man:opendkim-testadsp(8)
man:opendkim-testkey
http://www.opendkim.org/docs.html
Process: 23824 ExecStart=/usr/sbin/opendkim $OPTIONS (code=exited, status=0/SUCCESS)
Main PID: 23825 (opendkim)
CGroup: /system.slice/opendkim.service
└─23825 /usr/sbin/opendkim -x /etc/opendkim.conf -P /var/run/opendkim/opendkim.pid

May 27 16:26:39 mail.yourdomain.com systemd[1]: Started DomainKeys Identified Mail (DKIM) Milter.
May 27 16:26:39 mail.yourdomain.com opendkim[23825]: OpenDKIM Filter v2.10.1 starting (args: -x /etc/opendkim.conf -P /var/run/opendkim/opendkim.pid)

</pre>
<p>At this point we have a opendkim daemon working we need to integrate opendkim with postfix</p>
<p>we need to open postfix main config file</p>
<blockquote><p>vim /etc/postfix/main.cf</p></blockquote>
<p>and finally append these lines</p>
<pre class="brush: plain; title: ; notranslate">

milter_default_action = accept
smtpd_milters = inet:127.0.0.1:8891

</pre>
<p>and restart postfix to see these changues applied</p>
<blockquote><p>systemctl restart postfix.service</p></blockquote>
<p>Finally the most important step is publish your public keys in each domain</p>
<p>for example for a file example.com.txt</p>
<p>whit these content</p>
<pre class="brush: plain; title: ; notranslate">

example.com._domainkey    IN    TXT    ( &amp;amp;quot;v=DKIM1; k=rsa; s=email; &amp;amp;quot;
&amp;amp;quot;p=MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAzGqMtyZwjFzNsvFVSnsPvyHcsAGpqglHcKtRSIGKyzbAigp18LARojk5UlTAHmED46THNbo8q6IS/fysaGBBR97oZLK2/8Vl6FOc0hdU1alEaAr/MpI+0MquCqjaAFdVWKHtGRthCzJ0HuDqbQFBnc3eUOe8RxkYWwxyKs+Tze/FCQ/mso/Gm/Zp/z7v8jTRbaIZtKRB+1oBrc&amp;amp;quot;
&amp;amp;quot;L2WuFEOkZyxCEq0gYLNV2AYcfIdvBXqHsHLeeEZMEbxIHOQGg3fINd3bbP2hxWtlnCrIGFQxdkOH4hx75wfZ+QRWh0d7jmW4c0Jnwvw0HLIJSzfS1kOUCPSq+MR7h4bT17sfWMXSvwqWca1R0eVRZdkuuBBeK5897vvRCA/44WMhv2GeWM6uHrRLy8Z8CAoCVd4FrZ6UQ+eQ2SjJaObInWbXC0/VRNHLRHVqW3pZROH3tYWAD39EUKpAWO&amp;amp;quot;
&amp;amp;quot;vr6YfwD/7PeM/283LLDuQceqIVg4kYcNeZR9iL65sLXWkHPb8rJeGFqQhUC+Cvm1HkhLbm5m/OHl41EF+dfLDT+c8EpCT3khSebKvwHFbd2l6XQhy+zQSvQtPSgtWJ2mgq4FIHFBJFdQRUv/KQdhDDapYkcM80DyyRnzXv4erfNcC//LaI4LmJBd36KTNKWUbrBibxOWye3ZheiaPGYrdwrp/X0rPXnnju8CAwEAAQ==&amp;amp;quot; )  ; ----- DKIM key example.com for example.com

</pre>
<p>you need to add a _domainkey txt record whit this text</p>
<pre class="brush: plain; title: ; notranslate">

v=DKIM1; k=rsa; s=email; p=MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAzGqMtyZwjFzNsvFVSnsPvyHcsAGpqglHcKtRSIGKyzbAigp18LARojk5UlTAHmED46THNbo8q6IS/fysaGBBR97oZLK2/8Vl6FOc0hdU1alEaAr/MpI+0MquCqjaAFdVWKHtGRthCzJ0HuDqbQFBnc3eUOe8RxkYWwxyKs+Tze/FCQ/mso/Gm/Zp/z7v8jTRbaIZtKRB+1oBrcL2WuFEOkZyxCEq0gYLNV2AYcfIdvBXqHsHLeeEZMEbxIHOQGg3fINd3bbP2hxWtlnCrIGFQxdkOH4hx75wfZ+QRWh0d7jmW4c0Jnwvw0HLIJSzfS1kOUCPSq+MR7h4bT17sfWMXSvwqWca1R0eVRZdkuuBBeK5897vvRCA/44WMhv2GeWM6uHrRLy8Z8CAoCVd4FrZ6UQ+eQ2SjJaObInWbXC0/VRNHLRHVqW3pZROH3tYWAD39EUKpAWOr6YfwD/7PeM/283LLDuQceqIVg4kYcNeZR9iL65sLXWkHPb8rJeGFqQhUC+Cvm1HkhLbm5m/OHl41EF+dfLDT+c8EpCT3khSebKvwHFbd2l6XQhy+zQSvQtPSgtWJ2mgq4FIHFBJFdQRUv/KQdhDDapYkcM80DyyRnzXv4erfNcC//LaI4LmJBd36KTNKWUbrBibxOWye3ZheiaPGYrdwrp/X0rPXnnju8CAwEAAQ=

</pre>
<p><strong>Step 41: Configuring DMARC records for each domain</strong></p>
<p>Basically Dmarc is a method that joins SPF and DKIM defining what to do when a received mail doesn&#8217;t pass DKIM or SPF</p>
<p>we need to create a DNS TXT record like _dmarc.your_domain.com</p>
<p>with this text</p>
<p>v=DMARC1 p=pvalue optinalparameter1=value optinalparameter2=value &#8230;</p>
<p><span style="text-decoration: underline;"><strong>Mandatory Parameters</strong></span></p>
<p><strong>Policy of domain</strong><br />
p= pvalues<br />
Defines policy of domain.</p>
<p>pvalues are:</p>
<ul>
<li>none -&gt;The Domain Owner requests no specific action be taken regarding delivery of messages</li>
<li>quarantine -&gt; if check dkim and/or spf fails, Depending on the capabilities of the Mail Receiver, this can mean &#8220;place into spam folder&#8221;, &#8220;scrutinize with additional intensity&#8221;, and/or &#8220;flag as suspicious&#8221;.</li>
<li>reject  -&gt; check dkim and/or spf fails Mail Receiver will reject mail during smtp transaction</li>
</ul>
<p><span style="text-decoration: underline;"><strong>Optional Parameters</strong></span></p>
<p><strong>Policy of Subdomains</strong></p>
<p>sp= spvalues</p>
<p>spvalues are:</p>
<ul>
<li>none -&gt;The Domain Owner requests no specific action be taken regarding delivery of messages</li>
<li>quarantine -&gt; if check dkim and/or spf fails, Depending on the capabilities of the Mail Receiver, this can mean &#8220;place into spam folder&#8221;, &#8220;scrutinize with additional intensity&#8221;, and/or &#8220;flag as suspicious&#8221;.</li>
<li>reject  -&gt; check dkim and/or spf fails Mail Receiver will reject mail during smtp transaction</li>
</ul>
<p><strong>DKIM identifier alignment</strong></p>
<p>adkim= dkimvalues</p>
<p>dkimvalues are:</p>
<p>s -&gt; strict, sender domain name must be the same that d=name in DKIM mail headers else fails<br />
r-&gt; relaxed, if sender domain is a subdomain will pass</p>
<p>if omitted adkim tag in domain txt default value is r (relaxed)</p>
<p><strong>SPF-authenticated Identifiers</strong></p>
<p>aspf= aspfvalues</p>
<p>aspfvalues are:</p>
<p>s -&gt; strict, MAIL FROM command in SMTP and from:header in email must mach<br />
r-&gt; relaxed, if sender domain is a subdomain will pass</p>
<p>if omitted aspf tag in domain txt default value is r (relaxed)</p>
<p><strong>Percentage of messages where DMARC mechanism is to be applied</strong></p>
<p>pct=pctvalue</p>
<p>pctvalue= a number between 0 and 100</p>
<p><strong>Interval between Aggregaye reports</strong><br />
ri = rivalue</p>
<p>rivalue= number of seconds between reports default 86400 (24 hours)</p>
<p><strong>Reporting URL of aggregate reports</strong></p>
<p>rua:mailto:address@domain.com</p>
<p>Each server will send an aggregate feedback to this adress</p>
<p>if domain lies outside sending zone you must validate, use a web searcher</p>
<p><strong>Reporting URL of aggregate feedback</strong></p>
<p>ruf:mailto:address@domain.com</p>
<p>Used for forensic reports about messagest that fail spf and/or dkim evaluation</p>
<p>if domain lies outside sending zone you must validate, use a web searcher</p>
<p>here you have a example of dmarc record</p>
<pre class="brush: plain; title: ; notranslate">

v=DMARC1; p=quarantine; pct=100 rua=mailto:dmarc.rua@customddomain.com

</pre>
<p>DMARC is not a point and shoot implementation you should follow a sequence like this in function of your mail volume:</p>
<ol>
<li>    Monitor all.</li>
<li>   Quarantine 1%.</li>
<li>    Quarantine 5%.</li>
<li>    Quarantine 10%.</li>
<li>  Quarantine 25%.</li>
<li>  Quarantine 50%.</li>
<li>  Quarantine all.</li>
<li>  Reject 1%.</li>
<li>  Reject 5%.</li>
<li>  Reject 10%.</li>
<li>  Reject 25%.</li>
<li>  Reject 50%.</li>
<li>  Reject all.</li>
</ol>
<p>&nbsp;</p>
<p><strong>Step 42: Enabling DMARC suport in postfix<br />
</strong></p>
<p>Receive reports from DMARC helps to verify our configurations, configure a mailserver that send DMARC reports to another sysadmins makes you a good sysadmin and a better person :-P.</p>
<p>To make this we need to configure openDMARC</p>
<p>Actually in centos 7 openDMARC needs libspf2 that is avaliable in testing repo.</p>
<p>if you try to install opendmarc running this command</p>
<blockquote><p>yum install opendmarc</p></blockquote>
<p>and you get an output like these</p>
<pre class="brush: plain; title: ; notranslate">

---&amp;amp;gt; Package libopendmarc.x86_64 0:1.3.1-4.el7 will be updated
---&amp;amp;gt; Package libopendmarc.x86_64 0:1.3.1-13.el7 will be an update
--&amp;amp;gt; Processing Dependency: libspf2.so.2()(64bit) for package: libopendmarc-1.3.1-13.el7.x86_64
---&amp;amp;gt; Package opendmarc.x86_64 0:1.3.1-4.el7 will be updated
---&amp;amp;gt; Package opendmarc.x86_64 0:1.3.1-13.el7 will be an update
--&amp;amp;gt; Processing Dependency: libspf2.so.2()(64bit) for package: opendmarc-1.3.1-13.el7.x86_64
--&amp;amp;gt; Finished Dependency Resolution
Error: Package: libopendmarc-1.3.1-13.el7.x86_64 (epel)
Requires: libspf2.so.2()(64bit)
Error: Package: opendmarc-1.3.1-13.el7.x86_64 (epel)
Requires: libspf2.so.2()(64bit)
You could try using --skip-broken to work around the problem
You could try running: rpm -Va --nofiles --nodigest

</pre>
<p>run this command</p>
<p>yum install opendmarc &#8211;enablerepo=epel-testing</p>
<p>OpenDMARK will need a MariaDB database  in order to store all info needed to generate reports.</p>
<p>We will create this database as first step</p>
<blockquote><p>  mysql -u root -p</p></blockquote>
<pre class="brush: sql; title: ; notranslate">
CREATE DATABASE opendmarc;
CREATE USER 'dmarc'@'localhost' IDENTIFIED BY 'dmarcdatabaseuserpassword';
GRANT ALL PRIVILEGES ON `opendmarc` . * TO 'dmarc'@'localhost';
FLUSH PRIVILEGES;
quit;

</pre>
<p>once we&#8217;ve created database and user, next step is populate tables.</p>
<blockquote><p>mysql -u dmarc -p opendmarc &lt; /usr/share/doc/opendmarc-1.3.1/schema.mysql</p></blockquote>
<p>should be easy now we can configure opendmarc</p>
<p>vim /etc/opendmarc.conf</p>
<p>replace line 15 to have these aspect</p>
<pre class="brush: plain; title: ; notranslate">

AuthservID HOSTNAME

</pre>
<p>now we will configure opendmarc service</p>
<pre class="brush: plain; title: ; notranslate">

systemctl enable opendmarc
systemctl start opendmarc

</pre>
<p>next step is integrate opendmarc service with postfix</p>
<blockquote><p>vim /etc/postfix/main.cf</p></blockquote>
<p>just modify smtpd_milters values</p>
<pre class="brush: plain; title: ; notranslate">

smtpd_milters = inet:127.0.0.1:8891 , inet:127.0.0.1:8893
non_smtpd_milters = $smtpd_milters

</pre>
<p>now you can restart postfix</p>
<blockquote><p>systemctl restart postfix.service</p></blockquote>
<p>some domains can use aname.domain.com instead top-level domain this can be a problem during dmarc verification, Mozilla maintais a database calle Public Suffix list that can be added to our opendmarc server to make it more effective</p>
<p>just execute these commands</p>
<blockquote><p>/usr/bin/wget &#8211;no-check-certificate -q -N -P /etc/opendmarc https://publicsuffix.org/list/effective_tld_names.dat<br />
chown opendmarc:opendmarc /etc/opendmarc/effective_tld_names.dat</p></blockquote>
<p>we should maintain this database updated we can add a cron job to do this job</p>
<p>just edit crontab</p>
<p>vim /etc/crontab</p>
<p>and append these line</p>
<pre class="brush: plain; title: ; notranslate">

@weekly /usr/bin/wget --no-check-certificate -q -N -P /etc/opendmarc https://publicsuffix.org/list/effective_tld_names.dat #Get latest effective_tld_names for OpenDMARC

</pre>
<p>Opendmarc needs know where Pubblic Suffix List is located</p>
<blockquote><p>vim /etc/opendmarc.conf</p></blockquote>
<p>line 221 should be like this</p>
<pre class="brush: plain; title: ; notranslate">

PublicSuffixList /etc/opendmarc/effective_tld_names.dat

</pre>
<p>we will restart opendmarc service to apply configuration changes</p>
<blockquote><p>systemctl restart opendmarc</p></blockquote>
<p>now we will configure opendmarc to maintain a history file</p>
<blockquote><p>vim /etc/opendmarc.conf</p></blockquote>
<p>uncomment line 166</p>
<pre class="brush: plain; title: ; notranslate">

HistoryFile /var/spool/opendmarc/opendmarc.dat

</pre>
<p>and restart opendmarc again</p>
<blockquote><p>systemctl restart opendmarc</p></blockquote>
<p>now we will process this file with a script every hour</p>
<blockquote><p>vim /etc/cron.hourly/processdmarc.cron</p></blockquote>
<p>it should have this content.</p>
<p><span style="text-decoration: underline;">Remenber put your dmarc password in dbpass variable</span></p>
<p><span style="text-decoration: underline;">and correct domain settings in /usr/sbin/opendmarc-reports command</span></p>
<pre class="brush: bash; title: ; notranslate">
#!/bin/bash
# Imports data from OpenDMARC's opendmarc.dat file into a local MySQL DB
# and sends DMARC failure reports to domain owners.
# Based on a script from Hamzah Khan (http://blog.hamzahkhan.com/)

set -e

# Database and History File Info
DBHOST='localhost'
DBUSER='dmarc'
DBPASS='yourpassword'
DBNAME='opendmarc'
HISTDIR='/var/spool/opendmarc'
HISTFILE='opendmarc'

# Make sure history file exists
touch ${HISTDIR}/${HISTFILE}.dat

# Move history file temp dir for processing
mv ${HISTDIR}/${HISTFILE}.dat /tmp/${HISTFILE}.$$

# Import temp history file data and send reports
/usr/sbin/opendmarc-import -dbhost=${DBHOST} -dbuser=${DBUSER} -dbpasswd=${DBPASS} -dbname=${DBNAME} -verbose &amp;amp;lt; /tmp/${HISTFILE}.$$
/usr/sbin/opendmarc-reports -dbhost=${DBHOST} -dbuser=${DBUSER} -dbpasswd=${DBPASS} -dbname=${DBNAME} -verbose -interval=86400 -report-email 'postmaster@cheatcodes.com' -report-org 'CheatCodes.com'
/usr/sbin/opendmarc-expire -dbhost=${DBHOST} -dbuser=${DBUSER} -dbpasswd=${DBPASS} -dbname=${DBNAME} -verbose

# Delete temp history file
rm -rf /tmp/${HISTFILE}.$$

</pre>
<p>finaly we will make this file executable</p>
<blockquote><p>chmod +x /etc/cron.hourly/processdmarc.cron</p></blockquote>
<p>Now your postfix has dmarc support and every hour will send necesary reports</p>
<p>&nbsp;</p>
<p><strong>Step 43: Configuring Roundcube webmail</strong></p>
<p style="text-align: left;">Smartphones are a inclredible good technology but sometimes we don&#8217;t have signal and we need to check our email, using roundcube we provide a webmail infrastructure to our users, where they can read and send emails using a web browser.</p>
<p style="text-align: left;">In order to configure roundcube we need to create a database, yes another one, using these  commands</p>
<blockquote>
<p style="text-align: left;">    mysql -u root -p</p>
</blockquote>
<pre class="brush: sql; title: ; notranslate">
CREATE DATABASE roundcubemail;
CREATE USER 'roundcube'@'localhost' IDENTIFIED BY 'a_secure_password';
GRANT ALL PRIVILEGES ON `roundcubemail` . * TO 'roundcube'@'localhost';
FLUSH PRIVILEGES;
quit;
 </pre>
<p>next step is populate tables</p>
<blockquote><p> mysql -uroundcube -p roundcube &lt;/usr/share/roundcubemail/SQL/mysql.initial.sql</p></blockquote>
<p>we also need to enable some selinux options for our case</p>
<p>setsebool -P httpd_can_sendmail on</p>
<p>now we need to configure roundcubemail to access database and know were are located the mailservers</p>
<p>we will move example config file to use as template</p>
<blockquote><p>mv /etc/roundcubemail/config.inc.php.sample /etc/roundcubemail/config.inc.ph</p></blockquote>
<p>we need to modify some values</p>
<pre class="brush: php; title: ; notranslate">

$config['db_dsnw'] = 'mysql://roundcube:your_password@localhost/roundcubemail';

$config['default_host'] = 'tls://yourfqdndomain.com';

$config['smtp_server'] = 'tls://yourfqdndomain.com';

$config['imap_auth_type'] = 'login';
$config['smtp_auth_type'] = 'login';
$config['smtp_port'] = 587;

$config['smtp_user'] = '%u';

$config['smtp_pass'] = '%p';

$config['des_key'] = 'PUTHEREA24CHARACTERRANDOMSTRING';

</pre>
<p>&nbsp;</p>
<p>next we need to generate php-fpm pool to server roundcubemail config</p>
<p>we will create a dir for store sessions</p>
<blockquote><p>mkdir /var/lib/php/yourfqdndomain.com</p></blockquote>
<p>adjust group ownership</p>
<blockquote><p>chown root:apache /var/lib/php/yourfqdndomain.com</p></blockquote>
<p>adjust group permissions</p>
<blockquote><p>chmod 770 /var/lib/php/yourfqdndomain.com</p></blockquote>
<p>and set a valid selinux labeling</p>
<blockquote><p>chcon -R -t httpd_var_run_t /var/lib/php/yourfqdndomain.com</p></blockquote>
<p>now we can create a valid  php-fpm pool</p>
<blockquote><p>vim /etc/php-fpm.d/yourfqdndomain.com.conf</p></blockquote>
<p>adapt this content</p>
<pre class="brush: plain; title: ; notranslate">

[yourfqdndomain]
listen = /var/run/php-fpm/yourfqdndomain.socket
listen.allowed_clients = 127.0.0.1
user = apache
group = apache
pm = dynamic
pm.max_children = 50
pm.start_servers = 5
pm.min_spare_servers = 3
pm.max_spare_servers = 35
slowlog = /var/log/php-fpm/yourfqdndomain.slow.log
rlimit_files = 1024
rlimit_core = 0
chdir = /usr/share/roundcubemail
php_flag[display_errors] = off
php_admin_value[error_log] = /var/log/php-fpm/yourfqdndomain-error.log
php_admin_flag[log_errors] = on
php_admin_value[memory_limit] = 128M
php_value[session.save_handler] = files
php_value[session.save_path] = /var/lib/php/yourfqdndomain.com

</pre>
<p>once edited we can restart php-fpm service to load new configuration</p>
<blockquote><p>systemctl restart php-fpm.service</p></blockquote>
<p>check if any error appears reading this command output</p>
<blockquote><p> systemctl status php-fpm.service</p></blockquote>
<p>next step is create a nginx record and certificate</p>
<p>nginx doesn&#8217;t have intermediate certificate config option we need to append pulic key with intermidiate certificate in one file executing a command like this.</p>
<blockquote><p>cat publiccertificate.crt intermediatecertificate.crt &gt; bundle_certificate.crt</p></blockquote>
<p>Order of cat command is important public certificate will be at the beginning otherwise you will get ssl errors in nginx.</p>
<p>finally we can create our nginx config file</p>
<blockquote><p>vim /etc/nginx/conf.d/yourfqdndomain.conf</p></blockquote>
<p>and adapt these template</p>
<pre class="brush: plain; title: ; notranslate">

server {

listen 80;
server_name yourfqdndomain.com;
error_log  /var/log/nginx/yourfqdndomain.error.log warn;
access_log  /var/log/nginx/yourfqdndomain.access.log;

return 301 https://$server_name$request_uri; # enforce https

}

server {

listen          443 ssl;
server_name    yourfqdndomain;

error_log  /var/log/nginx/yourfqdndomain.secure.error.log warn;
access_log  /var/log/nginx/yourfqdndomain.secure.access.log;

root            /usr/share/roundcubemail;
index           index.php;
charset         utf-8;

## SSL settings
ssl_certificate           /etc/pki/tls/certs/yourfqdndomain.bundle.crt;
ssl_certificate_key       /etc/pki/tls/private/yourfqdndomain.key;

ssl_protocols             TLSv1.2;
ssl_ciphers               &amp;amp;quot;EECDH+ECDSA+AESGCM:EECDH+aRSA+AESGCM:!aNULL:!eNULL:!LOW:!3DES:!MD5:!EXP:!PSK:!SRP:!DSS:!RC4&amp;amp;quot;;
ssl_prefer_server_ciphers on;
ssl_session_cache         shared:SSL:10m;
ssl_session_timeout       10m;
ssl_ecdh_curve            secp521r1;

add_header Strict-Transport-Security max-age=31536000;
# add_header X-Frame-Options DENY;

# auth_basic &amp;amp;quot;Restricted area&amp;amp;quot;;
# auth_basic_user_file /etc/nginx/passwd;

location / {
try_files $uri $uri/ index.php;
}

location ~/(plugins/enigma/home|bin|installer) {
      deny all;
      return 403;
}

location ~* \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
include       fastcgi_params;
fastcgi_pass  unix:/var/run/php-fpm/yourfqdndomain.socket;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}

}

</pre>
<p>now we should restart nginx</p>
<blockquote><p>systemctl restart nginx.service</p></blockquote>
<p>now we can open a web browser write our fqdn and check our roundcube webpage</p>
<p><a href="https://www.luzem.com/wp-content/uploads/2015/06/roundcube_login.png"><img class="aligncenter size-medium wp-image-3961" src="https://www.luzem.com/wp-content/uploads/2015/06/roundcube_login-300x171.png" alt="roundcube mail login" width="300" height="171" srcset="https://www.luzem.com/wp-content/uploads/2015/06/roundcube_login-300x171.png 300w, https://www.luzem.com/wp-content/uploads/2015/06/roundcube_login.png 552w" sizes="(max-width: 300px) 100vw, 300px" /></a>log with and account and check if everything is working, send an email respond create a folder &#8230;</p>
<p>Now you have a working webmail to your users <img src="https://s.w.org/images/core/emoji/2.2.1/72x72/1f61b.png" alt="😛" class="wp-smiley" style="height: 1em; max-height: 1em;" /> .</p>
<p><strong>Step 44: Protecting against brute force attacks using fail2ban<br />
</strong></p>
<p>At this point we are filtering spam and using a huge number of antispam technologies.  Unfortunately your mailserver will be exposed to internet and a lot of automatic tool will try get your passwords using bruteforce attacks.</p>
<p>To mitigate these actions we will use fail2ban, fail2ban reads system logs and block  temporaly a ip making a bruteforce attacks, generally this means that we attackers avoid our server because temporally block makes bruteforce attack imposible</p>
<p>To make this fail2ban read logs and counts invalid logins when a number of invalid logins is detected fail2ban adds a rule to firewalld blocking source ip of invalid logins during a penalty time, typical brute force attacks abandom because they can&#8217;t test more</p>
<p>first we need to enable several triggers in fail2ban</p>
<p>modifiy needed lines to sections look like these</p>
<blockquote><p>vim /etc/fail2ban/jail.conf</p></blockquote>
<pre class="brush: plain; title: ; notranslate">

...

[roundcube-auth]
enabled = true
port     = http,https
logpath  = /var/log/roundcubemail/errors

....

[postfix]
enabled = true
port     = smtp,465,submission
logpath  = %(postfix_log)s

....

[dovecot]
enabled = true
port    = pop3,pop3s,imap,imaps,submission,465,sieve
logpath = %(dovecot_log)s

...

[sieve]
enabled = true
port   = smtp,465,submission
logpath = %(dovecot_log)s

</pre>
<p>now we need to enable fail2ban service</p>
<blockquote><p>systemctl enable fail2ban.service</p></blockquote>
<p>and start service</p>
<blockquote><p> systemctl start fail2ban.service</p></blockquote>
<p><strong>Step 45: Enable imap quota</strong></p>
<p>Some users will send a lot of attachments , and they need to know how many free space leave in their mailbox, we will enable imap_quota plugin to avoid support call about that they can&#8217;t receive or send mails with titanic attachments.</p>
<p>Responsive of inform about how many free space left in their mailbox is dovecot, we need to enable some plugins.</p>
<blockquote><p>vim /etc/dovecot/conf.d/10-mail.conf</p></blockquote>
<p>line 208 should be</p>
<pre class="brush: plain; title: ; notranslate">

mail_plugins = $mail_plugins quota

</pre>
<blockquote><p>vim /etc/dovecot/conf.d/20-imap.conf</p></blockquote>
<p>line 56 should be</p>
<pre class="brush: plain; title: ; notranslate">

mail_plugins = $mail_plugins imap_quota

</pre>
<p>finally</p>
<blockquote><p>vim  /etc/dovecot/conf.d/90-quota.conf</p></blockquote>
<p>line 68 should look like these</p>
<pre class="brush: plain; title: ; notranslate">

quota = maildir:User quota

</pre>
<p>Now we need reboot dovecot service</p>
<blockquote><p> systemctl restart dovecot.service</p></blockquote>
<p>&nbsp;</p>
<p>congrats now you should have a funcional mailserver running.</p>
<p>&nbsp;</p>
<p><strong>References:</strong></p>
<p><a title="http://www.campworld.net/thewiki/pmwiki.php/LinuxServersCentOS/Cent6VirtMailServer" href="http://www.campworld.net/thewiki/pmwiki.php/LinuxServersCentOS/Cent6VirtMailServer">http://www.campworld.net/thewiki/pmwiki.php/LinuxServersCentOS/Cent6VirtMailServer</a></p>
<p><a title="http://dokuwiki.nausch.org/doku.php/centos:mail_c7:spam_7" href="http://dokuwiki.nausch.org/doku.php/centos:mail_c7:spam_7">http://dokuwiki.nausch.org/doku.php/centos:mail_c7:spam_7</a></p>
<p><a href="https://qmail.jms1.net/test-auth.shtml">https://qmail.jms1.net/test-auth.shtml</a></p>
<p><a href="http://en.linuxreviews.org/HOWTO_Stop_spam_using_Postfix">http://en.linuxreviews.org/HOWTO_Stop_spam_using_Postfix</a></p>
<p><a href="https://hynek.me/articles/hardening-your-web-servers-ssl-ciphers/">https://hynek.me/articles/hardening-your-web-servers-ssl-ciphers/</a></p>
<p><a href="https://www.ssllabs.com/downloads/SSL_TLS_Deployment_Best_Practices.pdf" target="_blank">https://www.ssllabs.com/downloads/SSL_TLS_Deployment_Best_Practices.pdf</a></p>
<p><a href="https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/7/html/Security_Guide/sec-Hardening_TLS_Configuration.html">https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/7/html/Security_Guide/sec-Hardening_TLS_Configuration.html</a></p>
<p><a href="https://www.df.eu/de/service/df-faq/cloudserver/anleitungen/spam-und-virenschutz-mit-postfix-debian/">https://www.df.eu/de/service/df-faq/cloudserver/anleitungen/spam-und-virenschutz-mit-postfix-debian/</a></p>
<p>https://z0z0.me/2014/10/26/install-postfix-dovecot-auth-tls-mysql-postfixadmin-spamassassin-and-clamav-on-centos7/</p>
<p><a href="https://www.2realities.com/blog/2014/02/13/secure-ssl-configuration-for-apache-postfix-dovecot/">https://www.2realities.com/blog/2014/02/13/secure-ssl-configuration-for-apache-postfix-dovecot/</a></p>
<p><a href="https://bettercrypto.org/">https://bettercrypto.org/</a></p>
<p><a href="https://wiki.gentoo.org/wiki/Complete_Virtual_Mail_Server">https://wiki.gentoo.org/wiki/Complete_Virtual_Mail_Server</a></p>
<p><a href="http://www.gentoo-wiki.info/Amavisd-new">http://www.gentoo-wiki.info/Amavisd-new</a></p>
<p><a href="http://www.iredmail.org/forum/topic3800-iredmail-support-localdomainsmaps-in-amavisdnew.html">http://www.iredmail.org/forum/topic3800-iredmail-support-localdomainsmaps-in-amavisdnew.html</a></p>
<p><a href="http://gogs.info/books/debian-mail/chunked/antispam.amavis.html">http://gogs.info/books/debian-mail/chunked/antispam.amavis.html</a></p>
<blockquote data-secret="3KDAY3CBOT" class="wp-embedded-content"><p><a href="http://www.nervous.it/2010/03/amavisd-and-per-user-spam-folder/">Per-user spam folder with Amavisd-new, Postfix+MySQL, virtual users, Dovecot</a></p></blockquote>
<p><iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted" src="http://www.nervous.it/2010/03/amavisd-and-per-user-spam-folder/embed/#?secret=3KDAY3CBOT" data-secret="3KDAY3CBOT" width="525" height="296" title="&#8220;Per-user spam folder with Amavisd-new, Postfix+MySQL, virtual users, Dovecot&#8221; &#8212; Luca Gibelli" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe></p>
<p><a href="https://github.com/hardware/nginx-config/blob/master/virtual-hosts/https/postfixadmin">https://github.com/hardware/nginx-config/blob/master/virtual-hosts/https/postfixadmin</a></p>
<p><a href="http://peketamin.hatenablog.jp/entry/2014/06/26/%28ubuntu_14_04%29_postfix_%E3%82%92%E5%A4%96%E9%83%A8%E3%81%8B%E3%82%89%E6%8E%A5%E7%B6%9A%E5%87%BA%E6%9D%A5%E3%82%8B%E3%82%88%E3%81%86%E3%81%AB%E3%81%99%E3%82%8B_%E2%86%92_dovecot_%E4%BD%BF%E3%81%A3">http://peketamin.hatenablog.jp/entry/2014/06/26/%28ubuntu_14_04%29_postfix_%E3%82%92%E5%A4%96%E9%83%A8%E3%81%8B%E3%82%89%E6%8E%A5%E7%B6%9A%E5%87%BA%E6%9D%A5%E3%82%8B%E3%82%88%E3%81%86%E3%81%AB%E3%81%99%E3%82%8B_%E2%86%92_dovecot_%E4%BD%BF%E3%81%A3</a></p>
<p><a href="https://community.rackspace.com/products/f/43/t/51">https://community.rackspace.com/products/f/43/t/51</a></p>
<p><a href="https://bugzilla.redhat.com/show_bug.cgi?id=1225596">https://bugzilla.redhat.com/show_bug.cgi?id=1225596</a></p>
<p><a href="http://www.zytrax.com/books/dns/ch9/dmarc.html">http://www.zytrax.com/books/dns/ch9/dmarc.html</a></p>
<p><a href="http://dmarc.org/draft-dmarc-base-00-01.txt">http://dmarc.org/draft-dmarc-base-00-01.txt</a></p>
<p><a href="http://www.stevejenkins.com/blog/2015/03/installing-opendmarc-rpm-via-yum-with-postfix-or-sendmail-for-rhel-centos-fedora/">http://www.stevejenkins.com/blog/2015/03/installing-opendmarc-rpm-via-yum-with-postfix-or-sendmail-for-rhel-centos-fedora/</a></p>
]]></content:encoded>
			<wfw:commentRss>https://www.luzem.com/2015/06/20/configure-centos-7-postfix-virtual-users/feed/</wfw:commentRss>
		<slash:comments>62</slash:comments>
		</item>
		<item>
		<title>Contraseñas router EPC3928AD</title>
		<link>https://www.luzem.com/2015/04/22/contrasenas-router-epc3928ad/</link>
		<comments>https://www.luzem.com/2015/04/22/contrasenas-router-epc3928ad/#comments</comments>
		<pubDate>Wed, 22 Apr 2015 17:35:58 +0000</pubDate>
		<dc:creator><![CDATA[Luzem]]></dc:creator>
				<category><![CDATA[Aparatitos]]></category>
		<category><![CDATA[EPC3928AD]]></category>
		<category><![CDATA[mundo-R]]></category>
		<category><![CDATA[R]]></category>

		<guid isPermaLink="false">http://luzem.dyndns.org/?p=3706</guid>
		<description><![CDATA[Si R te cambia tu router por un EPC3928AD estas son las contraseñas de acceso Sin aprovisionar, antes de que lo enchufes a R usuario y contraseña en blanco Aprovisionado, 45 minutos despues de que lo enchufes a R usuario admin contraseña: clientesR Si lo quereis poner en modo bridge debereis de aprovisionarlo para que &#8230; <p class="link-more"><a href="https://www.luzem.com/2015/04/22/contrasenas-router-epc3928ad/" class="more-link">Continue reading<span class="screen-reader-text"> "Contraseñas router EPC3928AD"</span></a></p>]]></description>
				<content:encoded><![CDATA[<p>Si R te cambia tu router por un EPC3928AD estas son las contraseñas de acceso</p>
<p><a href="https://www.luzem.com/wp-content/uploads/2015/04/EPC3928AD.png"><img class="size-medium wp-image-3707 aligncenter" src="https://www.luzem.com/wp-content/uploads/2015/04/EPC3928AD-300x266.png" alt="EPC3928AD" width="300" height="266" srcset="https://www.luzem.com/wp-content/uploads/2015/04/EPC3928AD-300x266.png 300w, https://www.luzem.com/wp-content/uploads/2015/04/EPC3928AD.png 362w" sizes="(max-width: 300px) 100vw, 300px" /></a></p>
<p><strong>Sin aprovisionar</strong>, antes de que lo enchufes a R</p>
<ul>
<li>usuario y contraseña en blanco</li>
</ul>
<p><strong>Aprovisionado</strong>, 45 minutos despues de que lo enchufes a R</p>
<ul>
<li>usuario admin</li>
<li>contraseña: clientesR</li>
</ul>
<p>Si lo quereis poner en modo bridge debereis de aprovisionarlo para que actualize el firmware.</p>
<p>Si tenias ip estatica, prepara el nombre del titular, en dni y los 6 ultimos digitos de la cuenta bancaria para verificar que eres tu el cliente</p>
]]></content:encoded>
			<wfw:commentRss>https://www.luzem.com/2015/04/22/contrasenas-router-epc3928ad/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Recovering passwords from a windows 2003 server</title>
		<link>https://www.luzem.com/2015/03/10/recovering-passwords-from-a-windows-2003-server/</link>
		<comments>https://www.luzem.com/2015/03/10/recovering-passwords-from-a-windows-2003-server/#respond</comments>
		<pubDate>Tue, 10 Mar 2015 21:20:05 +0000</pubDate>
		<dc:creator><![CDATA[Luzem]]></dc:creator>
				<category><![CDATA[Sistemas Operativos]]></category>
		<category><![CDATA[ophcrack]]></category>
		<category><![CDATA[recover password]]></category>
		<category><![CDATA[windows 2003 server]]></category>

		<guid isPermaLink="false">http://luzem.dyndns.org/?p=3398</guid>
		<description><![CDATA[Sometimes when a business decide to switch his computer maintenance to another company switched company rejects to give server passwords with or without good reason. There&#8217;s a lot of ways of reset administrator password, but recover any of then can be better. If you need to recover passwords from a windows 2003 server a easy &#8230; <p class="link-more"><a href="https://www.luzem.com/2015/03/10/recovering-passwords-from-a-windows-2003-server/" class="more-link">Continue reading<span class="screen-reader-text"> "Recovering passwords from a windows 2003 server"</span></a></p>]]></description>
				<content:encoded><![CDATA[<p>Sometimes when a business decide to switch his computer maintenance to another company switched company rejects to give server passwords with or without good reason.</p>
<p>There&#8217;s a lot of ways of reset administrator password, but recover any of then can be better.</p>
<p>If you need to recover passwords from a windows 2003 server a easy way is shutdown the server and start a linux live CD like ubuntu.</p>
<p>If you can access to windows filesystem you can access to SAM data, a database with local passwords <img src="https://s.w.org/images/core/emoji/2.2.1/72x72/1f61b.png" alt="😛" class="wp-smiley" style="height: 1em; max-height: 1em;" /> .</p>
<p>You only need to copy %SystemRoot%/system32/config directory to a flash memory or another storage device.</p>
<p>Install into another computer Ophcrack software. In my laptop running fedora 21 executeas root</p>
<blockquote><p>dnf install ophcrack</p></blockquote>
<p>Download XP rainbow tables from here<a title="ophcrack tables" href="http://ophcrack.sourceforge.net/tables.php"> http://ophcrack.sourceforge.net/tables.php</a></p>
<p>Open ophcrack</p>
<p>Click on Tables -&gt; install</p>
<p>and load downloaded tables</p>
<p><a href="https://www.luzem.com/wp-content/uploads/2015/03/ophcrack_load_tables.png"><img class="aligncenter size-medium wp-image-3424" src="https://www.luzem.com/wp-content/uploads/2015/03/ophcrack_load_tables-300x276.png" alt="ophcrack load tables" width="300" height="276" srcset="https://www.luzem.com/wp-content/uploads/2015/03/ophcrack_load_tables-300x276.png 300w, https://www.luzem.com/wp-content/uploads/2015/03/ophcrack_load_tables.png 508w" sizes="(max-width: 300px) 100vw, 300px" /></a></p>
<p>Now at load button select Encrypted SAM and open the folder %SystemRoot%/system32/config recovered using Linux liveCD</p>
<p><a href="https://www.luzem.com/wp-content/uploads/2015/03/ophcrack_main_window.png"><img class="aligncenter size-medium wp-image-3425" src="https://www.luzem.com/wp-content/uploads/2015/03/ophcrack_main_window-300x257.png" alt="ophcrack main window" width="300" height="257" srcset="https://www.luzem.com/wp-content/uploads/2015/03/ophcrack_main_window-300x257.png 300w, https://www.luzem.com/wp-content/uploads/2015/03/ophcrack_main_window.png 756w" sizes="(max-width: 300px) 100vw, 300px" /></a>and finally click on Crack button</p>
<p><a href="https://www.luzem.com/wp-content/uploads/2015/03/recovered_passwords.png"><img class="aligncenter size-medium wp-image-3426" src="https://www.luzem.com/wp-content/uploads/2015/03/recovered_passwords-291x300.png" alt="recovered passwords" width="291" height="300" srcset="https://www.luzem.com/wp-content/uploads/2015/03/recovered_passwords-291x300.png 291w, https://www.luzem.com/wp-content/uploads/2015/03/recovered_passwords-992x1024.png 992w, https://www.luzem.com/wp-content/uploads/2015/03/recovered_passwords.png 1105w" sizes="(max-width: 291px) 100vw, 291px" /></a>Only took half minute, literally in recover 13 of 14 passwords.</p>
<p>Enjoy</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>https://www.luzem.com/2015/03/10/recovering-passwords-from-a-windows-2003-server/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>creating replacing and resizing mdadm Raid 1</title>
		<link>https://www.luzem.com/2015/03/04/creating-replacing-and-resizing-mdadm-raid-1/</link>
		<comments>https://www.luzem.com/2015/03/04/creating-replacing-and-resizing-mdadm-raid-1/#comments</comments>
		<pubDate>Wed, 04 Mar 2015 22:05:43 +0000</pubDate>
		<dc:creator><![CDATA[Luzem]]></dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[changue drive]]></category>
		<category><![CDATA[mdadm]]></category>
		<category><![CDATA[raid]]></category>
		<category><![CDATA[raid 1]]></category>
		<category><![CDATA[replace hard disk]]></category>
		<category><![CDATA[resize]]></category>

		<guid isPermaLink="false">http://luzem.dyndns.org/?p=3391</guid>
		<description><![CDATA[Sometimes hardware Raid controllers are very expensive to fit in low budget solutions, when this happens you can use software raid, like mdadm. Normally hard disks have a limited lifetime. To avoid disasters I replace hard disk every two years, at same time that means that new hard disk will come in a bigger capacity. &#8230; <p class="link-more"><a href="https://www.luzem.com/2015/03/04/creating-replacing-and-resizing-mdadm-raid-1/" class="more-link">Continue reading<span class="screen-reader-text"> "creating replacing and resizing mdadm Raid 1"</span></a></p>]]></description>
				<content:encoded><![CDATA[<p><a href="https://www.luzem.com/wp-content/uploads/2015/03/wpid-wp-1425508841164.jpeg"><img class="aligncenter size-medium wp-image-3409" src="https://www.luzem.com/wp-content/uploads/2015/03/wpid-wp-1425508841164-300x225.jpeg" alt="Raid controller" width="300" height="225" srcset="https://www.luzem.com/wp-content/uploads/2015/03/wpid-wp-1425508841164-300x225.jpeg 300w, https://www.luzem.com/wp-content/uploads/2015/03/wpid-wp-1425508841164-1024x768.jpeg 1024w" sizes="(max-width: 300px) 100vw, 300px" /></a></p>
<p>Sometimes hardware Raid controllers are very expensive to fit in low budget solutions, when this happens you can use software raid, like mdadm.</p>
<p>Normally hard disks have a limited lifetime. To avoid disasters I replace hard disk every two years, at same time that means that new hard disk will come in a bigger capacity. I will simulate this workflow.</p>
<p>Unfortunately I&#8217;m not a rich engineer yet and need to simulate hard disk, if you want to donate some hard disk leave me a comment <img src="https://s.w.org/images/core/emoji/2.2.1/72x72/1f642.png" alt="🙂" class="wp-smiley" style="height: 1em; max-height: 1em;" /></p>
<p>step 1 and 2 are for create virtual hard disk,</p>
<p style="text-align: center;"><span style="text-decoration: underline;"><strong><span style="color: #ff0000; text-decoration: underline;">REMEMBER MAKE BACKUPS BEFORE DO DANGEROUS THINGS LIKE THESE</span></strong></span></p>
<h2>Step 1: Create virtual hard disk</h2>
<p>Imagine that in a beginning we have a couple of two hard disk with a capacity of one terabyte (1HD and 2HD), and after two years  we acquired two new hard drives with a capacity of three terabyte (3HD and 4HD).</p>
<p>I will use gigabytes instead terabytes for time and capacity reasons</p>
<p>as root</p>
<ul>
<li>cd</li>
<li>mkdir mdadmtesting</li>
<li>cd mdadmtesting</li>
<li>fallocate -l 1G 1HD.raw</li>
<li>fallocate -l 1G 2HD.raw</li>
<li>fallocate -l 3G 3HD.raw</li>
<li>fallocate -l 3G 4HD.raw</li>
</ul>
<h2>Step 2: Associate created files with loop devices</h2>
<ul>
<li>losetup /dev/loop0 /root/mdadmtesting/1HD.raw</li>
<li>losetup /dev/loop1 /root/mdadmtesting/2HD.raw</li>
<li>losetup /dev/loop2 /root/mdadmtesting/3HD.raw</li>
<li>losetup /dev/loop3 /root/mdadmtesting/4HD.raw</li>
</ul>
<h2>Step3: create a mdadm device in raid 1 mode</h2>
<ul>
<li> mdadm &#8211;create &#8211;verbose /dev/md0 &#8211;level=1 &#8211;raid-devices=2 /dev/loop0 /dev/loop1</li>
<li>mkfs.ext4 /dev/md0</li>
</ul>
<p>finally we need to mount new raid and make some files</p>
<ul>
<li>mount /dev/md0 /mnt</li>
<li>cd /mnt</li>
<li>for i in {1..100}; do echo $i &gt; $i; done</li>
</ul>
<h2>Step 4 Replace one hard disk</h2>
<p>we need to mark one hard disk as fail to replace</p>
<ul>
<li>mdadm &#8211;manage /dev/md0 &#8211;fail /dev/loop0</li>
</ul>
<p>remove disk from array</p>
<ul>
<li>mdadm &#8211;manage /dev/md0 &#8211;remove /dev/loop0</li>
</ul>
<p>attach new hard disk</p>
<ul>
<li>mdadm &#8211;manage /dev/md0 &#8211;add /dev/loop2</li>
</ul>
<p>check raid status and wait until raid state is setted as clear and not</p>
<p>State : clean, degraded, recovering</p>
<ul>
<li>mdadm &#8211;detail /dev/md0</li>
</ul>
<h2>Step 5: Replace second hard disk</h2>
<ul>
<li>mdadm &#8211;manage /dev/md0 &#8211;fail /dev/loop1</li>
<li>mdadm &#8211;manage /dev/md0 &#8211;remove /dev/loop1</li>
<li>mdadm &#8211;manage /dev/md0 &#8211;add /dev/loop3</li>
</ul>
<p>wait until state is clean</p>
<ul>
<li>mdadm &#8211;detail /dev/md0</li>
</ul>
<h2>Step 6 Grow raid device</h2>
<p>At this moment we have removed our old 1Tb disk and they have been replaced with a new 3Tb drive but our raid size is 1Tb we need to grow it</p>
<ul>
<li>mdadm &#8211;grow /dev/md0 &#8211;size=max</li>
</ul>
<h2>Step 7 Grow filesystem</h2>
<p>Our raid size is 3Tb but our file system is still at 1Tb we need to resize it</p>
<ul>
<li>resize2fs /dev/md0</li>
</ul>
<p>and finally we have our mdadm raid with new drives and a lot of free space.</p>
<p>Enjoy</p>
]]></content:encoded>
			<wfw:commentRss>https://www.luzem.com/2015/03/04/creating-replacing-and-resizing-mdadm-raid-1/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Centos 7 Backup MariaDB using MySQL-zrm</title>
		<link>https://www.luzem.com/2015/02/23/centos-7-backup-mariadb-using-mysql-zrm/</link>
		<comments>https://www.luzem.com/2015/02/23/centos-7-backup-mariadb-using-mysql-zrm/#respond</comments>
		<pubDate>Mon, 23 Feb 2015 09:06:16 +0000</pubDate>
		<dc:creator><![CDATA[Luzem]]></dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Backup]]></category>
		<category><![CDATA[centos 7]]></category>
		<category><![CDATA[MariaDB]]></category>
		<category><![CDATA[MySQL-zrm]]></category>

		<guid isPermaLink="false">http://luzem.dyndns.org/?p=3365</guid>
		<description><![CDATA[One common mistake when we configure a server is forgot run backups, No enough time and other excuses can convince you that make a backup of a new server is not a priority, but sometimes a hipervisor fails and recover data from your virtual machine is hard or impossible. Trust me i saw a lot &#8230; <p class="link-more"><a href="https://www.luzem.com/2015/02/23/centos-7-backup-mariadb-using-mysql-zrm/" class="more-link">Continue reading<span class="screen-reader-text"> "Centos 7 Backup MariaDB using MySQL-zrm"</span></a></p>]]></description>
				<content:encoded><![CDATA[<p>One common mistake when we configure a server is forgot run backups, No enough time and other excuses can convince you that make a backup of a new server is not a priority, but sometimes a hipervisor fails and recover data from your virtual machine is hard or impossible. Trust me i saw a lot of unrecoverable databases in development environments unrecoverable after a power outage or hardware fail.</p>
<p>There are a big set of possible ways to backup mysql databases, it depends of several factors like database size, number of databases, reliability &#8230;</p>
<p>This tutorial will covered a basic backup for a database server with a small number of small &#8211; medium size databases.</p>
<p>Suppose that you have a MariaDB, Percona or Mysql service running and secured,</p>
<h3>1 step create a mysql backup user.</h3>
<ul>
<li>mysql -uroot -p</li>
<li>grant select, insert, update, create, drop, reload, shutdown, alter, super, lock tables, replication client on *.* to &#8216;zrmbackup&#8217;@&#8217;localhost&#8217; identified by &#8216;pass123&#8217;;</li>
<li>flush PRIVILEGES;</li>
</ul>
<blockquote><p>verify permissions</p></blockquote>
<ul>
<li>show grants for &#8216;zrmbackup&#8217;@&#8217;localhost&#8217;;</li>
</ul>
<h3> 2 step install Mysql-zrm</h3>
<p>yum install epel-release</p>
<p>yum install MySQL-zrm.noarch</p>
<h3>3 Step create a backup dir</h3>
<p>mkdir /var/backup</p>
<p><em>*trick in my case I mounted a nfs share in this directory.</em></p>
<h3>4 Step configure Mysql-zrm</h3>
<p>We need edit mysql-zrm config file</p>
<p>vim /etc/mysql-zrm/mysql-zrm.conf</p>
<pre class="brush: plain; title: ; notranslate">

#
# Template for Zmanda Recovery Manager for MySQL configuration file
#
# Global configuration file is /etc/mysql-zrm/mysql-zrm.conf
# The file should be copied to /etc/mysql-zrm/&lt;backup set name&gt;/mysql-zrm.conf
# if backup set specific modifications are required.
#
# MySQL ZRM configuration file describes the backup configuration for
# a backup set. This file is organized into five sections for convenience
# - Backup parameters,
# - Databases/tables that are part of backup set,
# - MySQL server parameters
# - ZRM parameters.
# - ZRM plugin parameters.
#
# For more information about Zmanda Recovery Manager for MySQL, please
# see mysql-zrm(1) and/or Administration manual at Zmanda Network.
#
#
# Any line starting with '#' are comments and will be ignored

#
# Backup parameters
#

# Backup comment. This is a text string which can be retrieved
# using the mysql-zrm-reporter(1) tool. You can store some notes
# about the backup set.
# This parameter is optional and has no defaults.
#comment=This is a comment

# Backup level. It can be full or incremental
# Use 0 for full and 1 for incremental backups
# This parameter is optional and default value is full backup.
#
backup-level=0

# Backup method
# Values can be &quot;raw&quot; or &quot;logical&quot;. Logical backup are backups using
# mysqldump(1) tool
# This parameter is optional and default value is &quot;raw&quot;.
#
backup-mode=logical

# Size of LVM snapshot. This parameter is optional and  is required only
# for &quot;raw&quot; backup-mode and if the MySQL database data are stored in
# LVM logical volumes.
# A size suffix of k for kilobyte, m for megabyte, g for gigabyte
# or t for terabyte
#
#lvm-snapshot=10M

# specifies the plugin for snapshot operations
#
#snapshot-plugin=&quot;/usr/share/mysql-zrm/plugins/lvm-snapshot.pl&quot;

# Specifies the type of backup
# Values can be &quot;regular&quot; or &quot;quick&quot;.
# Quick backup type uses the snapshot itself as the backup
# without copying the data from the snapshot volume
#backup-type=quick

# Directory to which backups are done. All backups are stored under this
# directory.  This parameter is optional and the default
# value is &quot;/var/lib/mysql-zrm&quot;
#
destination=/var/backup/database

# Specifies how long the backup should be retained. The value can be
# specified in days (suffix D), weeks (suffix: W), months (suffix: M) or
# years (suffix Y). 30 days in a month and 365 days in a year are assumed
# This parameter is optional and the default is the backups are retained
# forever.
#
retention-policy=1Y

# This parameter should be set to 1 if MySQL ZRM backups are being on done on a
# MySQL replication slave.
#replication=1

# This parameter should be set to 1 if backups should be compressed. If this
# parameter is set, gzip(1) command is used by default. If different
# compression algorithm should be used, it must be set in &quot;compress-plugin&quot;
# parameter. Default: There is no data compression.
compress=1

# This specifies the program to be used for compression. The &quot;compression&quot;
# parameter must be set for this parameter to be used. The compression
# command should also support -d option for uncompress backup images. If
# value is not specified then gzip(1) is used for compression.
#compress-plugin=/usr/bin/gzip

# This parameter should be set to 1 if backups should be encrypted.
# The &quot;encrypt-plugin&quot; parameter must be configured. Default: There is no
# data encryption.
#encrypt=1

# This parameter specifies that the program that should be used for
# backup data encryption. &quot;decrypt-option&quot; parameter should also be specified.
#encrypt-plugin=&quot;/usr/share/mysql-zrm/plugins/encrypt.pl&quot;

# This specifies the option to be passed to the encryption
# program specified as &quot;encrypt-plugin&quot; parameter for decryption.
#decrypt-option=&quot;-d&quot;

#
# Databases/Tables in the backup set
#
# One of the &quot;all-databases&quot; or &quot;databases&quot; or &quot;tables&quot;/&quot;database&quot; parameters
# should be specified. If none of the them are specified, &quot;all-databases&quot;
# is assumed.
#

# This parameter should be set to 1 if all databases are part of this backup set
#
all-databases=1

# List of databases that are part of this backup set. Multiple database
# names are separated by space character. This parameter is ignored if
# &quot;all-databases&quot; is set 1.
#
#databases=wikidb forums

# List of specific tables that are part of this backup set. This parameter
# should not be specified if all tables in the databases in &quot;databases&quot;
# parameter are part of the backup set. Multiple table names should be
# separated by space character. The database to which these tables belong
# to should be specified in &quot;database&quot; parameter.
#
#tables=text user page
#database=&quot;wikidb&quot;

#
# The list of databases or tables that are excluded from the backup if the
# database name or table name matches the pattern. Wildcard characters *, ?,
# [, ] are supported. See mysql-zrm-backup man page for details
#
# exclude-pattern=&lt;pattern&gt;

# MySQL server parameters
#

# MySQL database user used for backup and recovery of the backup set.
# This parameter is optional. If this parameter is not specified, values from
# my.cnf configuration file.
#
user=&quot;zrmbackup&quot;

# MySQL database user password.
# This parameter is optional. If this parameter is not specified, values from
# my.cnf configuration file or no password is used.
#
password=&quot;pass123&quot;

# Fully qualified domain name of the MySQL server.
# This parameter is optional. If this parameter is not specified, values from
# my.cnf configuration file.
#
#host=&quot;localhost.company.com&quot;

# Port to which the MySQL server is listening to. This parameter is optional
# and default value is 3306
#
#port=3306

#Name of Socket file that can be used for connecting to MySQL
#
#socket=/var/lib/mysql/mysql.sock

# ssl-options are arguments that are passed to MySQL client commands
# for SSL connection to the MySQL server. This parameter is optional and is
# required only if MySQL server allows SSL connections.
#
#ssl-options=&quot;--ssl --ssl-ca=file1 --ssl-cert=file2 --ssl-key=file3&quot;

# This can be set to specify that mysqldump should dump stored routines also.
# This paramter is optional and the default is that stored routines are
# not dumped my mysqldump
routines=1

# This can be set to 0 to specify that the --single-transaction
# should not be used for mysqldump
single-transaction=1

# This can be used to specif the character set name that mysqldump should
# use as default. This parameter is optional.
# If not specified utf8 is used as the default character set.
#default-character-set=latin1

# Directory where MySQL commands can be found. The parameter is optional.
#
#mysql-binpath=&quot;/opt/lampp/bin&quot;

# Directory where MySQL binary logs can be found. The parameter is optional.
#
#mysql-binlog-path=&quot;/var/log/mysql&quot;

# Directory to use for temporary storage. This parameter is optional
#
#tmpdir=/tmp

#
# ZRM parameters
#

# This parameter controls the verbosity of MySQL ZRM logging. The MySQL ZRM logs
# are available at /var/log/mysql-zrm/mysql-zrm.log. This parameter is optional
# default value is 0 (less verbose).
# The valid values are 0 and 1
#
verbose=1

# After a backup run the backup report is emailed to the mailto address
# This parameter is optional and default behavior is not to send mail
# notifications.
#
mailto=&quot;backups@youremail.com&quot;

# Policy on when the mail should be sent
# Values can be &quot;always&quot;, &quot;never&quot; or &quot;only-on-error&quot;
mail-policy=only-on-error

# The list of backup reports that are generated after each backup run if
# &quot;html-report-directory&quot; parameter is specified.
# If this parameter is not specified, &quot;backup-status-info&quot; report is generated.
# Valid report names are : backup-method-info, backup-status-info,
#                          backup-retention-info, backup-performance-info,
#                          restore-full-info, restore-incr-info,
#                          replication-info, backup-app-performance-info
# See mysql-zrm-reporter(1) for details of backup reports.
# Multiple report names should be separated by &quot;,&quot;.
#
html-reports=backup-status-info

# Directory in which Text/HTML reports will be created by mysql-zrm-reporter(1)
# tool. If this parameter is specified, the mysql-zrm-reporter(1) creates the
# backup reports in this directory after each successful or unsuccessful
# backup run.
# Text reports will be created under &quot;Text&quot; sub-directory
# HTML reports will be created under &quot;Html&quot; sub-directory
#
#html-report-directory=/var/www/mysql-zrm/reports/

# If backup reports are required as RSS feed, &quot;webserver-url&quot; parameter must
# be specified. The value must be set to a valid location on the web server
# in which HTML reports are located and that URL can be used by
# administrator/user to browse HTML reports and can get to the RSS feeds.
# If this parameter is not specified, backup reports are not generated as
# RSS feeds. The list of reports that are available as RSS feed is specified
# in &quot;html-reports&quot;.
#
#webserver-url=http://www.company.com/reports/html/

# Location of RSS header file. Administrators can customize RSS channel
# properties using this file. A template for RSS header is available in
# /usr/share/mysql-zrm/plugins/RSS.header file. Location of RSS header
# must be provided if &quot;webserver-url&quot; is specified.
#
#rss-header-location=/etc/mysql-zrm/

#
# ZRM plugin parameters.
# ZRM provides plugin interfaces to allow MySQL administrators to customize
# the backup to their environment.
#

# COPY plugin: Only one copy-plugin must be configured for a backup set.
#
# Socket Copy plugin is to used to transfer backup files from MySQL server to
# the machine running ZRM for MySQL with sockets.
#
# Please read the Notes at /usr/share/doc/mysql-zrm/README-plugin-socket-copy
#
#copy-plugin=/usr/share/mysql-zrm/plugins/socket-copy.pl

# SSH Copy plugin is to used to transfer backup files from MySQL server to
# the machine running ZRM for MySQL with ssh
#
# Please read the Notes at /usr/share/doc/mysql-zrm/README-plugin-ssh-copy
#
#copy-plugin=/usr/share/mysql-zrm/plugins/ssh-copy.pl

# PRE-BACKUP plugin: Plugin that will be called before a backup run for
# the backup set.
#pre-backup-plugin=&quot;/usr/share/mysql-zrm/plugins/pre-backup.pl&quot;

# Set of parameters passed to the pre-backup-plugin. These parameters are
# passed to &quot;pre-backup-plugin&quot; before a backup run for the backup set.
# &quot;pre-backup-plugin&quot; parameter must be specified.
#pre-backup-plugin-options=&quot;option1 option2&quot;

# POST-BACKUP plugin: Plugin that will be called after a backup run for
# the backup set.
#post-backup-plugin=&quot;/usr/share/mysql-zrm/plugins/post-backup.pl&quot;

# Set of parameters passed to the post-backup-plugin. These parameters are
# passed to &quot;post-backup-plugin&quot; after a backup run for the backup set.
# &quot;post-backup-plugin&quot; parameter must be specified.
#post-backup-plugin-options=&quot;option1 option2&quot;

# PRE-SCHEDULER plugin: Plugin that can be used to dynamically determine the
# start time for a backup run.
#pre-scheduler-plugin=&quot;/usr/share/mysql-zrm/plugins/pre-scheduler.pl&quot;

# ZRM Plugin configuration parameters

# This parameter is used by the encrypt plugin and
# specifies the file containing the passphrase.
#passfile=&quot;/tmp/a.pass&quot;

# This parameter is used by ssh-plugin.pl plugin to specify the user to be
# used to ssh to the  remote host
#ssh-user=&quot;root&quot;

# This parameter is used by the ssh-copy.pl and socket-copy.pl plugins
# to specify the location of mysql client binaries on the remote host.
#remote-mysql-binpath=&quot;/usr/bin&quot;

# This parameter is used by the socket-copy.pl plugin to specify the port
# to be opened on the remote host.
#socket-remote-port=&quot;25300&quot;

# This parameter is used by the windows-copy.pl plugin to specify the port
# to be opened on the windows machine during backup
#windows-backup-port=&quot;10080&quot;

# This parameter is used by the windows-copy.pl plugin to specify the port
# to be opened on the windows machine during restore
#windows-restore-port=&quot;10081&quot;

</pre>
<h3>Step 5. Launch a backup</h3>
<p>mysql-zrm-scheduler -now</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>https://www.luzem.com/2015/02/23/centos-7-backup-mariadb-using-mysql-zrm/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
