Pages

Wednesday, 6 November 2019

Configure Postfix server (4/7)

Configure Postfix server (4/7)

# Create a backup file of main.cf and master.cf files.


[root@mailserver ~]# cd /etc/postfix
[root@mailserver postfix]# cat main.cf > main.cf.org
[root@mailserver postfix]# cat master.cf > master.cf.org

# Create new file main.cf

[root@mailserver sql]# vim /etc/postfix/main.cf
[root@mailserver sql]# cat /etc/postfix/main.cf
myhostname = mailserver.example.com
mydomain = example.com
myorigin = $mydomain
inet_interfaces = all
inet_protocols = ipv4
mynetworks_style = host
mynetworks = $config_directory/mynetworks
smtpd_banner = $myhostname ESMTP $mail_name
# ---------------------- VIRTUAL DOMAINS START ----------------------
virtual_alias_maps = proxy:mysql:$config_directory/sql/virtual_alias_maps.cf
virtual_mailbox_domains = proxy:mysql:$config_directory/sql/virtual_domains_maps.cf
virtual_mailbox_maps = proxy:mysql:$config_directory/sql/virtual_mailbox_maps.cf
#virtual_mailbox_limit_maps = proxy:mysql:$config_directory/sql/virtual_mailbox_limit_maps.cf
virtual_mailbox_base = /home/mail
virtual_uid_maps = static:8
virtual_gid_maps = static:12
mailbox_size_limit = 104857600
message_size_limit = 104857600
relay_domains = proxy:mysql:$config_directory/sql/relay_domains.cf
relay_recipient_maps = proxy:mysql:$config_directory/sql/relay_recipient_maps.cf
transport_maps = proxy:mysql:$config_directory/sql/transport_maps.cf
#transport_maps = hash:$config_directory/transport
#virtual_transport = dovecot
dovecot_destination_recipient_limit = 1
# ----------------------- VIRTUAL DOMAINS END -----------------------
# ------------------------- SASL PART START -------------------------
broken_sasl_auth_clients = yes
smtpd_helo_required = yes
smtpd_client_restrictions = permit_sasl_authenticated
smtpd_sender_restrictions = permit_sasl_authenticated
smtpd_sasl_auth_enable = yes
smtpd_sasl_security_options = noanonymous
smtpd_sasl_tls_security_options = $smtpd_sasl_security_options
smtpd_sasl_type = dovecot
# Can be an absolute path, or relative to $queue_directory
smtpd_sasl_path = private/auth
# -------------------------- SASL PART END --------------------------
# -------------------------- TLS PART START -------------------------
smtpd_use_tls = yes
smtpd_tls_auth_only = yes
smtpd_tls_cert_file = /etc/pki/tls/certs/mailserver.example.com.crt
smtpd_tls_key_file = /etc/pki/tls/certs/mailserver.example.com.key
smtpd_tls_received_header = yes
smtpd_tls_loglevel = 1
tls_random_source = dev:/dev/urandom
# --------------------------- TLS PART END --------------------------
# ------------------ SMTPD RESTRICTIONS PART START ------------------
disable_vrfy_command = yes
non_fqdn_reject_code = 450
invalid_hostname_reject_code = 450
maps_rbl_reject_code = 450
unverified_sender_reject_code = 550
#header_checks = pcre:$config_directory/header_checks
#body_checks = pcre:$config_directory/body_checks
#warning: the restrictions reject_unknown_(sender|recipient)_domain
#will trigger if your DNS becomes unavailable
smtpd_recipient_restrictions =
permit_mynetworks
permit_sasl_authenticated
reject_unauth_destination
reject_invalid_helo_hostname
warn_if_reject reject_non_fqdn_helo_hostname
warn_if_reject reject_unknown_helo_hostname
warn_if_reject reject_unknown_client
reject_non_fqdn_sender
reject_non_fqdn_recipient
reject_unknown_sender_domain
reject_unknown_recipient_domain
check_client_access hash:$config_directory/rbl_override
reject_rbl_client zen.spamhaus.org
reject_rbl_client bl.spamcop.net
reject_rbl_client dnsbl.sorbs.net=127.0.0.2
reject_rbl_client dnsbl.sorbs.net=127.0.0.3
reject_rbl_client dnsbl.sorbs.net=127.0.0.4
reject_rbl_client dnsbl.sorbs.net=127.0.0.5
reject_rbl_client dnsbl.sorbs.net=127.0.0.7
reject_rbl_client dnsbl.sorbs.net=127.0.0.9
reject_rbl_client dnsbl.sorbs.net=127.0.0.11
reject_rbl_client dnsbl.sorbs.net=127.0.0.12
permit
smtpd_data_restrictions =
permit_mynetworks,
reject_unauth_pipelining,
reject_multi_recipient_bounce,
permit
# ------------------- SMTPD RESTRICTIONS PART END --------------------


Create below line in master.cf file

[root@mailserver sql]# vim /etc/postfix/master.cf
[root@mailserver sql]# cat /etc/postfix/master.cf
#
# Postfix master process configuration file. For details on the format
# of the file, see the master(5) manual page (command: "man 5 master").
#
# Do not forget to execute "postfix reload" after editing this file.
#
# ==========================================================================
# service type private unpriv chroot wakeup maxproc command + args
# (yes) (yes) (yes) (never) (100)
# ==========================================================================
smtp inet n - n - - smtpd
#smtp inet n - n - 1 postscreen
#smtpd pass - - n - - smtpd
#dnsblog unix - - n - 0 dnsblog
#tlsproxy unix - - n - 0 tlsproxy
#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
smtps inet n - n - - smtpd
-o syslog_name=postfix/smtps
-o smtpd_tls_wrappermode=yes
-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
#628 inet n - n - - qmqpd
pickup unix n - n 60 1 pickup
cleanup unix n - n - 0 cleanup
qmgr unix n - n 300 1 qmgr
#qmgr unix n - n 300 1 oqmgr
tlsmgr unix - - n 1000? 1 tlsmgr
rewrite unix - - n - - trivial-rewrite
bounce unix - - n - 0 bounce
defer unix - - n - 0 bounce
trace unix - - n - 0 bounce
verify unix - - n - 1 verify
flush unix n - n 1000? 0 flush
proxymap unix - - n - - proxymap
proxywrite unix - - n - 1 proxymap
smtp unix - - n - - smtp
relay unix - - n - - smtp
# -o smtp_helo_timeout=5 -o smtp_connect_timeout=5
showq unix n - n - - showq
error unix - - n - - error
retry unix - - n - - error
discard unix - - n - - discard
local unix - n n - - local
virtual unix - n n - - virtual
lmtp unix - - n - - lmtp
anvil unix - - n - 1 anvil
scache unix - - n - 1 scache
#
# ====================================================================
# Interfaces to non-Postfix software. Be sure to examine the manual
# pages of the non-Postfix software to find out what options it wants.
#
# Many of the following services use the Postfix pipe(8) delivery
# agent. See the pipe(8) man page for information about ${recipient}
# and other message envelope options.
# ====================================================================
#
# maildrop. See the Postfix MAILDROP_README file for details.
# Also specify in main.cf: maildrop_destination_recipient_limit=1
#
#maildrop unix - n n - - pipe
# flags=DRhu user=vmail argv=/usr/local/bin/maildrop -d ${recipient}
#
# ====================================================================
#
# Recent Cyrus versions can use the existing "lmtp" master.cf entry.
#
# Specify in cyrus.conf:
# lmtp cmd="lmtpd -a" listen="localhost:lmtp" proto=tcp4
#
# Specify in main.cf one or more of the following:
# mailbox_transport = lmtp:inet:localhost
# virtual_transport = lmtp:inet:localhost
#
# ====================================================================
#
# Cyrus 2.1.5 (Amos Gouaux)
# Also specify in main.cf: cyrus_destination_recipient_limit=1
#
#cyrus unix - n n - - pipe
# user=cyrus argv=/usr/lib/cyrus-imapd/deliver -e -r ${sender} -m ${extension} ${user}
#
# ====================================================================
#
# Old example of delivery via Cyrus.
#
#old-cyrus unix - n n - - pipe
# flags=R user=cyrus argv=/usr/lib/cyrus-imapd/deliver -e -m ${extension} ${user}
#
# ====================================================================
#
# See the Postfix UUCP_README file for configuration details.
#
#uucp unix - n n - - pipe
# flags=Fqhu user=uucp argv=uux -r -n -z -a$sender - $nexthop!rmail ($recipient)
#
# ====================================================================
#
# Other external delivery methods.
#
#ifmail unix - n n - - pipe
# flags=F user=ftn argv=/usr/lib/ifmail/ifmail -r $nexthop ($recipient)
#
#bsmtp unix - n n - - pipe
# flags=Fq. user=bsmtp argv=/usr/local/sbin/bsmtp -f $sender $nexthop $recipient
#
#scalemail-backend unix - n n - 2 pipe
# flags=R user=scalemail argv=/usr/lib/scalemail/bin/scalemail-store
# ${nexthop} ${user} ${extension}
#
#mailman unix - n n - - pipe
# flags=FR user=list argv=/usr/lib/mailman/bin/postfix-to-mailman.py
# ${nexthop} ${user}
#
# add line for dovecot
dovecot unix - n n - - pipe
flags=DRhu user=mail:mail argv=/usr/libexec/dovecot/deliver -d ${recipient}

[root@mailserver postfix]#

[root@mailserver ~]# vim /etc/postfix/mynetworks
[root@mailserver ~]# cat /etc/postfix/mynetworks
# This specifies the list of subnets that Postfix considers as
# "trusted" SMTP clients that have more privileges than "strangers".
#
# In particular, "trusted" SMTP clients are allowed to relay mail
# through Postfix.
#
# Be sure to add your public ip address block if needed.
#
127.0.0.0/8
192.168.10.0/24
[root@mailserver ~]#

[root@mailserver ~]# vim /etc/postfix/rbl_override
[root@mailserver ~]# cat /etc/postfix/rbl_override
mailserver.example.com OK
192.168.10.0/24 OK

[root@mailserver ~]# postmap /etc/postfix/rbl_override

Create new folder in /etc/postfix/sql

[root@mailserver postfix]# mkdir sql
[root@mailserver postfix]# cd /etc/postfix/sql
[root@mailserver sql]#

[root@mailserver sql]# vim /etc/postfix/sql/virtual_alias_maps.cf
[root@mailserver sql]# cat /etc/postfix/sql/virtual_alias_maps.cf
hosts = localhost
dbname = maildb
user = mailuser
password = redhat
table = alias
select_field = goto
where_field = address
additional_conditions = AND active = '1'
[root@mailserver sql]#

[root@mailserver sql]# vim /etc/postfix/sql/virtual_domains_maps.cf
[root@mailserver sql]# cat /etc/postfix/sql/virtual_domains_maps.cf
hosts = localhost
dbname = maildb
user = mailuser
password = redhat
table = domain
select_field = description
where_field = domain
additional_conditions = AND backupmx = '0' AND active = '1'
[root@mailserver sql]#

[root@mailserver sql]# vim /etc/postfix/sql/virtual_mailbox_maps.cf
[root@mailserver sql]# cat /etc/postfix/sql/virtual_mailbox_maps.cf
hosts = localhost
dbname = maildb
user = mailuser
password = redhat
table = mailbox
select_field = maildir
where_field = username
additional_conditions = AND active = '1'

[root@mailserver sql]#


[root@mailserver sql]# vim /etc/postfix/sql/virtual_mailbox_limit_maps.cf
[root@mailserver sql]# cat /etc/postfix/sql/virtual_mailbox_limit_maps.cf
hosts = localhost
dbname = maildb
user = mailuser
password = redhat
table = mailbox
select_field = quota
where_field = username
additional_conditions = AND active = '1'
[root@mailserver sql]#


[root@mailserver sql]# vim /etc/postfix/sql/relay_domains.cf
[root@mailserver sql]# cat /etc/postfix/sql/relay_domains.cf
hosts = localhost
dbname = maildb
user = mailuser
password = redhat
table = domain
select_field = domain
where_field = domain
additional_conditions = AND backupmx = '1' AND active = '1'
[root@mailserver sql]#

[root@mailserver sql]# vim /etc/postfix/sql/relay_recipient_maps.cf
[root@mailserver sql]# cat /etc/postfix/sql/relay_recipient_maps.cf
hosts = localhost
dbname = maildb
user = mailuser
password = redhat
table = alias
select_field = goto
where_field = address
additional_conditions = AND active = '1'

[root@mailserver sql]#

[root@mailserver sql]# vim /etc/postfix/sql/transport_maps.cf
[root@mailserver sql]# cat /etc/postfix/sql/transport_maps.cf
hosts = localhost
dbname = maildb
user = mailuser
password = redhat
table = domain
select_field = transport
where_field = domain
additional_conditions = AND active = '1'
[root@mailserver sql]#

[root@mailserver sql]# chown root:postfix /etc/postfix/sql/ -R

[root@mailserver sql]# chcon -u system_u /etc/postfix/sql -R

[root@mailserver sql]# chmod 0640 /etc/postfix/sql/*.cf

[root@mailserver sql]# chmod 0750 /etc/postfix/sql/

[root@mailserver sql]# newaliases


Installation and Configure Mariadb (3/7)

Installation and Configure Mariadb (3/7).

# Installation of MariaDB server via yum command. 

[root@mailserver ~]# yum install mariadb mariadb-servers


[root@mailserver ~]#
[root@mailserver ~]# systemctl enable mariadb
ln -s '/usr/lib/systemd/system/mariadb.service' '/etc/systemd/system/multi-user.target.wants/mariadb.service'
[root@mailserver ~]# systemctl start mariadb

[root@mailserver ~]# mysql_secure_installation
/bin/mysql_secure_installation: line 379: find_mysql_client: command not found

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we'll need the current
password for the root user. If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none):
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.

Set root password? [Y/n] y
New password: redhat
Re-enter new password: redhat
Password updated successfully!
Reloading privilege tables..
... Success!


By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them. This is intended only for testing, and to make the installation
go a bit smoother. You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] y
... Success!

Normally, root should only be allowed to connect from 'localhost'. This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] y
... Success!

By default, MariaDB comes with a database named 'test' that anyone can
access. This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] y
- Dropping test database...
... Success!
- Removing privileges on test database...
... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] y
... Success!

Cleaning up...

All done! If you've completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!
[root@mailserver ~]# mysql -u root -p
Enter password: redhat
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 10
Server version: 5.5.44-MariaDB MariaDB Server

Copyright (c) 2000, 2015, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> exit
Bye
[root@mailserver ~]#


# Create maildb database and mailuser user for access


[root@mailserver ~]# mysql -u root -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 12
Server version: 5.5.44-MariaDB MariaDB Server

Copyright (c) 2000, 2015, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> create database maildb;
Query OK, 1 row affected (0.00 sec)

MariaDB [(none)]> CREATE USER 'mailuser'@'localhost' IDENTIFIED BY 'redhat';
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> GRANT ALL PRIVILEGES ON `maildb`.* TO 'mailuser'@'localhost';
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]>


Installation and Configure Postfixadmin-2.93 (2/7)

Installation and Configure Postfixadmin-2.93 (2/7)

# Download postfixadmin-2.93

[root@mailserver ~]# wget http://liquidtelecom.dl.sourceforge.net/project/postfixadmin/postfixadmin/postfixadmin-2.93/postfixadmin-2.93.tar.gz
--2015-11-23 05:36:58-- http://liquidtelecom.dl.sourceforge.net/project/postfixadmin/postfixadmin/postfixadmin-2.93/postfixadmin-2.93.tar.gz
Resolving liquidtelecom.dl.sourceforge.net (liquidtelecom.dl.sourceforge.net)... 197.155.77.8
Connecting to liquidtelecom.dl.sourceforge.net (liquidtelecom.dl.sourceforge.net)|197.155.77.8|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1269907 (1.2M) [application/x-gzip]
Saving to: ‘postfixadmin-2.93.tar.gz’

100%[======================================>] 12,69,907 375KB/s in 3.3s

2015-11-23 05:37:02 (375 KB/s) - ‘postfixadmin-2.93.tar.gz’ saved [1269907/1269907]

[root@mailserver ~]#

[root@mailserver ~]#
[root@mailserver ~]# tar -xvf postfixadmin-2.93.tar.gz --directory=/usr/share
postfixadmin-2.93/
postfixadmin-2.93/GPL-LICENSE.TXT
postfixadmin-2.93/debian/
postfixadmin-2.93/debian/control
postfixadmin-2.93/debian/postfixadmin.examples
....
Output Obmiited 
....
postfixadmin-2.93/VIRTUAL_VACATION/INSTALL.TXT
postfixadmin-2.93/VIRTUAL_VACATION/index.php
postfixadmin-2.93/VIRTUAL_VACATION/vacation.pl
postfixadmin-2.93/smarty.inc.php
[root@mailserver ~]#


[root@mailserver ~]# ls -d /usr/share/postfixadmin-2.93
/usr/share/postfixadmin-2.93
[root@mailserver ~]# 

# Create Soft Link of Postfixadmin-2.93 to postfixadmin in /usr/share directory  

[root@mailserver ~]# ln -s /usr/share/postfixadmin-2.93/ /usr/share/postfixadmin

[root@mailserver ~]# ll -d /usr/share/postfixadmin*
lrwxrwxrwx. 1 root root 29 Nov 23 05:50 /usr/share/postfixadmin -> /usr/share/postfixadmin-2.93/
drwxrwxr-x. 17 centos 1010 4096 Sep 26 15:26 /usr/share/postfixadmin-2.93
[root@mailserver ~]#

# Create Document directory in /usr/share/doc/postfixadmin-2.93

[root@mailserver ~]# mkdir /usr/share/doc/postfixadmin-2.93


[root@mailserver ~]# mv /usr/share/postfixadmin/{ADDITIONS,DOCUMENTS,VIRTUAL_VACATION} /usr/share/doc/postfixadmin-2.93

[root@mailserver ~]# chown root:apache /usr/share/postfixadmin/templates_c/

[root@mailserver ~]# chmod g+w /usr/share/postfixadmin/templates_c/

[root@mailserver ~]# mkdir /etc/postfixadmin

[root@mailserver ~]# touch /etc/postfixadmin/config.local.php

[root@mailserver ~]# chown root:apache /etc/postfixadmin/config.local.php

[root@mailserver ~]# chmod 0640 /etc/postfixadmin/config.local.php

[root@mailserver ~]# ln -s /etc/postfixadmin/config.local.php /usr/share/postfixadmin


# Copy below contain to /etc/postfixadmin/config.local.php file. 
   
[root@mailserver ~]# vim /etc/postfixadmin/config.local.php
[root@mailserver ~]# cat /etc/postfixadmin/config.local.php
<?php
$CONF['configured'] = true;
$CONF['setup_password'] = 'changeme';
$CONF['default_language'] = 'en';
$CONF['database_type'] = 'mysqli';
$CONF['database_host'] = 'localhost';
$CONF['database_user'] = 'mailuser';
$CONF['database_password'] = 'redhat';
$CONF['database_name'] = 'maildb';
$CONF['admin_email'] = 'mailadmin@example.com';
$CONF['page_size'] = '50';
$CONF['default_aliases'] = array (
'MAILER-DAEMON' => 'postmaster@example.com',
'abuse' => 'postmaster@example.com',
'postmaster' => 'hostmaster@example.com',
'webmaster' => 'hostmaster@example.com',
'hostmaster' => 'root@example.com',
'root' => 'admin@example.com'
);
$CONF['domain_path'] = 'YES';
$CONF['domain_in_mailbox'] = 'NO';
$CONF['transport'] = 'YES';
$CONF['transport_options'] = array (
'dovecot', // for virtual accounts
'virtual', // for virtual accounts
'local', // for system accounts
'relay' // for backup mx
);
$CONF['transport_default'] = 'dovecot';
$CONF['vacation'] = 'NO';
$CONF['vacation_control'] = 'NO';
$CONF['vacation_control_admin'] = 'NO';
$CONF['backup'] = 'YES';
$CONF['sendmail'] = 'YES';
$CONF['logging'] = 'YES';
$CONF['fetchmail'] = 'YES';
$CONF['fetchmail_extra_options'] = 'YES';
$CONF['footer_text'] = 'Return to mailserver.example.com';
$CONF['footer_link'] = 'http://mailserver.example.com';
$CONF['used_quotas'] = 'YES';
$CONF['new_quota_table'] = 'YES';
[root@mailserver ~]#

# Create Virtual http conf file in /etc/httpd/conf.d/postfixadmin.conf

[root@mailserver ~]# vim /etc/httpd/conf.d/postfixadmin.conf
[root@mailserver ~]# cat /etc/httpd/conf.d/postfixadmin.conf
#
# postfixadmin - Web based Management tool created for Postfix.
#
# Allows only localhost by default
#
# But allowing postfixadmin to anyone other than localhost should be considered
# dangerous unless properly secured by SSL
Alias /mailadmin /usr/share/postfixadmin
<Directory /usr/share/postfixadmin/>
AddDefaultCharset UTF-8
<IfModule mod_authz_core.c>
# Apache 2.4
<RequireAny>
Require ip 127.0.0.1
Require ip ::1
Require ip 192.168.10.0/24
</RequireAny>
</IfModule>
<IfModule !mod_authz_core.c>
# Apache 2.2
Order Deny,Allow
Deny from All
# Allow from 127.0.0.1
Allow from ALL
Allow from ::1
Allow from 192.168.10.0/16
</IfModule>
</Directory>
[root@mailserver ~]#

Installation and Configure Postfix Service with Mariadb Database. (1/7)

Installation of Postfix with Mysql Database step by step(1/7)


# Configure Static ip address to a server

[root@localhost ~]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 08:00:27:e0:d3:c5 brd ff:ff:ff:ff:ff:ff
    inet 192.168.10.2/24 brd 192.168.10.255 scope global dynamic enp0s3
       valid_lft 736sec preferred_lft 736sec
    inet6 fe80::61e1:d548:2e53:232b/64 scope link
       valid_lft forever preferred_lft forever
[root@localhost ~]#


# Change Hostname of the server

[root@localhost ~]# hostnamectl set-hostname master.zmailtech.com
[root@localhost ~]# hostname
mailserver.zmailtech.com
[root@localhost ~]#

[root@localhost ~]# cat /etc/sysconfig/network
# Created by anaconda
HOSTNAME=mailserver.zmailtech.com
[root@localhost ~]#
 


# Set SELinux policy in Permissive mode 



[root@mailserver ~]# setenforce 0
[root@mailserver ~]# getenforce
Permissive

[root@mailserver ~]# vim /etc/selinux/config
[root@mailserver ~]# cat /etc/selinux/config

# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=permissive
# SELINUXTYPE= can take one of three two values:
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes are protected.
# mls - Multi Level Security protection.
SELINUXTYPE=targeted

[root@mailserver ~]# 

# Configure self-sign SSL Certificate.

[root@mailserver ~]# cd /etc/pki/tls/certs/

[root@mailserver certs]# make mailserver.example.com.key
umask 77 ; \
/usr/bin/openssl genrsa -aes128 2048 > mailserver.example.com.key
Generating RSA private key, 2048 bit long modulus
...................+++
.............................+++
e is 65537 (0x10001)
Enter pass phrase:
Verifying - Enter pass phrase:

[root@mailserver certs]# openssl rsa -in mailserver.example.com.key -out mailserver.example.com.key
Enter pass phrase for mailserver.example.com.key:
writing RSA key

[root@mailserver certs]# make mailserver.example.com.csr
umask 77 ; \
/usr/bin/openssl req -utf8 -new -key mailserver.example.com.key -out mailserver.example.com.csr
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [XX]:IN
State or Province Name (full name) []:Gujarat
Locality Name (eg, city) [Default City]:Ahmedabad
Organization Name (eg, company) [Default Company Ltd]:example
Organizational Unit Name (eg, section) []:mailserver
Common Name (eg, your name or your server's hostname) []:
Email Address []:testuser@example.com

Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:redhat
An optional company name []:

[root@mailserver certs]# openssl x509 -in mailserver.example.com.csr -out mailserver.example.com.crt -req -signkey mailserver.example.com.key -days 3650
Signature ok
subject=/C=IN/ST=Gujarat/L=Ahmeadabad/O=example/OU=mailserver/emailAddress=testuser@example.com
Getting Private key
[root@mailserver certs]#