How to Deny ICMP Ping Request on CentOS 6.2

Ping is a computer network administration utility used to test the reachability of a host on an Internet Protocol (IP) network. Ping operates by sending Internet Control Message Protocol (ICMP) echo request packets to the target host and waiting for an ICMP response. ICMP protocol is used by ping command to check the connectivity between two computers. By defaults all Linux CentOS servers will response on ICMP request. Hacker can misuse this service. They can generate countless ping requests to your Linux server. This is what called DOS denial of services.

Before changes, i can ping 192.168.1.44 as below :

D:\>ping 192.168.1.44

Pinging 192.168.1.44 with 32 bytes of data:

Reply from 192.168.1.44: bytes=32 time=1ms TTL=64
Reply from 192.168.1.44: bytes=32 time=1ms TTL=64
Reply from 192.168.1.44: bytes=32 time=2ms TTL=64
Reply from 192.168.1.44: bytes=32 time=1ms TTL=64

Ping statistics for 192.168.1.44:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 1ms, Maximum = 2ms, Average = 1ms

In this post, i will show on how to block ICMP ping request from others.

Method 1 :
To disable ICMP ping immediately, type the following command :

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

Method 2 :
To disable ICMP ping after reboot, modify the /etc/sysctl.conf as below. This will permanently disable the ICMP ping echo. Kindly append at the end line of the file :

[root@centos62 ~]# vi /etc/sysctl.conf
..
..
..
# Controls the maximum size of a message, in bytes
kernel.msgmnb = 65536

# Controls the default maxmimum size of a mesage queue
kernel.msgmax = 65536

# Controls the maximum shared segment size, in bytes
kernel.shmmax = 4294967295

# Controls the maximum number of shared memory segments, in pages
kernel.shmall = 268435456

net.ipv4.icmp_echo_ignore_all = 1

Change will take effect after reboot :

[root@centos62 ~]# reboot

Try to ping again. The server will not reply now :

D:\>ping 192.168.1.44

Pinging 192.168.1.44 with 32 bytes of data:

Request timed out.
Request timed out.
Request timed out.
Request timed out.

Ping statistics for 192.168.1.44:
    Packets: Sent = 4, Received = 0, Lost = 4 (100% loss),

How to Install php-mcrypt on CentOS 6.2

Symptoms :
This error appeared when i try to use phpmyadmin on authentication type as cookie. mcrypt is necessary if you want to use cookie based authentication with phpymyadmin.

The mcrypt exension is missing. Please check your PHP configuration.

mcrypt

To install php-mcrypt on CentOS 6.2, follow the following steps :

1. Download epel repository :

[root@centos62 ~]# [root@centos62 ~]# wget http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-5.noarch.rpm
[root@centos62 ~]# wget http://ftp.riken.jp/Linux/fedora/epel/RPM-GPG-KEY-EPEL-6

2. Install epel repository :

[root@centos62 ~]# rpm --import RPM-GPG-KEY-EPEL-6
[root@centos62 ~]# rpm -i epel-release-6-5.noarch.rpm

3. Simply run the following command to install php-mcrypt :

[root@centos62 ~]# yum install php-mcrypt -y
Loaded plugins: fastestmirror
Determining fastest mirrors
epel/metalink                                                                | 4.0 kB     00:00
 * base: centos.maulvi.net
 * epel: mirror01.idc.hinet.net
 * extras: centos.maulvi.net
 * rpmforge: fr2.rpmfind.net
 * updates: centos.maulvi.net
CentOS6.2-Repository                                                         | 4.0 kB     00:00 ...
CentOS6.2-Repository/primary_db                                              | 3.5 MB     00:00 ...
base                                                                         | 3.7 kB     00:00
base/primary_db                                                              | 3.5 MB     00:33
epel                                                                         | 4.3 kB     00:00
epel/primary_db                                                              | 3.5 MB     00:40
extras                                                                       | 3.5 kB     00:00
extras/primary_db                                                            | 6.4 kB     00:00
rpmforge                                                                     | 1.1 kB     00:00
rpmforge/primary                                                             | 1.5 MB     00:21
rpmforge                                                                                  4248/4248
updates                                                                      | 3.5 kB     00:00
updates/primary_db                                                           | 1.1 MB     00:13
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package php-mcrypt.i686 0:5.3.3-1.el6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

====================================================================================================
 Package                   Arch                Version                    Repository           Size
====================================================================================================
Installing:
 php-mcrypt                i686                5.3.3-1.el6                epel                 18 k

Transaction Summary
====================================================================================================
Install       1 Package(s)

Total download size: 18 k
Installed size: 38 k
Downloading Packages:
php-mcrypt-5.3.3-1.el6.i686.rpm                                              |  18 kB     00:00
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Warning: RPMDB altered outside of yum.
  Installing : php-mcrypt-5.3.3-1.el6.i686                                                      1/1

Installed:
  php-mcrypt.i686 0:5.3.3-1.el6

Complete!

How to Restrict the Access to Specific Web sites Using Squid Proxy Server on CentOS 6.2

This howto covers the steps necessary to restrict the access to specific web sites using Squid Proxy cache server for CentOS 6.2. Before beginning this steps, please make sure you have properly configured the squid proxy server. If not, please follow this article to install squid proxy server on CentOS 6.2 (How to Install and Configure Squid Proxy Server on CentOS 6.2)

Squid has capability to read the containing lists of web sites or domains for use in ACLs. In this example, the setup always restricting access to ehowstuff.com network and Bad_Websites, but allow surfing during surfing_hours group’s only if the sites does not in Bad_Wesites (other that Bad_Websites). Follow this steps to implement restricting access to specific websites.

1. Open the squid.conf configuration file :

    [root@centos62 ~]# vi /etc/squid/squid.conf
    

2. Create web folder under /etc/squid. This is to store any anonymous files such as Bad_Websites.squid.

    [root@centos62 ~]# mkdir /etc/squid/web
    

3.Create Bad_Websites.squid and add the bad websites list.

    [root@centos62 ~]# vi /etc/squid/web/Bad_Websites.squid
    

Example Bad website list :

    #List in /etc/squid/web/Bad_Websites.squid
    www.porn.com
    www.badwebsites.com
    

4. Define surfing_hour group’s name, surfing time and restricted websites file list.

    #Add this at the bottom of the ACL Section
    #
    acl surfing_hours time M T W H F 08:00-17:00
    acl Bad_Websites  dstdomain "/etc/squid/web/Bad_Websites.squid"
    #
    

5. Always restricting access to ehowstuff.com network and Bad_Wesites, but allow surfing during surfing_hours group’s only if the sites does not in Bad_Websites (other that Bad_Websites).

    # Only allow cachemgr access from ehowstuff.com
    http_access allow ehowstuff.com surfing_hours !Bad_Websites
    http_access deny Bad_Websites
    http_access deny ehowstuff.com
    

6. Restart Squid proxy server to take effect :

    [root@centos62 ~]# service squid restart
    Stopping squid: ................                           [  OK  ]
    Starting squid: .                                          [  OK  ]
    

Full Configuration of the Squid Cache Proxy Configuration :

    #
    # Recommended minimum configuration:
    #
    acl manager proto cache_object
    acl localhost src 127.0.0.1/32 ::1
    acl to_localhost dst 127.0.0.0/8 0.0.0.0/32 ::1
    
    # Example rule allowing access from your local networks.
    # Adapt to list your (internal) IP networks from where browsing
    # should be allowed
    acl localnet src 10.0.0.0/8	# RFC1918 possible internal network
    acl localnet src 172.16.0.0/12	# RFC1918 possible internal network
    acl localnet src 192.168.0.0/16	# RFC1918 possible internal network
    acl localnet src fc00::/7       # RFC 4193 local private network range
    acl localnet src fe80::/10      # RFC 4291 link-local (directly plugged) machines
    acl ehowstuff.com src 192.168.1.0/24    # Your internal network
    
    acl SSL_ports port 443
    acl Safe_ports port 80		# http
    acl Safe_ports port 21		# ftp
    acl Safe_ports port 443		# https
    acl Safe_ports port 70		# gopher
    acl Safe_ports port 210		# wais
    acl Safe_ports port 1025-65535	# unregistered ports
    acl Safe_ports port 280		# http-mgmt
    acl Safe_ports port 488		# gss-http
    acl Safe_ports port 591		# filemaker
    acl Safe_ports port 777		# multiling http
    acl CONNECT method CONNECT
    
    #Add this at the bottom of the ACL Section
    #
    acl surfing_hours time M T W H F 08:00-17:00
    acl Bad_Websites  dstdomain "/etc/squid/web/Bad_Websites.squid"
    
    #
    # Recommended minimum Access Permission configuration:
    #
    # Only allow cachemgr access from localhost
    http_access allow manager localhost
    http_access deny manager
    
    # Only allow cachemgr access from ehowstuff.com
    http_access allow ehowstuff.com surfing_hours !Bad_Websites
    http_access deny Bad_Websites
    http_access deny ehowstuff.com
    
    
    
    # Deny requests to certain unsafe ports
    http_access deny !Safe_ports
    
    # Deny CONNECT to other than secure SSL ports
    http_access deny CONNECT !SSL_ports
    
    # We strongly recommend the following be uncommented to protect innocent
    # web applications running on the proxy server who think the only
    # one who can access services on "localhost" is a local user
    #http_access deny to_localhost
    
    #
    # INSERT YOUR OWN RULE(S) HERE TO ALLOW ACCESS FROM YOUR CLIENTS
    #
    
    # Example rule allowing access from your local networks.
    # Adapt localnet in the ACL section to list your (internal) IP networks
    # from where browsing should be allowed
    #http_access allow localnet
    http_access allow localhost
    
    # And finally deny all other access to this proxy
    http_access deny all
    
    # Squid normally listens to port 3128
    http_port 3128
    
    # We recommend you to use at least the following line.
    hierarchy_stoplist cgi-bin ?
    
    # Uncomment and adjust the following to add a disk cache directory.
    #cache_dir ufs /var/spool/squid 100 16 256
    
    # Leave coredumps in the first cache dir
    coredump_dir /var/spool/squid
    
    # Add any of your own refresh_pattern entries above these.
    refresh_pattern ^ftp:		1440	20%	10080
    refresh_pattern ^gopher:	1440	0%	1440
    refresh_pattern -i (/cgi-bin/|\?) 0	0%	0
    refresh_pattern .		0	20%	4320
    

How to Restrict Web Access By Time Using Squid Proxy Server on CentOS 6.2

This howto covers the steps necessary to control internet access by time using Squid Proxy cache server for CentOS 6.2. Before beginning this steps, please make sure you have properly configured the squid proxy server. If not, please follow this article to install squid proxy server on CentOS 6.2 (How to Install and Configure Squid Proxy Server on CentOS 6.2)

1. Open the squid.conf configuration file :

    [root@centos62 ~]# vi /etc/squid/squid.conf
    

2. In this example, the setup just allow surfing_hour’s access from the ehowstuff.com network, while always restricting access to ehowstuff.com network other than surfing hour.

    # Example rule allowing access from your local networks.
    # Adapt to list your (internal) IP networks from where browsing
    # should be allowed
    acl ehowstuff.com src 192.168.1.0/24    # Your ehowstuff.com internal network
    

3. Define surfing_hour group’s name and time.

    #Add this at the bottom of the ACL Section
    #
    acl surfing_hours time M T W H F 08:00-17:00
    #
    

4. Always restricting access to ehowstuff.com, but allow during surfing hours only.

    # Only allow cachemgr access from ehowstuff.com
    http_access allow ehowstuff.com surfing_hours
    http_access deny ehowstuff.com
    

5. Restart Squid proxy server to take effect :

    [root@centos62 ~]# service squid restart
    Stopping squid: ................                           [  OK  ]
    Starting squid: .                                          [  OK  ]
    

Full Configuration of the Squid Cache Proxy Configuration :

    #
    # Recommended minimum configuration:
    #
    acl manager proto cache_object
    acl localhost src 127.0.0.1/32 ::1
    acl to_localhost dst 127.0.0.0/8 0.0.0.0/32 ::1
    
    # Example rule allowing access from your local networks.
    # Adapt to list your (internal) IP networks from where browsing
    # should be allowed
    acl localnet src 10.0.0.0/8	# RFC1918 possible internal network
    acl localnet src 172.16.0.0/12	# RFC1918 possible internal network
    acl localnet src 192.168.0.0/16	# RFC1918 possible internal network
    acl localnet src fc00::/7       # RFC 4193 local private network range
    acl localnet src fe80::/10      # RFC 4291 link-local (directly plugged) machines
    acl ehowstuff.com src 192.168.1.0/24    # Your ehowstuff.com internal network
    
    acl SSL_ports port 443
    acl Safe_ports port 80		# http
    acl Safe_ports port 21		# ftp
    acl Safe_ports port 443		# https
    acl Safe_ports port 70		# gopher
    acl Safe_ports port 210		# wais
    acl Safe_ports port 1025-65535	# unregistered ports
    acl Safe_ports port 280		# http-mgmt
    acl Safe_ports port 488		# gss-http
    acl Safe_ports port 591		# filemaker
    acl Safe_ports port 777		# multiling http
    acl CONNECT method CONNECT
    
    #Add this at the bottom of the ACL Section
    #
    acl surfing_hours time M T W H F 08:00-17:00
    #
    # Recommended minimum Access Permission configuration:
    #
    # Only allow cachemgr access from localhost
    http_access allow manager localhost
    http_access deny manager
    
    # Only allow cachemgr access from ehowstuff.com
    http_access allow ehowstuff.com surfing_hours
    http_access deny ehowstuff.com
    
    
    
    # Deny requests to certain unsafe ports
    http_access deny !Safe_ports
    
    # Deny CONNECT to other than secure SSL ports
    http_access deny CONNECT !SSL_ports
    
    # We strongly recommend the following be uncommented to protect innocent
    # web applications running on the proxy server who think the only
    # one who can access services on "localhost" is a local user
    #http_access deny to_localhost
    
    #
    # INSERT YOUR OWN RULE(S) HERE TO ALLOW ACCESS FROM YOUR CLIENTS
    #
    
    # Example rule allowing access from your local networks.
    # Adapt localnet in the ACL section to list your (internal) IP networks
    # from where browsing should be allowed
    #http_access allow localnet
    http_access allow localhost
    http_access allow ehowstuff.com
    
    # And finally deny all other access to this proxy
    http_access deny all
    
    # Squid normally listens to port 3128
    http_port 3128
    
    # We recommend you to use at least the following line.
    hierarchy_stoplist cgi-bin ?
    
    # Uncomment and adjust the following to add a disk cache directory.
    #cache_dir ufs /var/spool/squid 100 16 256
    
    # Leave coredumps in the first cache dir
    coredump_dir /var/spool/squid
    
    # Add any of your own refresh_pattern entries above these.
    refresh_pattern ^ftp:		1440	20%	10080
    refresh_pattern ^gopher:	1440	0%	1440
    refresh_pattern -i (/cgi-bin/|\?) 0	0%	0
    refresh_pattern .		0	20%	4320
    

How to Check Hard Disk Size and Hard Disk Usage on CentOS 6.2

In this post, i will share the simple command to check the Hard Disk size and usage on CentOS 6.2. This command is a basic command for linux operating system.

To view and list of the usage of each partition in the server :

    [root@centos62 ~]# df -h
    Filesystem            Size  Used Avail Use% Mounted on
    /dev/mapper/vg_centos62-lv_root
                           13G  1.8G   10G  15% /
    tmpfs                 504M     0  504M   0% /dev/shm
    /dev/sda1             485M   48M  412M  11% /boot
    

df command will displays the total, used, and available free space on all currently mounted filesystems.

To list the size of a specific directory, run the following command :

    [root@centos62 ~]# du -sh /root
    2.6M    /root
    

du command reports disk usage. It will shows the disk space used by the files and directories in a directory. The -h option makes the output easier to read by user.

How to Install and Configure Samba Server on CentOS 6.2

In this post, i will show you on how to install samba service on CentOS 6.2. This post assumed that you have configure local yum repository.

    [root@centos62 ~]# yum install samba
    Loaded plugins: fastestmirror
    Loading mirror speeds from cached hostfile
     * base: centos.maulvi.net
     * extras: centos.maulvi.net
     * updates: centos.maulvi.net
    Setting up Install Process
    Resolving Dependencies
    --> Running transaction check
    ---> Package samba.i686 0:3.5.10-114.el6 will be installed
    --> Processing Dependency: samba-winbind-clients = 3.5.10-114.el6 for package: samba-3.5.10-114.el6.i686
    --> Processing Dependency: samba-common = 3.5.10-114.el6 for package: samba-3.5.10-114.el6.i686
    --> Processing Dependency: libtdb.so.1 for package: samba-3.5.10-114.el6.i686
    --> Processing Dependency: libcups.so.2 for package: samba-3.5.10-114.el6.i686
    --> Processing Dependency: libwbclient.so.0 for package: samba-3.5.10-114.el6.i686
    --> Processing Dependency: libtalloc.so.2 for package: samba-3.5.10-114.el6.i686
    --> Running transaction check
    ---> Package cups-libs.i686 1:1.4.2-44.el6 will be installed
    --> Processing Dependency: libavahi-client.so.3 for package: 1:cups-libs-1.4.2-44.el6.i686
    --> Processing Dependency: libtiff.so.3 for package: 1:cups-libs-1.4.2-44.el6.i686
    --> Processing Dependency: libjpeg.so.62 for package: 1:cups-libs-1.4.2-44.el6.i686
    --> Processing Dependency: libavahi-common.so.3 for package: 1:cups-libs-1.4.2-44.el6.i686
    --> Processing Dependency: libpng12.so.0(PNG12_0) for package: 1:cups-libs-1.4.2-44.el6.i686
    --> Processing Dependency: libpng12.so.0 for package: 1:cups-libs-1.4.2-44.el6.i686
    ---> Package libtalloc.i686 0:2.0.1-1.1.el6 will be installed
    ---> Package libtdb.i686 0:1.2.1-3.el6 will be installed
    ---> Package samba-common.i686 0:3.5.10-114.el6 will be installed
    --> Processing Dependency: /usr/bin/pkg-config for package: samba-common-3.5.10-114.el6.i686
    ---> Package samba-winbind-clients.i686 0:3.5.10-114.el6 will be installed
    --> Running transaction check
    ---> Package avahi-libs.i686 0:0.6.25-11.el6 will be installed
    ---> Package libjpeg.i686 0:6b-46.el6 will be installed
    ---> Package libpng.i686 2:1.2.46-1.el6_1 will be installed
    ---> Package libtiff.i686 0:3.9.4-1.el6_0.3 will be installed
    ---> Package pkgconfig.i686 1:0.23-9.1.el6 will be installed
    --> Finished Dependency Resolution
    
    Dependencies Resolved
    
    ====================================================================================================
     Package                      Arch        Version                 Repository                   Size
    ====================================================================================================
    Installing:
     samba                        i686        3.5.10-114.el6          CentOS6.2-Repository        5.0 M
    Installing for dependencies:
     avahi-libs                   i686        0.6.25-11.el6           CentOS6.2-Repository         54 k
     cups-libs                    i686        1:1.4.2-44.el6          CentOS6.2-Repository        324 k
     libjpeg                      i686        6b-46.el6               CentOS6.2-Repository        133 k
     libpng                       i686        2:1.2.46-1.el6_1        CentOS6.2-Repository        184 k
     libtalloc                    i686        2.0.1-1.1.el6           CentOS6.2-Repository         18 k
     libtdb                       i686        1.2.1-3.el6             CentOS6.2-Repository         29 k
     libtiff                      i686        3.9.4-1.el6_0.3         CentOS6.2-Repository        338 k
     pkgconfig                    i686        1:0.23-9.1.el6          CentOS6.2-Repository         67 k
     samba-common                 i686        3.5.10-114.el6          CentOS6.2-Repository         13 M
     samba-winbind-clients        i686        3.5.10-114.el6          CentOS6.2-Repository        1.1 M
    
    Transaction Summary
    ====================================================================================================
    Install      11 Package(s)
    
    Total download size: 20 M
    Installed size: 70 M
    Is this ok [y/N]: y
    Downloading Packages:
    ----------------------------------------------------------------------------------------------------
    Total                                                                10 MB/s |  20 MB     00:02
    Running rpm_check_debug
    Running Transaction Test
    Transaction Test Succeeded
    Running Transaction
      Installing : libtalloc-2.0.1-1.1.el6.i686                                                    1/11
      Installing : libtdb-1.2.1-3.el6.i686                                                         2/11
      Installing : samba-winbind-clients-3.5.10-114.el6.i686                                       3/11
      Installing : libjpeg-6b-46.el6.i686                                                          4/11
      Installing : libtiff-3.9.4-1.el6_0.3.i686                                                    5/11
      Installing : 2:libpng-1.2.46-1.el6_1.i686                                                    6/11
      Installing : 1:pkgconfig-0.23-9.1.el6.i686                                                   7/11
      Installing : samba-common-3.5.10-114.el6.i686                                                8/11
      Installing : avahi-libs-0.6.25-11.el6.i686                                                   9/11
      Installing : 1:cups-libs-1.4.2-44.el6.i686                                                  10/11
      Installing : samba-3.5.10-114.el6.i686                                                      11/11
    
    Installed:
      samba.i686 0:3.5.10-114.el6
    
    Dependency Installed:
      avahi-libs.i686 0:0.6.25-11.el6              cups-libs.i686 1:1.4.2-44.el6
      libjpeg.i686 0:6b-46.el6                     libpng.i686 2:1.2.46-1.el6_1
      libtalloc.i686 0:2.0.1-1.1.el6               libtdb.i686 0:1.2.1-3.el6
      libtiff.i686 0:3.9.4-1.el6_0.3               pkgconfig.i686 1:0.23-9.1.el6
      samba-common.i686 0:3.5.10-114.el6           samba-winbind-clients.i686 0:3.5.10-114.el6
    
    Complete!
    

Set Samba auto after boot up :

    [root@centos62 ~]# chkconfig smb on
    

Start samba service :

    [root@centos62 ~]# service smb start
    Starting SMB services:                                     [  OK  ]
    

How to Install and Configure Squid Proxy Server on CentOS 6.2

This howto will show you the steps to install and configure a Squid 3 Proxy Server on CentOS6.2. Squid service plays two main roles which mainly act as a caching proxy server between the user and the web. Second role, squid also regularly used as a content accelerator, or reverse proxy, intercepting requests to a server and using a cached version of the page to serve the request. Follow below steps to install and configure squid.

1. Install Squid proxy using yum command. This installation is performed using local yum repository as documented in this article. (How to Setup Local Yum Repository from CD-ROM/DVD-ROM image on CentOS 6.2)

    [root@centos62 ~]# yum install squid -y
    Loaded plugins: fastestmirror
    Loading mirror speeds from cached hostfile
     * base: centos.maulvi.net
     * extras: centos.maulvi.net
     * updates: centos.maulvi.net
    Setting up Install Process
    Resolving Dependencies
    --> Running transaction check
    ---> Package squid.i686 7:3.1.10-1.el6_2.1 will be installed
    --> Processing Dependency: perl(Getopt::Long) for package: 7:squid-3.1.10-1.el6_2.1.i686
    --> Processing Dependency: perl(integer) for package: 7:squid-3.1.10-1.el6_2.1.i686
    --> Processing Dependency: perl(Pod::Usage) for package: 7:squid-3.1.10-1.el6_2.1.i686
    --> Processing Dependency: perl(DBI) for package: 7:squid-3.1.10-1.el6_2.1.i686
    --> Processing Dependency: perl(Digest::MD5) for package: 7:squid-3.1.10-1.el6_2.1.i686
    --> Processing Dependency: perl(vars) for package: 7:squid-3.1.10-1.el6_2.1.i686
    --> Processing Dependency: libltdl.so.7 for package: 7:squid-3.1.10-1.el6_2.1.i686
    --> Processing Dependency: perl(strict) for package: 7:squid-3.1.10-1.el6_2.1.i686
    --> Processing Dependency: /usr/bin/perl for package: 7:squid-3.1.10-1.el6_2.1.i686
    --> Processing Dependency: perl(Getopt::Std) for package: 7:squid-3.1.10-1.el6_2.1.i686
    --> Processing Dependency: perl(Net::POP3) for package: 7:squid-3.1.10-1.el6_2.1.i686
    --> Running transaction check
    ---> Package libtool-ltdl.i686 0:2.2.6-15.5.el6 will be installed
    ---> Package perl.i686 4:5.10.1-119.el6_1.1 will be installed
    --> Processing Dependency: perl-libs = 4:5.10.1-119.el6_1.1 for package: 4:perl-5.10.1-119.el6_1.1.i686
    --> Processing Dependency: perl-libs for package: 4:perl-5.10.1-119.el6_1.1.i686
    --> Processing Dependency: perl(Pod::Simple) for package: 4:perl-5.10.1-119.el6_1.1.i686
    --> Processing Dependency: libperl.so for package: 4:perl-5.10.1-119.el6_1.1.i686
    --> Processing Dependency: perl(version) for package: 4:perl-5.10.1-119.el6_1.1.i686
    --> Processing Dependency: perl(Module::Pluggable) for package: 4:perl-5.10.1-119.el6_1.1.i686
    ---> Package perl-DBI.i686 0:1.609-4.el6 will be installed
    --> Running transaction check
    ---> Package perl-Module-Pluggable.i686 1:3.90-119.el6_1.1 will be installed
    ---> Package perl-Pod-Simple.i686 1:3.13-119.el6_1.1 will be installed
    --> Processing Dependency: perl(Pod::Escapes) >= 1.04 for package: 1:perl-Pod-Simple-3.13-119.el6_1.1.i686
    ---> Package perl-libs.i686 4:5.10.1-119.el6_1.1 will be installed
    ---> Package perl-version.i686 3:0.77-119.el6_1.1 will be installed
    --> Running transaction check
    ---> Package perl-Pod-Escapes.i686 1:1.04-119.el6_1.1 will be installed
    --> Finished Dependency Resolution
    
    Dependencies Resolved
    
    ====================================================================================================
     Package                     Arch       Version                    Repository                  Size
    ====================================================================================================
    Installing:
     squid                       i686       7:3.1.10-1.el6_2.1         updates                    1.7 M
    Installing for dependencies:
     libtool-ltdl                i686       2.2.6-15.5.el6             CentOS6.2-Repository        45 k
     perl                        i686       4:5.10.1-119.el6_1.1       CentOS6.2-Repository       9.7 M
     perl-DBI                    i686       1.609-4.el6                CentOS6.2-Repository       705 k
     perl-Module-Pluggable       i686       1:3.90-119.el6_1.1         CentOS6.2-Repository        37 k
     perl-Pod-Escapes            i686       1:1.04-119.el6_1.1         CentOS6.2-Repository        30 k
     perl-Pod-Simple             i686       1:3.13-119.el6_1.1         CentOS6.2-Repository       209 k
     perl-libs                   i686       4:5.10.1-119.el6_1.1       CentOS6.2-Repository       590 k
     perl-version                i686       3:0.77-119.el6_1.1         CentOS6.2-Repository        49 k
    
    Transaction Summary
    ====================================================================================================
    Install       9 Package(s)
    
    Total download size: 13 M
    Installed size: 38 M
    Downloading Packages:
    (1/9): squid-3.1.10-1.el6_2.1.i686.rpm                                       | 1.7 MB     00:14
    ----------------------------------------------------------------------------------------------------
    Total                                                               881 kB/s |  13 MB     00:15
    warning: rpmts_HdrFromFdno: Header V4 RSA/SHA1 Signature, key ID c105b9de: NOKEY
    Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
    Importing GPG key 0xC105B9DE:
     Userid : CentOS-6 Key (CentOS 6 Official Signing Key) 
     Package: centos-release-6-2.el6.centos.7.i686 (@anaconda-CentOS-201112130233.i386/6.2)
     From   : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
    Running rpm_check_debug
    Running Transaction Test
    Transaction Test Succeeded
    Running Transaction
      Installing : 1:perl-Pod-Escapes-1.04-119.el6_1.1.i686                                         1/9
      Installing : 3:perl-version-0.77-119.el6_1.1.i686                                             2/9
      Installing : 4:perl-libs-5.10.1-119.el6_1.1.i686                                              3/9
      Installing : 1:perl-Pod-Simple-3.13-119.el6_1.1.i686                                          4/9
      Installing : 1:perl-Module-Pluggable-3.90-119.el6_1.1.i686                                    5/9
      Installing : 4:perl-5.10.1-119.el6_1.1.i686                                                   6/9
      Installing : perl-DBI-1.609-4.el6.i686                                                        7/9
      Installing : libtool-ltdl-2.2.6-15.5.el6.i686                                                 8/9
      Installing : 7:squid-3.1.10-1.el6_2.1.i686                                                    9/9
    
    Installed:
      squid.i686 7:3.1.10-1.el6_2.1
    
    Dependency Installed:
      libtool-ltdl.i686 0:2.2.6-15.5.el6             perl.i686 4:5.10.1-119.el6_1.1
      perl-DBI.i686 0:1.609-4.el6                    perl-Module-Pluggable.i686 1:3.90-119.el6_1.1
      perl-Pod-Escapes.i686 1:1.04-119.el6_1.1       perl-Pod-Simple.i686 1:3.13-119.el6_1.1
      perl-libs.i686 4:5.10.1-119.el6_1.1            perl-version.i686 3:0.77-119.el6_1.1
    
    Complete!
    

2. Configure server hosts file :

    [root@centos62 ~]# vi /etc/hosts
    
    127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
    ::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
    
    192.168.1.44 centos62.ehowstuff.com
    

3. Configure main squid configuration file. Use vi to edit.

    [root@centos62 ~]# vi /etc/squid/squid.conf
    

4. Add your internal network name into the IP networks list where browsing should be allowed. In this example, your internal network name is ehowstuff.com.

    acl localnet src 10.0.0.0/8     # RFC1918 possible internal network
    acl localnet src 172.16.0.0/12  # RFC1918 possible internal network
    acl localnet src 192.168.0.0/16 # RFC1918 possible internal network
    acl localnet src fc00::/7       # RFC 4193 local private network range
    acl localnet src fe80::/10      # RFC 4291 link-local (directly plugged) machines
    acl ehowstuff.com src 192.168.1.0/24    # Your internal network
    

5. Add ehowstuff.com network in the ACL section list IP networks where browsing should be allowed :

    #http_access allow localnet
    http_access allow localhost
    http_access allow ehowstuff.com
    

6. Make sure squid proxy port is uncomment. You can change the proxy port to any available port here. As an example, other available port is 8080.

    # Squid normally listens to port 3128
    http_port 3128
    

7. Configure auto start at boot for squid service :

    [root@centos62 ~]# chkconfig squid on
    

8. Start squid service :

    [root@centos62 ~]# service squid restart
    Stopping squid: ................                           [  OK  ]
    Starting squid: .                                          [  OK  ]
    

9. Client browser configuration should be as below :

squid

How to Install gcc on CentOS 6.2

In this post, i will show you on how to install gcc package. The GNU Compiler Collection (GCC) is a compiler system produced by the GNU Project supporting various programming languages. The compiler is designed to support multiple front-ends and multiple back-ends by translating first into Register Transfer Language and from there into assembly code for the target architecture. Assume that you have installed minimal installation type CentOS 6.2 and has setup your own local yum repository. You can use internet CentOS yum repository instead if you have direct internet connection to your server.

How to Setup Local Yum Repository from CD-ROM/DVD-ROM image on CentOS 6.2

Simply run yum command to install the gcc.

    [root@centos6 ~]# yum install gcc
    Loaded plugins: fastestmirror
    Loading mirror speeds from cached hostfile
     * base: mirrors.hostemo.com
     * extras: mirrors.hostemo.com
     * updates: mirrors.hostemo.com
    Setting up Install Process
    Resolving Dependencies
    --> Running transaction check
    ---> Package gcc.i686 0:4.4.6-3.el6 will be installed
    --> Finished Dependency Resolution
    
    Dependencies Resolved
    
    ============================================================================================
     Package       Arch           Version                  Repository                      Size
    ============================================================================================
    Installing:
     gcc           i686           4.4.6-3.el6              CentOS6.2-Repository           8.2 M
    
    Transaction Summary
    ============================================================================================
    Install       1 Package(s)
    
    Total download size: 8.2 M
    Installed size: 15 M
    Is this ok [y/N]: y
    Downloading Packages:
    Running rpm_check_debug
    Running Transaction Test
    Transaction Test Succeeded
    Running Transaction
      Installing : gcc-4.4.6-3.el6.i686                                                     1/1
    
    Installed:
      gcc.i686 0:4.4.6-3.el6
    
    Complete!
    

How to Install Httpd on CentOS 6.2

Apache httpd is one of the most popular web servers and has a lot of features that make it very extensible and useful for many different types of websites.This steps has been tested on CentOS 6.2. Assume that you have installed minimal installation type CentOS 6.2 and has setup your own local yum repository. You can use internet CentOS yum repository instead if you have direct internet connection to your server.

How to Setup Local Yum Repository from CD-ROM/DVD-ROM image on CentOS 6.2

    [root@centos6 ~]# yum install httpd
    Loaded plugins: fastestmirror
    Determining fastest mirrors
    CentOS6.2-Repository                                                        | 1.3 kB     00:00 ...
    CentOS6.2-Repository/primary                                                | 1.2 MB     00:00 ...
    CentOS6.2-Repository                                                                     3042/3042
    Setting up Install Process
    Resolving Dependencies
    --> Running transaction check
    ---> Package httpd.i686 0:2.2.15-15.el6.centos will be installed
    --> Processing Dependency: httpd-tools = 2.2.15-15.el6.centos for package: httpd-2.2.15-15.el6.centos.i686
    --> Processing Dependency: libaprutil-1.so.0 for package: httpd-2.2.15-15.el6.centos.i686
    --> Processing Dependency: libapr-1.so.0 for package: httpd-2.2.15-15.el6.centos.i686
    --> Processing Dependency: apr-util-ldap for package: httpd-2.2.15-15.el6.centos.i686
    --> Processing Dependency: /etc/mime.types for package: httpd-2.2.15-15.el6.centos.i686
    --> Running transaction check
    ---> Package apr.i686 0:1.3.9-3.el6_1.2 will be installed
    ---> Package apr-util.i686 0:1.3.9-3.el6_0.1 will be installed
    ---> Package apr-util-ldap.i686 0:1.3.9-3.el6_0.1 will be installed
    ---> Package httpd-tools.i686 0:2.2.15-15.el6.centos will be installed
    ---> Package mailcap.noarch 0:2.1.31-2.el6 will be installed
    --> Finished Dependency Resolution
    
    Dependencies Resolved
    
    ===================================================================================================
     Package              Arch          Version                      Repository                   Size
    ===================================================================================================
    Installing:
     httpd                i686          2.2.15-15.el6.centos         CentOS6.2-Repository        818 k
    Installing for dependencies:
     apr                  i686          1.3.9-3.el6_1.2              CentOS6.2-Repository        129 k
     apr-util             i686          1.3.9-3.el6_0.1              CentOS6.2-Repository         89 k
     apr-util-ldap        i686          1.3.9-3.el6_0.1              CentOS6.2-Repository         15 k
     httpd-tools          i686          2.2.15-15.el6.centos         CentOS6.2-Repository         70 k
     mailcap              noarch        2.1.31-2.el6                 CentOS6.2-Repository         27 k
    
    Transaction Summary
    ===================================================================================================
    Install       6 Package(s)
    
    Total download size: 1.1 M
    Installed size: 3.4 M
    Is this ok [y/N]: y
    Downloading Packages:
    ---------------------------------------------------------------------------------------------------
    Total                                                              3.8 MB/s | 1.1 MB     00:00
    Running rpm_check_debug
    Running Transaction Test
    Transaction Test Succeeded
    Running Transaction
    Warning: RPMDB altered outside of yum.
      Installing : mailcap-2.1.31-2.el6.noarch                                                     1/6
      Installing : apr-1.3.9-3.el6_1.2.i686                                                        2/6
      Installing : apr-util-1.3.9-3.el6_0.1.i686                                                   3/6
      Installing : httpd-tools-2.2.15-15.el6.centos.i686                                           4/6
      Installing : apr-util-ldap-1.3.9-3.el6_0.1.i686                                              5/6
      Installing : httpd-2.2.15-15.el6.centos.i686                                                 6/6
    
    Installed:
      httpd.i686 0:2.2.15-15.el6.centos
    
    Dependency Installed:
      apr.i686 0:1.3.9-3.el6_1.2                     apr-util.i686 0:1.3.9-3.el6_0.1
      apr-util-ldap.i686 0:1.3.9-3.el6_0.1           httpd-tools.i686 0:2.2.15-15.el6.centos
      mailcap.noarch 0:2.1.31-2.el6
    
    Complete!
    

How to Enable Autostart httpd on CentOS 6.2

In this post, i will share on how to enable auto-start for httpd daemon on CentOS 6.2. Assume that your centos server has installed httpd apache service.

    [root@centos6 ~]# chkconfig --level 35 httpd on
    

The chkconfig command with the –level switch indicates that some action needs to be done at the runlevels entered as its values. The first argument in the command is the package you want to affect and the second defines whether you want it on or off. In this case we want httpd service to be started when entering runlevels 3 and 5: If you not specifying the runlevels with the –level switch, chckconfig will make the changes for runlevels 3 and 5 automatically as below :

    [root@centos6 ~]# chkconfig httpd on
    

How to Setup Local Yum Repository from CD-ROM/DVD-ROM image on CentOS 6.2

In this post, i will share on how to update and install the RPM packages from CD-ROM/DVD-ROM image on CentOS 6.2. This will very useful when you are running on slow internet connection. Instead of go through the internet connection, it is possible to use Local CD/DVD-ROM as your yum repository. There are two methods to install and configure local CentOS 6.2 yum repository. Both methods have been tested and working on CentOS 6.2 linux server. You can select any method that you most preferred. This may be also applicable on other version of CentOS server.

Method 1:
1. Insert DVD/ISO into DVD-Drive.
2. Mount the ISO from the DVD-ROM into /mnt directory :

    [root@centos62 ~]# mount /dev/cdrom /mnt
    mount: block device /dev/sr0 is write-protected, mounting read-only
    

3. Create centos62.repo text file in /etc/yum.repos.d/ with the following content. Please create something as follow:

    [root@centos62 ~]# vi /etc/yum.repos.d/centos62.repo
    
    [CentOS6.2-Repository]
    name=DVD-CentOS6.2 repository
    baseurl=file:///mnt
    enabled=1
    gpgcheck=0
    

4. Finish. You can start install, remove and update using yum command :
Example :

    [root@centos62 ~]# yum install httpd -y
    

Method 2 :
1. Check the existing partition on your CentOS 6.2 server

    [root@centos6 ~]# df
    Filesystem           1K-blocks      Used Available Use% Mounted on
    /dev/mapper/VolGroup-lv_root
                          18102140   1165764  16016824   7% /
    tmpfs                   515444         0    515444   0% /dev/shm
    /dev/sda1               495844     29842    440402   7% /boot
    

2. Create localrepo directory in /mnt :

    [root@centos6 ~]# mkdir /mnt/localrepo
    

3. Create 1 2 3 directory in /mnt/localrepo

    [root@centos6 ~]# mkdir -p /mnt/localrepo/{1,2,3}
    

4. Mount the ISO from the DVDROM into /mnt/localrepo/1 directory

    [root@centos6 ~]# mount -o loop /dev/cdrom /mnt/localrepo/1
    
    [root@centos6 ~]# df -lh
    Filesystem            Size  Used Avail Use% Mounted on
    /dev/mapper/VolGroup-lv_root
                           18G  1.2G   16G   7% /
    tmpfs                 504M     0  504M   0% /dev/shm
    /dev/sda1             485M   30M  431M   7% /boot
    /dev/sr0              3.6G  3.6G     0 100% /mnt/localrepo/1
    

5. Create Temporary repo folder under /tmp to put required rpm’s packages for createrepo installation.

    [root@centos6 ~]# mkdir /tmp/repo
    

6. Copy the require pacckages to install create repo:

    [root@centos6 ~]# cp /mnt/localrepo/1/Packages/createrepo* /tmp/repo
    [root@centos6 ~]# cp /mnt/localrepo/1/Packages/deltarpm* /tmp/repo
    [root@centos6 ~]# cp /mnt/localrepo/1/Packages/libxml2-python* /tmp/repo
    [root@centos6 ~]# cp /mnt/localrepo/1/Packages/python-deltarpm* /tmp/repo
    [root@centos6 ~]# ls /tmp/repo
    createrepo-0.9.8-4.el6.noarch.rpm          libxml2-python-2.7.6-4.el6.i686.rpm
    deltarpm-3.5-0.5.20090913git.el6.i686.rpm  python-deltarpm-3.5-0.5.20090913git.el6.i686.rpm
    

7. Install the rpm packages using below command:

    [root@centos6 ~]# rpm -ivh /tmp/repo/*
    Preparing...                ########################################### [100%]
       1:deltarpm               ########################################### [ 25%]
       2:python-deltarpm        ########################################### [ 50%]
       3:libxml2-python         ########################################### [ 75%]
       4:createrepo             ########################################### [100%]
    

8. Go to /mnt/localrepo directory.

    [root@centos6 ~]# cd /mnt/localrepo/
    

9. Run createrepo command :

    [root@centos6 localrepo]# createrepo .
    2704/3042 - 1/Packages/system-config-users-docs-1.0.8-1.el6.noarch.rpm
    iso-8859-1 encoding on Ville Skyttä  - 2.8.2-2
    
    3042/3042 - 1/Packages/zsh-4.3.10-4.1.el6.i686.rpm
    Saving Primary metadata
    Saving file lists metadata
    Saving other metadata
    [root@centos6 localrepo]# ls
    1  2  3  repodata
    

10. Clean up the repo :

    [root@centos6 ~]# yum clean all
    Loaded plugins: fastestmirror
    Cleaning up Everything
    Cleaning up list of fastest mirrors
    

11. Create a repo config file in /etc/yum.repos.d/ directory :

    [root@centos6 ~]# vi /etc/yum.repos.d/local.repo
    
    [CentOS6.2-Repository]
    name=CentOS6.2 repository
    baseurl=file:///mnt/localrepo
    enabled=1
    gpgcheck=0
    

How to Install Webmin 1.570-1 on CentOS 6.2 using RPM

In this post, i will share you on how to install Webmin, a web-based interface for system administration for Linux, on CentOS 6.2. Assumed that you have root access and understand the basic usage of the webmin software.

1. Download Webmin:

    [root@centos6 ~]# wget http://prdownloads.sourceforge.net/webadmin/webmin-1.570-1.noarch.rpm
    --2012-01-07 05:28:08--  http://prdownloads.sourceforge.net/webadmin/webmin-1.570-1.noarch.rpm
    Resolving prdownloads.sourceforge.net... 216.34.181.59
    Connecting to prdownloads.sourceforge.net|216.34.181.59|:80... connected.
    HTTP request sent, awaiting response... 301 Moved Permanently
    Location: http://downloads.sourceforge.net/project/webadmin/webmin/1.570/webmin-1.570-1.noarch.rpm [following]
    --2012-01-07 05:28:09--  http://downloads.sourceforge.net/project/webadmin/webmin/1.570/webmin-1.570-1.noarch.rpm
    Resolving downloads.sourceforge.net... 216.34.181.59
    Reusing existing connection to prdownloads.sourceforge.net:80.
    HTTP request sent, awaiting response... 302 Found
    Location: http://cdnetworks-kr-2.dl.sourceforge.net/project/webadmin/webmin/1.570/webmin-1.570-1.noarch.rpm [following]
    --2012-01-07 05:28:09--  http://cdnetworks-kr-2.dl.sourceforge.net/project/webadmin/webmin/1.570/webmin-1.570-1.noarch.rpm
    Resolving cdnetworks-kr-2.dl.sourceforge.net... 211.39.135.163
    Connecting to cdnetworks-kr-2.dl.sourceforge.net|211.39.135.163|:80... connected.
    HTTP request sent, awaiting response... 200 OK
    Length: 16358730 (16M) [application/x-rpm]
    Saving to: âwebmin-1.570-1.noarch.rpmâ
    
    100%[======================================================>] 16,358,730  16.8K/s   in 15m 45s
    
    2012-01-07 05:43:55 (16.9 KB/s) - âwebmin-1.570-1.noarch.rpmâ
    

2. Add the GPG Key:

    [root@centos6 ~]# rpm --import http://www.webmin.com/jcameron-key.asc
    

3. Install webmin :

    [root@centos6 ~]# rpm -U webmin-1.570-1.noarch.rpm
    Operating system is CentOS Linux
    Webmin install complete. You can now login to http://youripaddress:10000/
    as root with your root password.
    

4. Start webmin service :

    [root@centos6 ~]# service webmin start
    

or

    [root@centos6 ~]# /etc/init.d/webmin start
    

5. Make webmin auto start after reboot the centOS server:

    [root@centos6 ~]# chkconfig webmin on
    [root@centos6 ~]# chkconfig --list
    webmin          0:off   1:off   2:on    3:on    4:on    5:on    6:off
    

6. Login the webmin web interface :

http://youripaddress:10000