postfix header check

https://www.howtoforge.com/community/threads/howto-spam-control-for-postfix.48608/
http://mattshaw.org/news/how-to-filter-mail-with-postfix-header_checks/

https://posluns.com/guides/header-checks/
https://www.howtoforge.com/community/threads/postfix-header-checks.80/

ispconfig3 setup on debian jessie remove default page setting

https://www.howtoforge.com/tutorial/perfect-server-debian-8-jessie-apache-bind-dovecot-ispconfig-3

+ remove /etc/apache2/sites-enabled/000-default..conf
or echo >  /etc/apache2/sites-enabled/000-default..conf

python pip install without cache

From documentation at https://pip.pypa.io/en/latest/reference/pip_install.html#caching:
Starting with v6.0, pip provides an on by default cache which functions similarly to that of a web browser. While the cache is on by default and is designed do the right thing by default you can disable the cache and always access PyPI by utilizing the --no-cache-dir option.

pip install pillow --no-cache-dir













install nethogs on centos 7

I’ve just found that ‘nethogs’, a bandwidth monitoring software is not covered in the EPEL for Centos 7. This is a memo for how to install nethogs on CentOS 7.

1. Install the dependencies necessary.
yum install libpcap-devel -y
2. Download and install the RPM package.
rpm -ivh http://cdn.kanachan.me.uk/dl/rpms/nethogs/nethogs-0.8.0-1.el6.x86_64.rpm

pflogsumm postfix mail log analyzer pflog


yum install perl-Date-Calc

sudo curl -O http://jimsun.linxnet.com/downloads/pflogsumm-1.1.3.tar.gz

tar -xzf pflogsumm-1.1.3.tar.gz

mv pflogsumm-1.1.3 pflogsumm

chmod +x pflogsumm/pflogsumm.pl

perl   /usr/local/pflogsumm/pflogsumm.pl   /var/log/maillog

# generate log summary for yesterday

[root@mail ~]# perl /usr/sbin/pflogsumm -d yesterday /var/log/maillog


To run cronjob for pflogsumm

crontab -e

# send mail log summary at AM 1:00 everyday to root

00 01 * * * perl /usr/sbin/pflogsumm -e -d yesterday /var/log/maillog | mail -s 'Logwatch for Postfix' root

http://jimsun.linxnet.com/postfix_contrib.html

https://www.dropbox.com/s/rkbp13lz4eon988/pflogsumm-1.1.3.tar.gz?dl=0

start a daemon at startup ubuntu

  • To start a daemon at startup:
    update-rc.d service_name defaults
    
  • To remove:
    update-rc.d -f service_name remove
    
defaults => default run levels 2,3,4 and 5
Example:
update-rc.d tomcat7 defaults

difference between use of port 25 465 and 587

port 25 is used for transmitting email between MTA's also known as SMTP relaying.

port 465 is no longer used on ssl-smtp(although port 465 was never published as an official SMTP transmission or submission channel by the IETF ) and IANA has now assigned 465 to new service called "urd".

The RFC proposed a split of the traditional message submission and message relay concept. The RFC defined that message submission should occur over port 587 to ensure new policy and security requirements don't interfere with the traditional relay traffic over message relay port 25.
Port 587 is for msa - it is almost like standard SMTP port. SSL encryption may be started by STARTTLS command at SMTP level if server supports it and your ISP does not filter server's EHLO reply (reported 2014 Nov). MSA should accept email after authentication (e.g. after SMTP AUTH). It helps to stop outgoing spam when netmasters of DUL ranges can block outgoing connections to SMTP port (port 25)

REDHAT CLUSTER part 3 - Adding cluster resources and services

Make sure selinux is disabled or in permissive for testing


Adding cluster resources and services

Cluster SERVICE = 1 or more RESOURCES            

resource are defined within <rm>  </rm> eg.

<rm>
<resources> ...
...
</resources>
</rm>

cluster resources are configured with resource scripts and located at /usr/share/cluster along with cluster resources



[root@c1 cluster]# ls /usr/share/cluster/
apache.metadata                 lvm.metadata          oralistener.metadata
apache.sh                       lvm.sh                oralistener.sh
...
..


On any one node for example im on node 3 edit /etc/cluster/cluster.conf





 [root@c3 cluster]# cat cluster.conf

<?xml version="1.0"?>
<cluster config_version="4" name="hacluster">
    <logging debug="off"/>
    <clusternodes>
        <clusternode name="c1" nodeid="1"/>
        <clusternode name="c2" nodeid="2"/>
        <clusternode name="c3" nodeid="3"/>
    </clusternodes>
    <rm>
        <failoverdomains>
            <failoverdomain name="simple" nofailback="1" ordered="0" restricted="0">
                <failoverdomainnode name="c1"/>
                <failoverdomainnode name="c2"/>
                <failoverdomainnode name="c3"/>
            </failoverdomain>
        </failoverdomains>
        <resources>
            <ip address="192.168.0.88" family="IPv4" prefer_interface="eth1"/>
            <apache config_file="conf/httpd.conf" name="apache" server_root="/etc/httpd" shutdown_wait="60"/>
        </resources>
    </rm>
</cluster>

validate configuration

[root@c3]# ccs_config_validate
Configuration validates

Distribute cluster conf with below command and enter ricci user password for all nodes respectively

[root@c3]# cman_tool version -r
You have not authenticated to the ricci daemon on c3
Password:
You have not authenticated to the ricci daemon on c2
Password:
You have not authenticated to the ricci daemon on c1
Password:

SERVICES

We can configure a web server cluster service with respect to the configured IP address and Apache web server resources with the following CMAN configuration file syntax:
 Make sure to increase config_version here i have number "8"

[root@c1 ~]# ccs_config_dump
<?xml version="1.0"?>
<cluster config_version="8" name="hacluster">
    <logging debug="off"/>
    <clusternodes>
        <clusternode name="c1" nodeid="1"/>
        <clusternode name="c2" nodeid="2"/>
        <clusternode name="c3" nodeid="3"/>
    </clusternodes>
    <rm>
        <failoverdomains>
            <failoverdomain name="simple" nofailback="1" ordered="0" restricted="0">
                <failoverdomainnode name="c1"/>
                <failoverdomainnode name="c2"/>
                <failoverdomainnode name="c3"/>
            </failoverdomain>
        </failoverdomains>
        <resources>
            <ip address="192.168.0.88" family="IPv4" prefer_interface="eth0"/>
            <apache config_file="conf/httpd.conf" name="apache" server_root="/etc/httpd" shutdown_wait="60"/>
        </resources>

        <service autostart="1" name="webserver" recovery="relocate">
            <ip ref="192.168.0.88"/>
            <apache ref="apache"/>
        </service>

    </rm>
    <cman nodename="c1" cluster_id="10117"/>
</cluster>

[root@c3 ~]# clustat
Cluster Status for hacluster @ Fri Aug 28 17:00:32 2015
Member Status: Quorate

 Member Name                             ID   Status
 ------ ----                             ---- ------
 c1                                          1 Online, rgmanager
 c2                                          2 Online, rgmanager
 c3                                          3 Online, Local, rgmanager

 Service Name                   Owner (Last)                   State        
 ------- ----                   ----- ------                   -----        
 service:webserver              c3                             started 

[root@c3 ~]# ip ad | grep inet
    inet 127.0.0.1/8 scope host lo
    inet6 ::1/128 scope host
    inet 192.168.0.77/24 brd 192.168.0.255 scope global eth0
    inet 192.168.0.88/24 scope global secondary eth0 #virtual ip
    inet6 fe80::a00:27ff:fe2e:2480/64 scope link


 






REDHAT CLUSTER part 2 - Setting up corosync , CMAN, and RGmanager centos 6.7

Disable SELinux on all nodes
setenforce 0

All nodes are under oracle virtual box:-
number of cluster nodes : 3
setup static ip for all 3 nodes and proper hostname
example
[root@c1 cluster]# cat /etc/hosts
127.0.0.1   localhost
192.168.0.55 c1.example.com c1
192.168.0.66 c2.example.com c2
192.168.0.77 c3.example.com c3

Setup proper gateway( setup similar config in other 2 nodes)
[root@c1]# cat /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=c1.example.com
GATEWAY=192.168.0.235

[root@c1 ]# cat /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
HWADDR=08:00:27:2E:24:80
TYPE=Ethernet
UUID=02e21921-20a5-4490-bf4a-052ab8cb6c11
ONBOOT=yes
NM_CONTROLLED=no
BOOTPROTO=none
IPADDR=192.168.0.55
NETMASK=255.255.255.0

NTP configuration: ON ALL 3 nodes. You must install and start the NTP time synchronization
service to maintain consistent time throughout the cluster:

[root@node-1 ~]# yum install ntp –y

Installation time is synchronized with official CentOS NTP
servers. If you want to change this, edit the NTP configuration file at /etc/
ntp.conf.
You must start the NTP service and make sure it starts at boot. In the
following screenshot, you can see the commands used:
[root@c1 ~]# service ntpd start
[root@c1 ~]# chkconfig ntpd on

Setting up corosync

setup iptables to allow cluster communication traffic among cluster nodes. You must add an iptables rule to allow UDP traffic on 5404 and 5405, and another rule to allow multicast traffic communication :

iptables -I INPUT -m state --state NEW -p udp -m multiport --dports 5404,5405 -j ACCEPT

iptables -I INPUT -m addrtype --dst-type MULTICAST -j ACCEPT

The default Corosync cluster communication ports are 5404 and
5405, and the UDP protocol is used. The ports are configured in the
/etc/corosync/corosync.conf configuration file. If you want
to change the default Corosync communication ports, make sure you
change iptables accordingly.

service iptables save

yum install corosync -y   #do it on all nodes

#generate corosync encryption key on any one node and transfer it to rest of nodes

#corosync-keygen
it might take long time so to speed up
dd if=/dev/random of=test123.log

Make backup of original file and rename on any one node.
[root@c1 ~]# cp /etc/corosync/corosync.conf.example /etc/corosync/corosync.conf
#vim corosync.conf

 Remove all commented-out lines—lines starting with #—and change the
secauth parameter to on.
 Change the bindnetaddr parameter to the current cluster node's IP address.



 * Remove all commented-out lines—lines starting with #—and change the
secauth parameter to on.
 * Change the bindnetaddr parameter to the current cluster node's IP address.
* Change the to_syslog parameter to no. We will use a separate log file, so there's no need to duplicate the information in syslog.

Now scp the corosync.conf to all rest of nodes

On all nodes
#service corosync start
#chkconfig corosync on

To check if members have joined
[root@c3 ~]# corosync-objctl  | grep member.*ip
runtime.totem.pg.mrp.srp.members.3.ip=r(0) ip(192.168.0.77)
runtime.totem.pg.mrp.srp.members.1.ip=r(0) ip(192.168.0.55)
runtime.totem.pg.mrp.srp.members.2.ip=r(0) ip(192.168.0.66)

You can stop corosync for some time on all nodes
#service corosync stop


Install CMAN on all nodes

yum install cman -y

Create cluster.conf file on any one node and copy to rest of nodes

cat /etc/cluster/cluster.conf

<?xml version="1.0"?>
<cluster config_version="3" name="hacluster">
    <logging debug="off"/>
    <clusternodes>
        <clusternode name="c1" nodeid="1"/>
        <clusternode name="c2" nodeid="2"/>
        <clusternode name="c3" nodeid="3"/>
    </clusternodes>
    <rm>
        <failoverdomains>
            <failoverdomain name="simple" nofailback="1" ordered="0" restricted="0">
                <failoverdomainnode name="c1"/>
                <failoverdomainnode name="c2"/>
                <failoverdomainnode name="c3"/>
            </failoverdomain>
        </failoverdomains>
    </rm>
</cluster>

The config_version parameter is the version of the CMAN
configuration file(it should be same on all nodes and should be increased by one+ when changed similar to serial number in bind zone configuration), and the name parameter is your preferred cluster name.
The debug parameter is set to off and should be turned on for debugging purposes.The clusternodes section is where the cluster nodes are configured. The clusternode parameter is defined by a name parameter, which is the FQDN or short node name, and the nodeid parameter, which is the ID of the cluster node.

Once the CMAN service has been successfully started on all cluster nodes, check the CMAN node status using the cman_tool nodes command. All three cluster nodes should be listed with status as M. In the following screenshot, you can see the output of the cman_tool nodes command issued on the node-1 cluster node:

[root@c1 ~]# cman_tool nodes
Node  Sts   Inc   Joined               Name
   1   M    364   2015-08-26 10:53:04  c1
   2   M    372   2015-08-26 10:54:14  c2
   3   M    368   2015-08-26 10:53:18  c3

Let's take a look at each column in more detail:
•     Node: This column shows the node ID number.
•     Sts: This column shows the cluster node status, with M indicating that the
node is a joined cluster member and X indicating that the node is dead.
•     Inc: This column is for debugging purposes only. It is the incarnation number.
•     Joined: This column shows the time the cluster member joined the cluster.
•     Name: This column shows the cluster node name as defined in the cluster.conf file.

Check quorum status:-

[root@c1 ~]# cman_tool status
Version: 6.2.0
Config Version: 3
Cluster Name: hacluster
Cluster Id: 10117
Cluster Member: Yes
Cluster Generation: 372
Membership state: Cluster-Member
Nodes: 3
Expected votes: 3
Total votes: 3
Node votes: 1
Quorum: 2 
Active subsystems: 7
Flags:
Ports Bound: 0 
Node name: c1
Node ID: 1
Multicast addresses: 239.192.39.172
Node addresses: 192.168.0.55

Nodes: This line is where the number of your cluster nodes
should be listed

Expected votes: This line shows the number of expected votes
in the currently active configuration

Total votes: This line shows the number of total votes provided
by the CMAN configuration file

Node votes: This line shows the number of votes the current
node has

Quorum: This line shows the number of votes required to reach
Quorum

The finishing touch for the CMAN installation and configuration process is the start of a service called ricci. "The ricci service provides on-the-fly CMAN configuration file distribution."

setup password for ricci user and start ricci on all nodes-

passwd ricci
Password: ********


service ricci start
chkconfig ricci on


Setup RG Manager on all nodes:-

iptables -I INPUT -m state --state NEW -p tcp -m multiport --dports 11111,21064,41966,41967,41968,41969 -j ACCEPT

service iptables save
service iptables restart

yum install rgmanager -y

service rgmanager start
chkconfig rgmanager on

Check cluster status:-

#clustat

#Member status: This line provides information about the
Quorum status.
#Member Name: This column shows the cluster node name as
defined in the cluster.conf configuration file.
#ID: This column shows the node ID number.
#Status: This column provides information about the node's
status. The output of the clustat command must list all
the cluster nodes as online, confirming that installation and
configuration of the cluster stack software on CentOS 6 were
successful and that you did a great job at it.


Edit cluster.conf file on any one node(you may need to manually create/copypaste same file on node which is offline) , make sure to increment configversion="" after making changes:-

[root@c1 ~]# cat /etc/cluster/cluster.conf
<?xml version="1.0"?>
<cluster config_version="3" name="hacluster">
    <logging debug="off"/>
    <clusternodes>
        <clusternode name="c1" nodeid="1"/>
        <clusternode name="c2" nodeid="2"/>
        <clusternode name="c3" nodeid="3"/>
    </clusternodes>
    <rm>
        <failoverdomains>
            <failoverdomain name="simple" nofailback="1" ordered="0" restricted="0">
                <failoverdomainnode name="c1"/>
                <failoverdomainnode name="c2"/>
                <failoverdomainnode name="c3"/>
            </failoverdomain>
        </failoverdomains>
    </rm>
</cluster>

To validate

[root@c1 ~]# ccs_config_validate
Configuration validates

Once it is found valid, you can propagate to other nodes

# cman_tool version -r

Note that, if a specific cluster node is not online, the configuration file will have to be transferred manually and the cluster stack software will have to be restarted to catch up once it comes back online.

You can confirm that the configuration file was successfully
distributed by issuing the ccs_config_dump command on any of
the other cluster nodes and comparing the XML output.

[root@c3 ~]# ccs_config_dump
<?xml version="1.0"?>
<cluster config_version="3" name="hacluster">
    <logging debug="off"/>
    <clusternodes>
        <clusternode name="c1" nodeid="1"/>
        <clusternode name="c2" nodeid="2"/>
        <clusternode name="c3" nodeid="3"/>
    </clusternodes>
    <rm>
        <failoverdomains>
            <failoverdomain name="simple" nofailback="1" ordered="0" restricted="0">
                <failoverdomainnode name="c1"/>
                <failoverdomainnode name="c2"/>
                <failoverdomainnode name="c3"/>
            </failoverdomain>
        </failoverdomains>
    </rm>
    <cman nodename="c3" cluster_id="10117"/>
</cluster>








































x11 forwarding in ubuntu 14.04 LTS

On server
======================
apt-get install xauth

/etc/ssh/ssh_config    #ssh client system-wide configuration file


Host *

ForwardX11 yes
ForwardX11Trusted yes


/etc/ssh/sshd_config     #daemon configuration

X11Forwarding yes
X11DisplayOffset 10


At client
==============
ssh -X user1@192.168.0.135

echo $DISPLAY
localhost:19.0



If it says anything other than localhost, it's quite possible you are not configured properly. If it says nothing, go down to the Configuring the SSH Server line.
To perform an actual test of the graphics, run xclock. A small clock should appear on your desktop if it works.
#to run firefox browser

#firefox -no-remote