Thursday, 25 July 2013

Assign dedicated ip to a domain in Cpanel

Assigning dedicated ip to an account is simple. You just need to follow the steps below.


Home » IP Functions







Home » IP Functions » Change a Site’s IP Address


From here select the account for which the ip has to be changed. Once selected click "Change" button at the bottom.



Now select the ip from the list that you click on the drop down button, and click " Change ".

This will change the ip of the account. 

Wednesday, 24 July 2013

Enable TUN/TAP in OpenVZ

For installing TUN/TAP for a OpenVZ vps, you should first make sure that the module is enabled in the node.

For this you need to run the command bellow.
# lsmod | grep tun
 If the module is not installed, just install it by running
# modprobe tun
Now to enable the module to the vps, run the following commands. Replace Veid with your vps id

# vzctl set Veid --devnodes net/tun:rw --save
# vzctl set Veid --devices c:10:200:rw --save
# vzctl stop Veid 
# vzctl set Veid --capability net_admin:on --save
# vzctl start Veid
# vzctl exec Veid mkdir -p /dev/net
# vzctl exec Veid chmod 600 /dev/net/tun
Now TUN/TAP is enabled for the vps. To check this get into the vps.
# vzctl enter Veid
Now run the following command in the vps.
# cat /dev/net/tun
 The result of the above command should be
cat: /dev/net/tun: File descriptor in bad state

Saturday, 20 July 2013

!! 'httpd' is disabled via '/etc/apachedisable', please re-enable to continue. !!

You may end up with the following error while running /scripts/easyapache

!! 'httpd' is disabled via '/etc/apachedisable', please re-enable to continue. !!

To resolve this, Login to your WHM

HomeHome » Service Configuration » Service Manager

The boxes for http would be unchecked, Just check it



Then Click the " Save " button at the bottom of the page.


Now you can run easyapache without any issue.


Friday, 5 July 2013

Error: Device 768 (vbd) could not be connected. Hotplug scripts not working


When you try to start a Xen vps from solusVM, It wont get started. If you try to start from the backend, you may end up with following error.

# xm create /home/xen/vm123/vm123.cfg
          Using config file "/home/xen/vm123/vm123.cfg".          Error: Device 768 (vbd) could not be connected. Hotplug scripts not working.

Check the hotplug error log :

# tail /var/log/xen/xen-hotplug.log
If you get the following output :

         stat: cannot stat `/dev/xensan/vm123_img': No such file or directory
         Nothing to flush.

Activating the corresponding logical volumes for the vps will fix the issue.


# lvchange -ay /dev/xen**/vm123_img




Missing Perl Libraries error while installing CSF on CentOs 5/6


While installing CSF you may end up with the following error. 

Checking Perl modules...
Can't locate LWP/UserAgent.pm in @INC (@INC contains: /etc/csf /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at (eval 22) line 2.
BEGIN failed--compilation aborted at (eval 22) line 2.

Can't locate Time/HiRes.pm in @INC (@INC contains: /etc/csf /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at (eval 27) line 2.
BEGIN failed--compilation aborted at (eval 27) line 2.


This have got a simple one line fix. Just do the following. 

root@amaziah [~]# yum install -y perl-libwww-perl perl-Time-HiRes


Download speed issue in Xen VPS


For fixing download speed issue in Xen VPS. Make following changes in the vps.

Edit the /etc/sysctl.conf file.

root@amaziah [~]# vi /etc/sysctl.conf
And then add the following lines to the end of the file.

net.core.rmem_max=16777216
net.core.wmem_max=16777216
net.ipv4.tcp_rmem=4096 87380 16777216
net.ipv4.tcp_wmem=4096 65536 16777216

 Now for the changes to take effect, either reboot the vps or issue the following command.

root@amaziah [~]# sysctl -p

Change timezone in Xen VPS


The file /etc/localtime is the one which holds information of server’s timezone.

For changing the timezone you should point it to the correct zone file by creating a soft link.

From following commands below we are changing the current timezone to IST:

Firstly move the current localtime file as backup.

#mv /etc/localtime /etc/localtime.bak
Now from /usr/share/zoneinfo/ you can find the preferred timezone. Once you found the timezone file, crate a soft link   to  /etc/localtime. Eg: For IST

#ln -sf /usr/share/zoneinfo/Asia/Calcutta /etc/localtime
You are done!! You can find the timezone changed. But if you reboot the vps the settings will get reverted back. So once finishing the steps above, do the following. 

 Run following command

echo 1 > /proc/sys/xen/independent_wallclock

Now installed ntp in the vps.

# yum install ntp 
# chkconfig ntpd on

 Synchronize the system clock with 0.pool.ntp.org server:

# ntpdate pool.ntp.org

Start NTP

# /etc/init.d/ntpd start


Now edit /etc/rc.local with your favorite editor and put the following lines there.

# vi  /etc/rc.local

service ntpd stop
echo 1 > /proc/sys/xen/independent_wallclock
ntpdate pool.ntp.org
service ntpd start


You would now get correct timezone and correct time every time you reboot your Xen VPS.



Change timezone in Openvz VPS



The file /etc/localtime is the one which holds information of server’s timezone.

For changing the timezone you should point it to the correct zone file by creating a soft link.

From following commands below we are changing the current timezone to IST:

Firstly move the current localtime file as backup.

#mv /etc/localtime /etc/localtime.bak
Now from /usr/share/zoneinfo/ you can find the preferred timezone. Once you found the timezone file, crate a soft link   to  /etc/localtime. Eg: For IST

#ln -sf /usr/share/zoneinfo/Asia/Calcutta /etc/localtime
Once the link is created, reboot the vps. 

#reboot

You are done!! Now you can find your timezone.



Thursday, 4 July 2013

How to setup custom nameservers in Kloxo


To setup custom nameservers in Kloxo, you have to register custom nameservers with your server IP address at your domain registrar.


After custom nameservers has been  registered in your domain registrar control panel, you can setup custom nameservers inside your Kloxo panel. For that you can follow the steps below. 


1. Login to Kloxo as " admin ".

2. From the home screen, click on the " DNS Templates " icon.

3. Now click the " Add DNS Template ".

4. Fill in the form.

5. In DNS Template Name field enter your prefered DNS template name (Any name).

6. From the dropdown lists choose your IP address for your Web and Mail services.

7. In "Primary DNS" and "Secondary DNS" enter your custom nameservers hostnames (The same you have registered in your domain registrar control panel).

8. Press " Add " button.

9. Then change DNS for your domain to you custom DNS servers at your domain registrar.

10. If all setup is done correctly, then it may take up to a 24-48 hours for DNS change to take effect.



Wednesday, 3 July 2013

error: configure: error: APR is needed to build mod_suphp for Apache 2.x but was not found

If you are facing the following error while installing suPhp

error: configure: error: APR is needed to build mod_suphp for Apache 2.x but was not found

Run ./configure as shown below.

# ./configure --with-apr=/usr/bin/apr-1-config
This should fix the issue. Now you can proceed with

# make
# make install



How to Flush DNS

How to Flush DNS cache in Microsoft Windows

For this just to the following steps.

Start => Run => cmd

Now give the following command in the command prompt

c:\> ipconfig /flushdns 

You are Done!!


How to Flush DNS cache in a Linux Server

For this login to the server. And issue the following command.

root@amaziah [~]# /etc/init.d/nscd restart
                          OR
root@amaziah [~]# service nscd restart
                          OR
root@amaziah [~]# service nscd reload


This will flush DNS cache in Linux.


How to restrict the users accessing a directory

Suppose you have a domain example.com. In the document root of example.com you have a directory "confidential". And you don't want all people to access this directory. So to restrict the access to this directory except few ips. For example 192.168.1.1, 192.168.1.2, 192.168.1.3. Then  you need to follow the steps given below.

First create a file .htaccess  in  "confidential" directory.

root@amaziah [~]#cd /document root/confidential 
#touch .htaccess

Now edit .htaccess using your favorite editor

#vi .htaccess
 Order Deny,Allow
Deny from all
Allow from 192.168.1.1
Allow from 192.168.1.2
Allow from 192.168.1.3
 

Now your confidential data are safe. Only users from 192.168.1.1, 192.168.1.2 & 192.168.1.3 can access it. All others will be denied.  :)



How to block Ddos


You can find the ips which have most number of connections with the command below.

netstat -anp |grep 'tcp\|udp' | awk '{print $5}' | cut -d: -f1 | sort | uniq -c | sort -n

The result of above command will look something like that is given below.

1 192.168.1.1
1 192.168.1.2
15 192.168.2.26
25 192.168.2.27
30 192.168.1.29
39 192.168.1.32
100 192.168.1.50


You can use the following script to block the ips causing ddos.


#!/bin/bash


netstat -anp |grep 'tcp\|udp' | awk '{print $5}' | cut -d: -f1 | sort | uniq -c | sort -n > test.out
for i in `cat test.out | awk '{print $2}' `
do
 {
 if [ "$i" != "127.0.0.1" ] && [ `cat test.out | grep $i | awk '{print$1}'` -gt 35 ] && [  "$i" != "0.0.0.0" ]
 then
 iptables -A INPUT -s $i -j DROP
 echo "Writing the rule :iptables -A INPUT -s $i -j DROP"
 fi
 }
done

How to Install maldetect

For installing Maidetect in your server, login to your server.

Download the latest tar file available using wget .

#wget http://www.rfxn.com/downloads/maldetect-current.tar.gz
Extract the file using the the command below.

# tar -xzvf maldetect-current.tar.gz
Get into the directory  maldetect-*

# cd maldetect-1.4.2/
Now issue the following command, which will install maldetect in your server

# sh install.sh

Now for scanning a particular directory "eg: /home"  using maldetect, issue the below command

#maldet -a  /home

Install rkhunter

The following steps explains how to install rkhunter in your server.

Firstly login to your server as root. And navigate to the directory where you would download the file.

# cd /usr/local/src

Now download the source file using wget.

# wget http://nchc.dl.sourceforge.net/project/rkhunter/rkhunter/1.4.0/rkhunter-1.4.0.tar.gz

Now extract the file using the following comand.

# tar -zxvf rkhunter-1.4.0.tar.gz

And get into the directory rkhunter-*

# cd rkhunter-1.4.0

Now, the command below will install rkhunter in your server.

# ./installer.sh --install
Now to automate the scan do the following steps below. We are creating the file in /usr/local/

# vi rkhunterscan

Add the following script to the file.

#!/bin/sh

( /usr/local/bin/rkhunter --versioncheck
/usr/local/bin/rkhunter --update
/usr/local/bin/rkhunter --cronjob --report-warnings-only
) | /usr/bin/mail -s "rkhunter output" admin@yourdomain.com
Now change the permission.

# chmod 750 rkhunterscan
Now edit the cronjob.

# crontab -e

Now add the following line.

0 3 * * * /usr/local/rkhunterscan -c





Email alert on root ssh login

For setting up email alert on root login, firstly login to the server.

Then get into the directory /root

# cd /root

The using your favorite editor, edit the file ".bashrc"

# vi .bashrc

Go to the end of the file. And insert the following line.

echo 'ALERT - Root Shell Access (YourserverName) on:' `date` `who` | mail -s "Alert: Root Access from `who | cut -d'(' -f2 | cut -d')' -f1`" you@yourdomain.com

Replace the following in the line with your variables.

YourserverName = Server hostname or Server IP address
you@yourdomain.com = Your mail id where you would like to receive the alert.


You are DONE!! Now if you login to the server, you will be receiving email alert at you@yourdomain.com.


Tuesday, 2 July 2013

Enable/Disable ping in a server

To disable ping in the server, you can execute the following

root@amaziah [~]# echo "1" > /proc/sys/net/ipv4/icmp_echo_ignore_all

Now, if you want to re-enable it,

root@amaziah [~]# echo "0" > /proc/sys/net/ipv4/icmp_echo_ignore_all

Now to disable it permanently, you can edit /etc/sysctl.conf

root@amaziah [~]#vi /etc/sysctl.conf

edit the following line

net.ipv4.icmp_echo_ignore_all = 0

and replace the "0" with "1" ie.

net.ipv4.icmp_echo_ignore_all = 1

 then save and close the file.






Tuesday, 11 June 2013

Exception printing is disabled by default for security reasons.


Exception printing is disabled by default for security reasons.

Error log record number: ******

Mostly for magento sites you face this error. 

In this case you need to check following steps.

Go to folder /errors/

Change local.xml.sample to local.xml

After this change you can see few more errors.

Then Open magento/lib/Zend/Cache/Backend/File.php  and search

protected $_options = array(
'cache_dir' => 'null',

and Change it to:

protected $_options = array(
'cache_dir' => 'tmp/',

Save the changes.

create tmp folder under root magento folder.

This should fix the issue.

How to install Chkrootkit

Firstly login to the shell and go to the desired location where the installation file has to be downloaded.

root@amaziah [~]# cd /usr/local/src

Now download Chkrootkit

# wget ftp://ftp.pangeia.com.br/pub/seg/pac/chkrootkit.tar.gz

Unpack the file that you just have downloaded

# tar -xzvf  chkrootkit.tar.gz

Now do the following,

# cd chkrootkit-*

# make sense

We have finished the installation process. You scan the server by

# ./chkrootkit

Now we can set a daily cronjob  to scan the server and send the report to your mail id

# crontab -e

Add the following line

0 1 * * * (cd /usr/local/src/chkrootkit*; ./chkrootkit 2>&1 | mail -s “chkrootkit output” email@domain.com)






Sunday, 5 February 2012

Unable to start SSH: Restarting Secure Shell server: sshd failed! /dev/null is not a character device!.

root@amaziah [~]# /etc/init.d/sshd restart

Restarting Secure Shell server: sshd failed!
/dev/null is not a character device!.

The /dev/null should be a character device as per the Linux standards. This error occurs when /dev/null turns into a regular file.

To fix this issue, firstly delete /dev/null file.

root@amaziah [~]# rm -f /dev/null


And create the character device

root@amaziah [~]# mknod /dev/null c 1 3

root@amaziah [~]# ls -la /dev/null  , the output should look like

crw-rw-rw- 1 root root 1, 3 Oct  1 11:42 /dev/null


Now restart the sshd service

root@amaziah [~]# /etc/init.d/sshd restart

Stopping sshd:              [  OK  ]

Starting sshd:              [  OK  ]




Fixed.........  :)