Monday, March 22, 2010

How to mount remote windows partition

How to mount remote windows partition (windows share) under Linux

Use the mount command to mount remote windows partition or windows share under Linux as follows:

Procedure to mount remote windows partition (NAS share)

1) Make sure you have following information:
==> Windows username and password to access share name
==> Sharename (such as //server/share) or IP address
==> root level access on Linux

2) Login to Linux as a root user (or use su command)

3) Create the required mount point:
# mkdir -p /mnt/ntserver
4) Use the mount command as follows:
# mount -t cifs //ntserver/download -o username=vivek,password=myPassword /mnt/ntserver

Use following command if you are using Old version such as RHEL <=4 or Debian <= 3:
# mount -t smbfs -o username=vivek,password=D1W4x9sw //ntserver/download /mnt/ntserver

5) Access Windows 2003/2000/NT share using cd and ls command:
# cd /mnt/ntserver; ls -l

Wednesday, March 17, 2010

Open rar file in linux

$ cd /tmp
$ wget http://www.rarlab.com/rar/rarlinux-3.6.0.tar.gz

Untar file
$ tar -zxvf rarlinux-3.6.0.tar.gz

Both unrar and rar commands are located in rar sub-directory. Just go to rar directory:
$ cd rar
$ ./unrar

Now copy rar and unrar to /bin directory:
# cp rar unrar /bin

How to use unrar

unrar command supports various options below are common options that you need to use everyday.

Task: To open rar (unpack) file in current directory type command:

$ unrar e file.rar

Please note that replace file.rar filename with your actual filename.

Task: List (l) file inside rar archive:

$ unrar l file.rar

Task: To extract (x) files with full path type command:

$ unrar x file.rar

(D) To test (t) integrity of archive, file type command:
$ unrar t file.rar

Tuesday, March 16, 2010

cPanel Installation on CentOS

Server Install: CentOS 5.3 and cPanel
------------------------------------------------------------


* Your server’s IP address must be authorized to install cPanel. This can be done when purchasing your license.
* This post does not cover the CentOS installation. I hope to write on this in the future.
* Important: I’m assuming you have a fresh/clean install of CentOS 5.3. cPanel requires that you have no other software installed. If you have installed other software, there is a good chance the install may fail.
* There are many ways to configure a server. This is how I do it. I offer no guarantees that this will work for you.

Let’s begin.
Login As Root

Log into your machine using SSH. Use the ’su’ command to become the root user. You will be prompted for a password.

su
Password: [enter password]

Set Hostname

Open the file /etc/sysconfig/network and change the HOSTNAME= value to mach your Fully Qualified Domain Name (FQDN) host name.

nano /etc/sysconfig/network

HOSTNAME=hostname.domain.com

Change the host associated with your main private IP address in your /etc/hosts file.

nano /etc/hosts

127.0.0.1 localhost
192.168.x.x hostname.domain.com hostname

Finally, run the hostname command, replacing hostname.domain.com with your FQDN.

hostname hostname.domain.com

Update Yum Repositories

Let’s update our YUM packages.

yum update

Press ‘y’ to continue.
Install Perl

Perl needs to be installed. Let’s install that now.

yum install perl

Download cPanel Installation Files

cd ~
wget http://layer1.cpanel.net/latest

Begin cPanel Installation

Let’s now start the installation. This may take several hours to complete. Maybe a good time to see that movie at the theater you’ve been itching to.

sh latest

Logging In

Once completed, you should see:

cPanel Layer 2 Install Complete

Now you can login to your cPanel.

Visiting http://[your_ip_address]:2086 or https://[your_ip_address]:2087 should bring up a login prompt.

Enter root for the user ID and your root password.
Complete cPanel Installation

You should see the cPanel interface now. Go through these steps. Basic networking knowledge is needed to complete this.

Once you’re finished, you have successfully installed cPanel on CentOS Server! Congrats! The last thing is to secure your machine. We will use the iptables firewall in CentOS for this.

Securing CentOS

There are many many ways to secure your server. The important thing is to secure it using something. This is the configuration I used. You may want to add or remove entries as needed. These commands will setup a firewall using iptables and will allow basic service ports to be accessed. I suggest you read up on iptables to gain a better understanding first.

Let’s make sure iptables is installed:

yum install iptables

Enter the commands below to build your firewall:

/sbin/iptables -A INPUT -i lo -j ACCEPT
/sbin/iptables -A INPUT -i ! lo -d 127.0.0.0/8 -j REJECT
/sbin/iptables -A INPUT -m state –state ESTABLISHED,RELATED -j ACCEPT
/sbin/iptables -A OUTPUT -j ACCEPT
/sbin/iptables -A INPUT -p tcp –dport 80 -j ACCEPT
/sbin/iptables -A INPUT -p tcp –dport 443 -j ACCEPT
/sbin/iptables -A INPUT -p tcp –dport 110 -j ACCEPT
/sbin/iptables -A INPUT -p tcp –dport 25 -j ACCEPT
/sbin/iptables -A INPUT -p tcp –dport 2082 -j ACCEPT
/sbin/iptables -A INPUT -p tcp –dport 2083 -j ACCEPT
/sbin/iptables -A INPUT -p tcp –dport 2086 -j ACCEPT
/sbin/iptables -A INPUT -p tcp –dport 2087 -j ACCEPT
/sbin/iptables -A INPUT -p tcp –dport 2089 -j ACCEPT
/sbin/iptables -A INPUT -p tcp –dport 2095 -j ACCEPT
/sbin/iptables -A INPUT -p tcp –dport 2096 -j ACCEPT
/sbin/iptables -A INPUT -p tcp -m state –state NEW –dport 22 -j ACCEPT
/sbin/iptables -A INPUT -p icmp -m icmp –icmp-type 8 -j ACCEPT
/sbin/iptables -A INPUT -j REJECT
/sbin/iptables -A FORWARD -j REJECT

What did we just do?

You restricted all incoming traffic to the following ports/services:

* Port 80 – HTTP
* Port 443 – HTTPS
* Port 110 – POP3
* Port 25 – SMTP
* Port 2082 – cPanel
* Port 2083 – cPanel
* Port 2086 – cPanel
* Port 2087 – cPanel
* Port 2089 – cPanel Licensing
* Port 2095 – Webmail
* Port 2096 – Webmail (Secure)
* Port 22 – SSH
* ICMP – Ability to ping server

You can read more on the ports that cPanel uses at http://www.cpanel.net/2007/06/getting-the-most-out-of-your-systems-firewall.html.

If you need to start over, use this command to remove the current iptables:

/sbin/iptables -F

After you are done, save your iptables. If you do not, you will lose your firewall settings on reboot:

/sbin/service iptables save

You’re Done

Admittedly, I am no cPanel expert; however, if you run into difficulty, let me know. I will do my best to help. As always, I would love to hear feedback. Happy installing everyone

Thursday, March 11, 2010

Iptables in Linux
--------------------


Blocking specific port through iptables
------------------------------------------
#iptables -A INPUT -p tcp -s 192.168.1.102(e.g-outsider pc) -d 192.168.1.114(e.g-configured iptables pc)--dport 80 -j DROP



Blocking ICMP
--------------
#iptables -A INPUT -p icmp --icmp-type echo-request -j DROP

OR

#iptables -A OUTPUT -p icmp --icmp-type 8 -j DROP


saveing the rule
-------------------
service iptables save
service iptables restart
chkconfig iptables on

vim /etc/sysconfig/iptables

iptables -L (listing the rule )
iptables -F (flush the rule)

NAT configure
-----------------------

1>echo 1 > /proc/sys/net/ipv4/ip_forward
2>/etc/sysctl.conf and net.ipv4.ip_forward = 0 to net.ipv4.ip_forward = 1.
3>
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
iptables -A FORWARD -i eth0 -o eth1 -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -A FORWARD -i eth1 -o eth0 -j ACCEPT



internal network eth1
external network eth0

Wednesday, March 10, 2010

Nfs Server configuration

Nfs Server Configuration :
===========================
1>vim /etc/exports
2> /home 192.168.0.0/255.255.255.0(rw,sync)
3>open /etc/hosts.deny:
then portmap:ALL
4>Then for indivisual network address open /etc/hosts.allow:
and add portmap: 192.168.0.1 , 192.168.0.2
5>ps aux | grep portmap
6>service portmap restart.
chkconfig portmap on
7>rpcinfo -p
8>service nfs restart
chkconfig nfs on
9>showmount -e localhost or the ip address of the host