How to install CSF Firewall on virtuozzo – Cannot enter into server after CSF installation VPS

March 14, 2010 on 4:33 am | In Cpanel, Installation, Linux | No Comments

CSF is a powerful Firewall for Linux and cPanel servers are here are the steps to get it working with Virtuozzo VPS

Installation

rm -fv csf.tgz
wget http://www.configserver.com/free/csf.tgz
tar -xzf csf.tgz
cd csf
sh install.sh

After the installation you will need to customize CSF to run on VPS:

edit /etc/sysconfig/iptables and add

-A FORWARD -j ACCEPT -p all -s 0/0 -i venet0
-A FORWARD -j ACCEPT -p all -s 0/0 -o venet0
-A INPUT -i venet0 -j ACCEPT
-A OUTPUT -o venet0 -j ACCEPT

create file /etc/csf/csfpre.sh and enter all the extra rules directly into it prefixed with “iptables” so the contents of that file should look something like:

iptables -A INPUT -i venet0 -j ACCEPT
iptables -A OUTPUT -o venet0 -j ACCEPT
iptables -A FORWARD -j ACCEPT -p all -s 0/0 -i venet0
iptables -A FORWARD -j ACCEPT -p all -s 0/0 -o venet0

edit /etc/csf/csf.conf file and add
and search for

ETH_DEVICE = ""

change to

ETH_DEVICE = "venet+"

Restart

/usr/sbin/csf -r

LOCKOUT ISSUES FOR CSF WHEN INSTALLED IN VPS. or Cannot enter into server after CSF installation on VPS

If the required IP table modules are not properly loaded to the container node, you may lockout yourself after the installation. If you have access to the main Hardware node, you can perform the following to get it up or ask your VPS provider to perform this on the Hardware (main) node.

Before enabling iptables on VPS, it needs to make sure that the iptables modules are enabled on the Hardware Node. In order to enable iptables modules on Hardware Node, edit /etc/sysconfig/iptables-config file on a Virtuozzo hardware node and look for the following parameter value: IPTABLES_MODULES=. Edit it as the following.

IPTABLES_MODULES=”ipt_REJECT ipt_tos ipt_TOS ipt_LOG ip_conntrack ipt_limit ipt_multiport iptable_filter iptable_mangle ipt_TCPMSS ipt_tcpmss ipt_ttl ipt_length ipt_state iptable_nat ip_nat_ftp”

Also edit /etc/sysconfig/vz file on a hardware node and look for the following parameter value: IPTABLES= , change it to the following.

IPTABLES=”ipt_REJECT ipt_tos ipt_TOS ipt_LOG ip_conntrack ipt_limit ipt_multiport iptable_filter iptable_mangle ipt_TCPMSS ipt_tcpmss ipt_ttl ipt_length ipt_state iptable_nat ip_nat_ftp” 

Now your Hardware node is fine. You need to enable the iptable modules to the VPS nodes.
(CID — container ID. You can find the value for each node by using the command vzlist -a)

vzctl stop CID

vzctl set CID --iptables ipt_REJECT --iptables ipt_tos --iptables ipt_TOS --iptables ipt_LOG --iptables ip_conntrack --iptables ipt_limit --iptables ipt_multiport --iptables iptable_filter --iptables iptable_mangle --iptables ipt_TCPMSS --iptables ipt_tcpmss --iptables ipt_ttl --iptables ipt_length  --iptables ipt_state --iptables iptable_nat --iptables ip_nat_ftp --save

vzctl set CID --numiptent 2000 --save

vzctl start CID

Now try entering into your node and restart CSF. It should start working fine.

Descriptions and Functions

======================

csf+lfd works on all Linux servers on the Operating Systems listed above, with or without cPanel

This suite of scripts provides:

  • Straight-forward SPI iptables firewall script
  • Daemon process that checks for login authentication failures for:
    • Courier imap, Dovecot, uw-imap, Kerio
    • openSSH
    • cPanel, WHM, Webmail (cPanel servers only)
    • Pure-pftd, vsftpd, Proftpd
    • Password protected web pages (htpasswd)
    • Mod_security failures (v1 and v2)
    • Suhosin failures
    • Exim SMTP AUTH
    • Custom login failures with separate log file and regular expression matching
  • POP3/IMAP login tracking to enforce logins per hour
  • SSH login notification
  • SU login notification
  • Excessive connection blocking
  • WHM configuration interface (cPanel servers only) or through Webmin
  • WHM iptables report log (cPanel servers only)
  • Easy upgrade between versions from within WHM (cPanel servers only) or through Webmin
  • Easy upgrade between versions from shell
  • A standard Webmin Module to configure csf is included in the distribution ready to install into Webmin – csfwebmin.tgz
  • Pre-configured to work on a cPanel server with all the standard cPanel ports open (cPanel servers only)
  • Auto-configures the SSH port if it’s non-standard on installation
  • Block traffic on unused server IP addresses – helps reduce the risk to your server
  • Alert when end-user scripts sending excessive emails per hour – for identifying spamming scripts
  • Suspicious process reporting – reports potential exploits running on the server
  • Excessive user processes reporting
  • Excessive user process usage reporting and optional termination
  • Suspicious file reporting – reports potential exploit files in /tmp and similar directories
  • Directory and file watching – reports if a watched directory or a file changes
  • Block traffic on the DShield Block List and the Spamhaus DROP List
  • BOGON packet protection
  • Pre-configured settings for Low, Medium or High firewall security (cPanel servers only)
  • Works with multiple ethernet devices
  • Server Security Check – Performs a basic security and settings check on the server (cPanel servers only)
  • Allow Dynamic DNS IP addresses – always allow your IP address even if it changes whenever you connect to the internet
  • Alert sent if server load average remains high for a specified length of time
  • mod_security log reporting (if installed)
  • Email relay tracking – tracks all email sent through the server and issues alerts for excessive usage (cPanel servers only)
  • IDS (Intrusion Detection System) – the last line of detection alerts you to changes to system and application binaries
  • SYN Flood protection
  • Ping of death protection
  • Port Scan tracking and blocking
  • Permanent and Temporary (with TTL) IP blocking
  • Exploit checks
  • Account modification tracking – sends alerts if an account entry is modified, e.g. if the password is changed or the login shell
  • Shared syslog aware
  • New in v4: Messenger Service – Allows you to redirect connection requests from blocked IP addresses to preconfigured text and html pages to inform the visitor that they have been blocked in the firewall. This can be particularly useful for those with a large user base and help process support requests more efficiently
  • New in v4: Country Code blocking – Allows you to deny or allow access by country – Powered by IPDENY.COM IP database
  • New in v4: Port Flooding Detection – Per IP, per Port connection flooding detection and mitigation to help block DOS attacks

Install PHP-MemCache Module On CentOS 5.0 + RHEL

January 17, 2009 on 3:27 pm | In Apache, Installation, PHP | No Comments

Download

wget http://pecl.php.net/get/memcache-2.1.2.tgz
tar -zxf memcache-2.1.2.tgz
cd memcache-2.1.2

phpize &&
./configure –enable-memcache
make
make install

This should create memcache.so in your extenstion directory (/usr/lib/php/modules)

If it is not done copy the file memcache.so to the default module directory.
locate your php.ini file

php -i| grep php.ini

add the line

———————
extension=memcache.so
———————

Restart Apache

/etc/rc.d/init.d/httpd restart

check the module is working
php -i| grep memcache.

should show something like

=============
memcache
memcache support => enabled
memcache.allow_failover => 1 => 1
memcache.chunk_size => 8192 => 8192
memcache.default_port => 11211 => 11211
memcache.max_failover_attempts => 20 => 20
Registered save handlers => files user memcache
OLDPWD => /usr/local/src/ezsmsupport/memcache-2.1.2
=============

Also, you can find it in your phpinfo page.
Thats all.

/usr/java/jdkX.X.X_Xbin/java: not found + Install Java on Linux servers

October 19, 2008 on 8:20 pm | In Apache, Centos, Cpanel, Installation, Linux | No Comments

In some cases, the 3rd parts scripts in server requires java to be installed. It may not work properly if the binary of java installed in the server. You need to install JavaSDK

So we present here the installation of Java in Linux server.

Its as easy as you run upcp in a Cpanel server.

Download the installation binary from Sun’s Java site

J2SE for Linux http://java.sun.com/j2se/1.4.2/download.html.( Download J2SE SDK)

You may need to register at the site and then they will send you the download link. Download the non-rpm binary

cd /usr/local/src/

wget thebinary

mv j2sdk-1_4_2_18-linux-i586.bin /usr/local/

cd /usr/local/

chmod 755 j2sdk-1_4_2_18-linux-i586.bin

./j2sdk-1_4_2_18-linux-i586.bin

Now setup the environment variables.

JAVA_HOME=/usr/local/j2sdk1.4.2_18

export JAVA_HOME

Also, you need to add these in the file /etc/profile.

JAVA_HOME=/usr/local/j2sdk1.4.2_18

export JAVA_HOME

Ioncube Installation

October 19, 2008 on 7:59 pm | In Cpanel, Installation, PHP | No Comments

Ioncube is easy to install without recompiling PHP. Specifically in cpanel servers you can install Ioncube without recompiling PHP.

These steps can be used to install in any Linux servers..

Check the architecture.

uname -i

cat /etc/redhat-release

Download the source from the link

http://downloads2.ioncube.com/loader_downloads/

For i316 architecture linux server select

ioncube_loaders_lin_x86.tar.gz

2. Installation

cd /usr/local/src/

wget http://downloads2.ioncube.com/loader_downloads/<source>.tar.gz

tar zxvff <source>.tar.gz

mv ioncube /usr/local

Locate you php.ini file using the command

php -i | grep php.ini

open up the php.ini file using any editors, find the “zend_extension” and add the line

zend_extension=/usr/local/ioncube/ioncube_loader_lin_x.x.so

Don’t forget to replace x.x with the php verision. For example you have php version 5.2.6, replace the x.x with 5.2.

Restart Apache

/etc/rc.d/init.d/httpd restart

Test it

php -v

It should show Ioncube.

How to install Python in linux server

April 29, 2008 on 2:38 pm | In Installation, Python | No Comments

Easy…..

cd /usr/local/src
wget http://www.python.org/ftp/python/2.5/Python-2.5.tgz
tar -zxvf Python-2.5.tgz
make
make install

How to install Mod_Python in Linux server

April 29, 2008 on 2:35 pm | In Installation, Python | 2 Comments

Both instruction for Apache 1.x and Apache 2.x are given below.

First, you need to check what version of Python you are running.

python -V

If you are running Apache 1.3.x, you should use mod_python version 2.7.11 and for Apache 2.2.x, use 3.3.1.

Python with version 2.1.x greater than are only supported
latest is to use Python2.5.5

The step are for Apache 1.3.x. However, for Apache 2.1.x download mod_python 3.3.1 and follow the same steps

cd /usr/local/src
wget http://www.trieuvan.com/apache/httpd/modpython/mod_python-2.7.11.tgz
tar -xvzf mod_python-2.7.11.tgz
cd mod_python-2.7.11

./configure –with-apxs=/usr/local/apache/bin/apxs –with-python=/usr/local/bin/python

The –with-python path should reflect the location of the python binary

If you are on Apache 1.3, follow the steps below. If not, go for make and make install.

vi src/Makefile
Locate the ‘CFLAGS’ line, and add the -DEAPI switch so it looks like this:
CFLAGS=$(OPT) $(INCLUDES) -DEAPI

Then add -lutil to the LIBS line like so:
LIBS=-lm /usr/local/src/Python-2.5.1/libpython2.5.a -lutil

Run the make and make install.

This should be done. for both Apache versions.

Edit httpd.conf and create your handlers.

Apache 1.3.x
LoadModule python_module libexec/mod_python.so
AddModule mod_python.c
AddHandler mod_python .psp .py

Apache 2.1.x
LoadModule python_module modules/mod_python.so
AddHandler mod_python .psp .py

How to install docutils in Linux server

April 29, 2008 on 1:50 pm | In Installation, Python | No Comments

Download manually the docutils tar gz from http://prdownloads.sourceforge.net/docutils/docutils-0.4.tar.gz?download

cd /usr/local/src/
wget http://prdownloads.sourceforge.net/docutils/docutils-0.4.tar.gz?download

sudo easy_install /pathto/docutils-0.4.tar.gz

:)

How to install Python Imaging Library PIL on Linux server

April 29, 2008 on 1:47 pm | In Installation, Python | No Comments

Python Imaging Library (PIL)

Make sure Python is installed.

Prerequisites.

If you need any of the features described below, make sure you
have the necessary libraries before building PIL.

feature library
—————————————————————–
JPEG support libjpeg (6a or 6b)

http://www.ijg.org

http://www.ijg.org/files/jpegsrc.v6b.tar.gz

ftp://ftp.uu.net/graphics/jpeg/

PNG support zlib (1.1.4 or later is recommended)

http://www.gzip.org/zlib/

OpenType/TrueType freetype2 (2.1.3 or later is recommended)
support

http://www.freetype.org

http://freetype.sourceforge.net

Installation

Make sure Python is installed.

Then go for

wget http://effbot.org/downloads/Imaging-1.1.6.tar.gz
tar -zxf Imaging-1.1.6.tar.gz
cd Imaging-1.1.6/

python setup.py install

Thant’s all

jmorecfg.h

April 26, 2008 on 3:06 pm | In Installation, PHP | No Comments

If this header file is not found when you give make for gd installation download it

===================
wget http://www.ece.cmu.edu/~ece796/project99/7/final/code/jmorecfg.h

mv jmorecfg.h /usr/lib/
===================

===================
updatedb
===================
or
===================
ldconfig
===================

jpeglib.h

April 26, 2008 on 3:04 pm | In Installation, PHP | No Comments

If this header file is not found when you give make for gd installation download it

===================
wget http://dev.w3.org/cvsweb/Amaya/libjpeg/jpeglib.h?rev=1.2

mv jpeglib.h?rev=1.2 /usr/lib/
===================

===================
updatedb
===================
or
===================
ldconfig
===================

Next Page »