How to find the External IP if it is Natted

If you are behind a NAT  and want to  find the real / external IP from  the server then execute one of the below command from the server ::

root@server[#] curl -s http://checkip.dyndns.org | html2text | awk -F ':' '{print $2}'

or

root@server[#] curl http://icanhazip.com/

or

root@server[#] curl http://myexternalip.com/raw

or

root@server[#] curl  ifconfig.me

The last one is a bit slower but it does show the external IP.

That’s all.

 

Roundcube : failed to open log file /var/log/httpd/suexec_log

While working on a issue for one of the client, I found that the Webmail link was giving 500 internal server error for Roundcube and checking the apache error logs I was getting the below errors ::

failed to open log file /var/log/httpd/suexec_log
fopen: Permission denied
[Mon Aug 18 16:50:08 2014] [warn] [client x.x.x.x] (104)Connection reset by peer: mod_fcgid: error reading data from FastCGI server
[Mon Aug 18 16:50:08 2014] [error] [client x.x.x.x] Premature end of script headers: index.php

Further checking , I’ve found that the below file was missing ::

/var/www/cgi-bin/cgi_wrapper/cgi_wrapper

So, I’ve copied that file from one of my other server and restarted apache service and this fixed the issue with  500 internal error for roundcube.

Note :: The cgi_wrapper file should have 755 permission with ownership of root:root.

Easy isn’t it.

Simple shell script to check if a Host is UP

If you work on multiple servers and want to check what hosts are up/down then you can use the below shell script to  test multiple servers  connectivity ::

#!/bin/bash
# test1.txt should contain a list of IP's to be tested
for i in `cat test1.txt`;
 do
ping -c 1 -W 1 $i &> /dev/null
if [ $? -ne 0 ]; then
#use if [ $? -eq 0 ]; then to test the up IP's
echo "$i is down"
fi
 done

That’s all.