Wednesday, November 7, 2007

postfix/smtp connect to gmail.com[64.233.171.83]: Connection timed out (port 25) server dropped connection without sending the initial SMTP greeting

Postfix has been configured fine.
The mail is working in the local Domain - mydomain.com


But when I try to send mails to outer domains,it produces the following "TIMEOUT" errors in /var/log/mail/info




Nov 5 23:02:43 mydomain postfix/pickup[30923]: 419941C678: uid=555 from=
Nov 5 23:02:43 mydomain postfix/cleanup[31536]: 419941C678: message-id=<20071106050243.419941C678@mydomain.com>
Nov 5 23:02:43 mydomain postfix/qmgr[22926]: 419941C678: from=, size=330, nrcpt=1 (queue active)
Nov 5 23:03:13 mydomain postfix/smtp[31538]: connect to yahoo.com[66.94.234.13]: Connection timed out (port 25)
Nov 5 23:03:13 mydomain postfix/smtp[31538]: connect to yahoo.com[216.109.112.135]: server dropped connection without sending the initial SMTP greeting (port 25)
Nov 5 23:03:13 mydomain postfix/smtp[31538]: 419941C678: to=, relay=none, delay=30, status=deferred (connect to yahoo.com[216.109.112.135]: server dropped connection without sending the initial SMTP greeting)
Nov 5 23:03:51 mydomain postfix/qmgr[22926]: 419941C678: from=, size=330, nrcpt=1 (queue active)
Nov 5 23:03:51 mydomain postfix/qmgr[22926]: 7C14E1C672: from=, size=533, nrcpt=1 (queue active)
Nov 5 23:03:51 mydomain postfix/qmgr[22926]: CD7961C73C: from=, size=527, nrcpt=1 (queue active)
Nov 5 23:03:51 mydomain postfix/smtp[31538]: connect to yahoo.com[216.109.112.135]: server dropped connection without sending the initial SMTP greeting (port 25)
Nov 5 23:04:21 mydomain postfix/smtp[31546]: connect to gmail.com[64.233.171.83]: Connection timed out (port 25)
Nov 5 23:04:21 mydomain postfix/smtp[31547]: connect to gmail.com[72.14.253.83]: Connection timed out (port 25)
Nov 5 23:04:21 mydomain postfix/smtp[31538]: connect to yahoo.com[66.94.234.13]: Connection timed out (port 25)


Nov 6 23:25:30 mydomain postfix/qmgr[11674]: B5DCA1C693: from=,
size=507, nrcpt=1 (queue active) Nov 6 23:26:00 mydomain postfix/smtp[13277]: connect to hotmail.com[64.4.33.7]: Connection timed out (port 25)
Nov 6 23:26:00 mydomain postfix/smtp[13278]: connect to gmail.com[64.233.171.83]: Connection timed out (port 25)
Nov 6 23:26:30 mydomain postfix/smtp[13277]: connect to hotmail.com[64.4.32.7]: Connection timed out (port 25) Nov 6 23:26:30 mydomain postfix/smtp[13277]: 07D5B1C678: to=, relay=none, delay=83207, status=deferred (connect to hotmail.com[64.4.32.7]: Connection timed out)
Nov 6 23:26:30 mydomain postfix/smtp[13278]: connect to gmail.com[64.233.161.83]: Connection timed out (port 25)
Nov 6 23:27:00 mydomain postfix/smtp[13278]: connect to gmail.com[72.14.253.83]: Connection timed out (port 25)



I messed up with it a lot .

It got solved by replacing

disable_dns_lookups = yes

with

disable_dns_lookups = no

in /etc/postfix/main.cf


And apart from this the the folowing may cause this issue ( I am not sure ).

1. The Server is under Firewall
2. Your Server IP may be listed in some SPAM list
3. Improperly configured "relayhost=" entry
4. The faulty main.cf

etcetera.........

Monday, November 5, 2007

QMAIL port 25 and 110 are closed

Qmail installation went fine .But I was unable to connect to port 25 and 110.They were in closed state.When I tried to connect with telnet I got the “Connection refused” message.



# qmailctl stat
/service/qmail-send: up (pid 2219) 37 seconds
/service/qmail-send/log: up (pid 2311) 37 seconds
/service/qmail-smtpd: up (pid 2917) 1 seconds
/service/qmail-smtpd/log: up (pid 2723) 37 seconds
/service/qmail-pop3d: up (pid 2724) 1 seconds
/service/qmail-pop3d/log: up (pid 2989) 37 seconds
messages in queue: 0
messages in queue but not yet preprocessed: 0

Looks good but when I try to connect on the mail server I got the connection problem.

]# telnet localhost 110
Trying 127.0.0.1...
telnet: connect to address 127.0.0.1: Connection refused


# telnet localhost 25
Trying 127.0.0.1...
telnet: connect to address 127.0.0.1: Connection refused



I have checked the logs for qmail-smtpd and qmail-pop3d and contains a lots of error lines like the following:
tcpserver: fatal: temporarily unable to figure out IP address for 0.0.0.0: file does not exist

I tried nmap

# nmap localhost

Starting nmap 3.70 ( http://www.insecure.org/nmap/ ) at 2007-11-05 10:47 IST
Interesting ports on localhost.localdomain (127.0.0.1):
(The 1655 ports scanned but not shown below are in state: closed)
PORT STATE SERVICE
80/tcp open http
111/tcp open rpcbind
143/tcp open imap
443/tcp open https
877/tcp open unknown
3306/tcp open mysql

Nmap run completed -- 1 IP address (1 host up) scanned in 0.224 seconds

Here the ports 25 and 110 are closed


# qmailctl stop
Stopping qmail...

qmail-smtpd
qmail-send
qmail-pop3d

# qmailctl start
Starting qmail...

Starting qmail-send
Starting qmail-smtpd
Starting qmail-pop3d


# qmailctl stat
/service/qmail-send: up (pid 2921) 37 seconds
/service/qmail-send/log: up (pid 2926) 37 seconds
/service/qmail-smtpd: up (pid 3144) 1 seconds
/service/qmail-smtpd/log: up (pid 2934) 37 seconds
/service/qmail-pop3d: up (pid 3149) 1 seconds
/service/qmail-pop3d/log: up (pid 2938) 37 seconds
messages in queue: 0
messages in queue but not yet preprocessed: 0


# nmap localhost

Starting nmap 3.70 ( http://www.insecure.org/nmap/ ) at 2007-11-05 10:47 IST
Interesting ports on localhost.localdomain (127.0.0.1):
(The 1655 ports scanned but not shown below are in state: closed)
PORT STATE SERVICE
80/tcp open http
111/tcp open rpcbind
143/tcp open imap
443/tcp open https
877/tcp open unknown
3306/tcp open mysql

Nmap run completed -- 1 IP address (1 host up) scanned in 0.224 seconds

Finally I've got the solution from
QmailRocks

For the can't find IP address, fix this by "touch /etc/dnsrewrite"

I did the same "touch /etc/dnsrewrite" and a QMAIL RESTART.


# touch /etc/dnsrewrite
# qmailctl restart


It worked. Great.


# nmap localhost

Starting nmap 3.70 ( http://www.insecure.org/nmap/ ) at 2007-11-05 10:47 IST
Interesting ports on localhost.localdomain (127.0.0.1):
(The 1655 ports scanned but not shown below are in state: closed)
PORT STATE SERVICE
25/tcp open smtp
80/tcp open http
110/tcp open pop3
111/tcp open rpcbind
143/tcp open imap
443/tcp open https
877/tcp open unknown
3306/tcp open mysql

Nmap run completed -- 1 IP address (1 host up) scanned in 0.224 seconds

Saturday, November 3, 2007

BASH Script to Generate files from existing ones with a partial change in filename

#!/bin/bash
# BASH Script to generate $EXTENSION files like FILE_fr.$EXTENSION,FILE_sp.$EXTENSION from existing FILE_$SEARCHSTRING.$EXTENSION without causing any kind of overwrite.
DIR=/tmp/html
EXTENSION=extension
SEARCHSTRING=en
cd $DIR > /dev/null 2> /dev/null
count=`find *$SEARCHSTRING.$EXTENSION | wc -l`
n=1
echo $count \"*$SEARCHSTRING.$EXTENSION\" files found
while [ $n -le $count ]
do
{
filename=`find *$SEARCHSTRING.$EXTENSION | head -$n | tail -1`
echo $filename
language=(fr sp po)
for (( i = 0 ; i < ${#language[@]} ; i++ ))
do

value=`ls $filename | awk -F "$SEARCHSTRING.$EXTENSION" {'print $1'}`
find "$value""${language[$i]}".$EXTENSION > /dev/null 2> /dev/null
if [ $? != 0 ]
then
{
cp "$value"$SEARCHSTRING.$EXTENSION "$value""${language[$i]}".$EXTENSION
}
fi
done
n=$[$n + 1]
}
done
cd - > /dev/null 2> /dev/null
exit

A Simple Service Monitor

#!/bin/bash
# Check the Service Status of Server and send notification mail if anyone is DOWN.
Server=192.168.0.35 ## IP of the remote Server to be monitored
ADMIN=hareeshvv@gmail.com ## Mail ID of Admin
Subject=Server-Status
DATE=`date +%d.%m.%Y`
TIME=`date +%H.%M.%S`

mkdir /tmp/$DATE.$TIME
cd /tmp/$DATE.$TIME
services=(http https mysql smtp pop imap imaps ssh) ## List of services to be checked

Watch () {
#nmap $Server | grep ${services[$i]} > /dev/null 2> /dev/null ## Use this one for Remote Server which is not behind any firewall
netstat -ntpl | grep ${services[$i]} > /dev/null 2> /dev/null ## Use this locally
if [ $? != 0 ]
then
echo ${services[$i]} is DOWN >> result
fi
}

for (( i = 0 ; i < ${#services[@]} ; i++ ))
do
Watch ${services[$i]}
done


grep DOWN result > /dev/null 2> /dev/null
if [ $? = 0 ]
then
count=`grep DOWN result | wc -l`
if [ ${#services[@]} = $count ]
then
echo "All Services are down" >> result
echo "Even the Server may be down" >> result
fi
mail -s $Subject $ADMIN < result
fi
rm -rf result
cd - > /dev/null
exit

How to Create Custom Hot key to Launch Applications in GNOME

1. Open Applications -> System -> Configuration Editor from the GUI

OR

Open a terminal, type gconf-editor

2. Go to "apps" -> "metacity" -> "keybinding_commands"
3. Double-click on an unused element e.g. "command_10"
4. Type in the name of the application you want to launch, for e.g. "firefox" or
"gnome-terminal"
5. Then go to "apps" -> "metacity" -> "global_keybindings"
6. Double-click on the command name that we have edited in "keybinding_commands" Section.
Here for me it is "run_command_10"
7. Then enter the Keyboard shortcut you would like to launch the application
I entered
"<"Alt">"t
here (without the quotes) for gnome-terminal.

Thats all

Go to Desktop and type Alt+t a GNOME terminal should open. It will depend on the active Windows also since some other applications may be having the same HotKey.

Simple Disk and Memory Monitor

#!/bin/sh
# Shell script to monitor the disk space,Memory,SWAP Usage and send an email to $ADMIN, if the free avilable percentage of space is >= $ALERT

ADMIN="hareeshvv@gmail.com"
ADMIN1="admin1@mycompany.com"
ADMIN2="admin2@mycompany.com"


# Alert Level Percentage of Disk Usage . Default is 90%
ALERT=90
df -h | grep -vE '^Filesystem|tmpfs|cdrom' | awk '{ print $5 " " $1 }' | while read output;
do
used=$(echo $output | awk '{ print $1}' | cut -d'%' -f1 )
partition=$(echo $output | awk '{ print $2 }' )
mountpoint=`mount | grep $partition | cut -f3 -d" "`

if [ $used -ge $ALERT ]; then
echo "Running out of space \"$partition ($used%) mounted on $mountpoint\" on $(hostname) as on $(date)" |
mail -s "Alert: Almost out of disk space $used" -c $ADMIN1,$ADMIN2 $ADMIN
fi
done

# Alert on RAM and SWAP Usage

MEM=`free -m | grep Mem | awk -F" " {'print $2'}`
USEDMEM=`free -m | grep Mem | awk -F" " {'print $3'}`
SWAP=`free -m | grep Swap | awk -F" " {'print $2'}`
USEDSWAP=`free -m | grep Swap | awk -F" " {'print $3'}`
echo "Total Memory - $MEM" > /tmp/memorystatus
echo "Used - $USEDMEM" >> /tmp/memorystatus
echo "Total Swap - $SWAP" >> /tmp/memorystatus
echo "Used Swap - $USEDSWAP" >> /tmp/memorystatus
echo "on $(hostname) as on $(date)" >> /tmp/memorystatus

mail -s "Memeory Usage" -c $ADMIN1,$ADMIN2 $ADMIN < /tmp/memorystatus

Wednesday, October 17, 2007

ConCatPASSWD.sh

#!/bin/bash
# Concatenate two passwords files. The resulting will contain entries of the first file with UID < 500 and that of second with UID > 500
DATE=`date +%d.%m.%Y`
TIME=`date +%H.%M.%S`
echo Name of File 1
read f1
echo Name of File 2
read f2
echo Name for New file
read newfile
mv $newfile $newfile.bak.$DATE.$TIME


## Manipulate first file

count=`cat $f1 | cut -f3 -d : | sort -n | wc -l`
h=1
while [ "$count" -ge "$h" ]
do
{
id=`head -$h $f1 | tail -1 | cut -f3 -d:`
if [ $id -lt "500" ]
then
{
head -$h $f1 | tail -1 >> $newfile
}
fi
h=$[$h + 1 ]
}
done

## file 2
count=`cat $f2 | cut -f3 -d : | sort -n | wc -l`
count=$(`expr 'cat count'`)
h=1
while [ "$count" -ge "$h" ]
do
{
id=`head -$h $f2 | tail -1 | cut -f3 -d:`
if [ $id -gt "499" ]
then
{
username=`head -$h $f2 | tail -1 | cut -f1 -d:`
grep $username: $newfile
if [ $? = "0" ]
then
echo "User $username or *$username* already exists in $newfile came from $f1 with UID less than 500"
else
head -$h $f2 | tail -1 >> $newfile
fi

}
fi
h=$[$h + 1 ]
}
done

AT&T USA | Internet not working | Fix by custom APN

If the AT&T Mobile internet is not working on your cellphone, it can be fixed easily by adding an APN configuration. You can read this a...