الجمعة، 28 مايو 2010

Linux Networking Configuring Multiple IP Addresses

Configuring Multiple IP Addresses E-mail

Configuring Multiple IP Addresses on a single NIC.


In the last section, we have learned to configure IP address for your interface. It is also possible to configure more than one IP addresses on a single NIC example: eth0. For this, we need to create a new child interface with name eth0:X where X can have the values 0, 1, 2, ........


The steps are very similar to the one we explained in the previous section (eth0). You need to verify the following details.

* First ensure the parent real interface (eth0) exists
* Verify that no other IP aliases with the same name exists with the name you plan to use. In this we want to create interface eth0:0.
* Create the virtual interface with the ifconfig command


As we discussed earlier, we shall create the file /etc/sysconfig/network-scripts/ifcfg-eth0:0 with the following contents.


-------------
DEVICE=Interface:X (eth0:0)
ONBOOT=yes
BOOTPROTO=static
IPADDR=IP_address
NETMASK=NET_MASK
-------------


Once it is done, please use the following commands to activate the interface.


-------------
root@Basil15099/~# ifdown Interface:X
root@Basil15099/~# ifup Interface:X
-------------


In my example, I have created a child interface eth0:0 with the IP address 192.168.1.101. So I had to modify the file /etc/sysconfig/network-scripts/ifcfg-eth0:0 with the following details.

-------------
DEVICE=eth0:0
ONBOOT=yes
BOOTPROTO=static
IPADDR=192.169.1.101
NETMASK=255.255.255.0
-------------

Then I executed the following commands to activate my child interface.

-------------
root@Basil15099/~# ifdown eth0:0
root@Basil15099/~# ifup eth0:0
-------------


If you are not using Fedora Linux, please use the following command to configure IP address for your child interface.

-------------
root@Basil15099/~# ifconfig interface:X IP_address netmask NET_MASK up
-------------

As you know this configuration will last till the next reboot. So in order to make the configuration permanent, you need to put the above command in the /etc/rc.local file.

So in my example, the command will be as follows.

-------------
root@Basil15099/~# ifconfig eth0:0 192.169.1.101 netmask 255.255.255.0 up
-------------


Thats all :-)

Linux Networking Configuring IP address

Configure IP address:


- Are you using Fedora linux or newer Redhat versions of Linux ??


Then it is very easy to configure IP address for your interface in linux. In fedora and newer redhat versions of linux, you may have noticed a directory named /etc/sysconfig/network-scripts. Some small modifications on the files of this directory will do the tricks :-)


If you want to configure an IP address for the interface eth0, you just need to create a file named ifcfg-eth0 under the directory /etc/sysconfig/network-scripts. The contents of the file should be as follows.


-------------
DEVICE= Interface_name
IPADDR=IP address
NETMASK=Netmask Value (Eg: 255.255.255.0)
BOOTPROTO=static
ONBOOT=yes
-------------

I have configured an IP address 192.168.1.100 to my interface eth0 using the following settings.

-------------
root@Basil15099/~#cd /etc/sysconfig/network-scripts
root@Basil15099//etc/sysconfig/network-scripts#cat ifcfg-eth0
#
# File: ifcfg-eth0
#
DEVICE=eth0
IPADDR=192.168.1.100
NETMASK=255.255.255.0
BOOTPROTO=static
ONBOOT=yes
#
# The following settings are optional
#
BROADCAST=192.168.1.255
NETWORK=192.168.1.0
root@Basil15099/~#
-------------

Please note that the above steps will only work with fedora linux and redhat versions.

Once the file is modified, you need to active the newly configured interface using the following commands.

-------------
root@Basil15099/~# ifdown interface_name
root@Basil15099/~# ifup interface_name
-------------

Eg:

-------------
root@Basil15099/~# ifdown eth0
root@Basil15099/~# ifup eth0
-------------

- Are you NOT USING Fedora Linux ? No worries....



As I have already told, the above method will only work with fedora and redhat versions of Linux. Here I am going to discuss some general tips to configure IP address by the use of a single command. This will work around all versions of linux so far :-)

Here is the command that assign an IP address to an interface.

-------------
root@Basil15099/~# ifconfig Interface_name IP_address netmask NET_MASK up
-------------


The "up" at the end of the command activates the interface.

Similar way, I have used the following command to configure an IP address 192.168.1.100 to my interface eth0.

-------------
root@Basil15099/~# ifconfig eth0 10.0.0.1 netmask 255.255.255.0 up
-------------


That's all!

NOTE: Once the IP address is configures using this method, what will happen when you reboot your machine ?


Of coarse, all configurations will be reset. So in order to make the configuration permanent, you need to put the above command in /etc/rc.local file. As you know, the script /etc/rc.local will be executed at the end of every reboot. So, if you add the command in the specified file, eth0 will automatically be configured with the given IP address in every reboot!!

Linux Networking- Introduction

Linux Networking- Introduction E-mail

Introduction


As you may know the the command ifconfig can be used to get the IP address of your interface. I am pasting a sample output of ifconfig command for reference.

-------------
root@Basil15099/~# ifconfig -a

eth0 Link encap:Ethernet HWaddr 00:0C:29:3B:66:D1
inet addr:83.166.168.139 Bcast:83.166.168.159 Mask:255.255.255.224
inet6 addr: fe80::20c:29ff:fe3b:66d1/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:403929286 errors:2261 dropped:5757 overruns:0 frame:0
TX packets:540873029 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:3650916530 (3.4 GiB) TX bytes:2670561852 (2.4 GiB)
Interrupt:177 Base address:0x1400

lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:89800080 errors:0 dropped:0 overruns:0 frame:0
TX packets:89800080 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:3330076384 (3.1 GiB) TX bytes:3330076384 (3.1 GiB)

sit0 Link encap:IPv6-in-IPv4
NOARP MTU:1480 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
-------------

The option -a will show all interfaces associated with your machine (Both active and inactive), where ifconfig will only show the active interfaces.
As you can see this command gives good information on the interrupts, or PCI bus ID, used by each card. You may ignore any further information's in order to avoid confusion. But it matters when it came to troubleshooting which we will discuss at the end of his chapter.

how to Remove All Spam and Trash from Server

Remove All Spam and Trash from Server:

A buildup of spam and trash in user accounts can occupy several gigs worth of space. To easily remove spam and trash from your users’ accounts, you can use the following commands:

Maildir/Courier-IMAP:

rm -rf /home/*/mail/*/*/.spam/*
rm -rf /home/*/mail/.spam/*
rm -rf /home/*/mail/*/*/.Trash/cur/*
rm -rf /home/*/mail/*/*/.Trash/new/*


CPPOP:
rm -rf /home/*/mail/*/*/spam
rm -rf /home/*/mail/spam
rm -rf /home/*/mail/INBOX.Trash
rm -rf /home/*/mail/*/*/INBOX.Trash


To delete the cPanel trash folders:
rm -rf /home/*/.trash/*


goodbye

How do I move my cPanel accounts from other servers

Please note that this is for advanced users that are familiar with SSH access and have a solid understand of its functionality and how cPanel works.
Backing up old accounts (old VPS):
You want to do the following now:
# cd /home/ (now that you're in home you want to do)
# ls (this will give you a long print out of usernames)
# /scripts/pkgacct username (you will make a big list which looks like, below: )
/scripts/pkgacct username1
/scripts/pkgacct username2
/scripts/pkgacct username3
/scripts/pkgacct username4
/scripts/pkgacct username5
/scripts/pkgacct username6
Once you have that list, just add "&&" on the end so it looks like this:
/scripts/pkgacct username1 &&
/scripts/pkgacct username2 &&
/scripts/pkgacct username3 &&
/scripts/pkgacct username4 &&
/scripts/pkgacct username5 &&
/scripts/pkgacct username6
So now you're able to copy / paste the above into your SSH window and cPanel will start the backup process. Once its completed, you will see it return to #, then you will want to do the following:
# tar –cvf user.tar.gz cpmove*
It will package all the newly backed up accounts and palace them into one single user.tar.gz
Moving this into your VPS (with VPSNext):
Now that you have it all backed up you now want to make a temp account on your new VPS, which you can do via your /whm. To do this is you want to go /whm >> Account Functions >> Create a new Account.
Once the account is created, you will be able to ftp into the account, so what you need to do is:
In the SSH (at your old host) do the following:
# ftp
# ftp> (this will show up)
# ftp> open 123.123.123.123 (you want to open the connection to the IP)
# it will now prompt you for a username / password.
# ftp> put user.tar.gz
# ftp> (after its done) type exit
Now your content is on you're your new vps server, you can exit the shell on this account and you're all done.
SSH into your new VPS account, and do the following:
# cd /home/username-that-you-made/
# mv user.tar.gz /home/
# cd /home/
# tar –xvf user.tar.gz
now you can do the following which will you will be able to restore all the cPanel accounts back on your VPS.
/scripts/restorepkg username1 &&
/scripts/restorepkg username2 &&
/scripts/restorepkg username3 &&
/scripts/restorepkg username4 &&
/scripts/restorepkg username5 &&
/scripts/restorepkg username6
Congratulations, you're all done.

How To Update Kernel

 How To Update Kernel

login as root

1- update Yum

yum update yum yum update



yum update \kernel*

check after install

cat /boot/grub/grub.conf

and then reboot the server

or

see your Kernel version 

uname -a 

after that see all  Kernel version

yum list | grep kernel
 

to update Kerneluse this command
yum update kernel-*
 

then reboot server ...


 

الأربعاء، 26 مايو 2010

Linux File And Directory Permissio

Never make files world-writable, search for world-writable files in the current directory.
find . -perm -2 -print
Find directory with 777 permission.
find . -type d -perm 777 
search for suid and sgid files.
find / -type f -perm +6000 -ls
search the /dev directory for world writable files.
find /dev -perm -2 -print
To find all files for particular user
find / -user nobody  -ls  (where nobody is the username)
To locate all world-writable files on your system, use the following command:
root# find / -perm -2 ! -type l -ls
In the normal course of operation, several files will be world-writable, including some from /dev, and symbolic links, thus the "! -type l" which excludes these from the previous find command.
SUID commands
The SUID mechanism allow ordinary users to temporarily access some files with the rights of file's owner.
For example it is possible (by passwd command) to change his password, writing in /etc/passwd which is owned by root, because /bin/passwd is executable by anybody but SUID for root ; when executing passwd the real user id (user who runs the command) is different from the effective user id (root) necessary to write in /etc/passwd
SUID is indicated by a 's' in place of 'x' for the owner-execute permission : -rwsr-xr-x
in octal notation a SUID program is indicated by 04???
SGID is similar for the group permissions : 02???
Setting permission correctly.
You can use these commands to set 755 on directories and 644 on files
find -type f -exec chmod 644 {} \;
      find -type d -exec chmod 755 {} \;