Posts

dual home network slow response

slow response on linux centos dual home nic on a load balancer down stream smtp solution is echo 2 > /proc/sys/net/ipv4/conf/eth0/rp_filter echo 2 > /proc/sys/net/ipv4/conf/eth1/rp_filter echo 2 > /proc/sys/net/ipv4/conf/eth2/rp_filter also modify /etc/sysctl.conf # Controls source route verification (previously 1) net.ipv4.conf.default.rp_filter = 2  source: https://www.centos.org/forums/viewtopic.php?t=7775

postfix relay transport access denied to downstream servers / clamd + amavis error

http://serverfault.com/questions/583372/postfix-transport-relay-access-denied/583438?noredirect=1#583438 virtual_mailbox_maps=/etc/postfix/virtual_mailbox_maps.txt ------------------------------------------------------- for clamd and amavis as scanner, if there is a clamav permission error add both clamd to amavis group or vice verse also check permission try 755

du cut tr send email notification overquota users in an old mail system linux accounts

Task : to email old users that they have exceeded 100m disk space The problem is that the folder where the user is deep inside 2 folders so "du" is used. tr is used to remove characters cut to get the coloumn http://stackoverflow.com/questions/11049748/how-to-cut-multiple-columns-from-several-files-and-print-the-ouput-to-different   cd /backup/home/virtual du -m --max-depth=2  | tr './' ' ' | cut -d' '  -f 1,4 | while read space user do    if [ $space -gt 100 ]                     then         mail -s "Your account is using over 100MB Disk Space" $user <<MAIL  $user: You are now using $space MB in your home directory. The only total amount of diskspace allowed is 100 MB. MAIL  fi done

varnish web accelerator

Varnish web application accelerator homepage: https://www.varnish-cache.org Install the Varnish YUM Repository # rpm -Uvh http://repo.varnish-cache.org/redhat/varnish-3.0/el5/noarch/varnish-release-3.0-1.noarch.rpm Install Varnish web accelerator # yum install varnish Enable Varnish web accelerator at startup # chkconfig varnish on Basic default.vcl # vi /etc/varnish/default.vcl 1 2 3 4 5 6 7 8 9 10 # This is a basic VCL configuration file for varnish. See the vcl(7) # man page for details on VCL syntax and semantics. # # Default backend definition. Set this to point to your content # server. # backend default { .host = "127.0.0.1"; .port = "80"; } Start Varnish web accelerator # service varnish start You will now have a basic Varnish web accelerator running on port 8080 Top 5 Varnish commands varnishstat Provides all the info you need to spot cache misses and errors. varnishhist Provides a histogram view of cache hits/m...

Centos 4 and Dovecot 1

 Centos 4 and dovecot 1 fail2ban from: http://www.webstershome.co.uk/content/fail2ban-block-unwanted-attacks Create the filter file "/etc/fail2ban/filter.d/dovecot-pop3imap.conf" and add [Definition] failregex = (?: dovecot: pop3-login|imap-login): (?:Authentication failure|Aborted login \(auth failed|Aborted login).*rip=(<HOST>),.* ignoreregex = note: the failregex may need changing to suit your system. now add the following to "/etc/fail2ban/jail.conf" [dovecot-pop3imap] enabled = true filter = dovecot-pop3imap action = iptables-multiport[name=dovecot-pop3imap, port="110,143,995,993,25,465,587"] sendmail-whois[name=dovecot-pop3imap, dest=root, sender=fail2ban@server.com] logpath = /var/log/maillog maxretry = 5 findtime = 600 bantime = 3600

Recursive searching via grep and sed

echo "Enter string to be placed" read NEWSTRING echo "===================================" echo "string to be replaced is $OLDSTRING" echo "string to be placed is $NEWSTRING  " echo "===================================" oldstr=$OLDSTRING #string to be replaced newstr=$NEWSTRING #new string to be placed echo "Enter folder path where we will find the string" read FOLDERPATH ### grep oldstring and output it in grep_output.txt    STEP1 grep -rl $oldstr $FOLDERPATH > grep_output.txt ### since there might be spaces or special characters on filenames, use sed to enclose them with quote and output in  sed_output.txt  STEP2 #for i in `cat grep_output.txt` #do sed -e "s/'/'\\\\''/g;s/\(.*\)/'\1'/" grep_output.txt  > sed_output.txt #done for i in `cat grep_output.txt` do sed -i "s/$oldstr/$newstr/g" $i > sed_output_new_old_string.txt done ## NOTE ## # 2013 latest ## STEP 2 Seems not wo...

Bash create notification using du -h --max-depth

Created this simple script to email disk space usage. #!/bin/bash ## Email directory list if over quota BASE2=/home/vmail/mazaredo.com ## Check whole directory summary BASE=/home/vmail #50GB THRESHOLD=52428800 # out=$(du -s $BASE | cut -f1) # if [ $out -gt $THRESHOLD ] then  echo $out  du -h --max-depth=1 $BASE2 | mail -s "DISK USAGE EXCEEDED" postmaster@example.com else  echo "quota not reached" fi