Apache2 Installation in Debian

By Default apache2 package you will be given the package apache2-mpm-worker, other packages are available:

apache2-mpm-worker

The worker MPM provides a threaded implementation for Apache2. It is considerably faster than the traditional model, and is the recommended MPM.

apache2-mpm-prefork

This Multi-Processing Module (MPM) implements a non-threaded, pre-forking web server that handles requests in a manner similar to Apache 1.3. It is appropriate for sites that need to avoid threading for compatibility with non-thread-safe libraries.

#apt-get install apache2

#apt-get install apache2-mpm-prefork

That's it basic apache2 installation finished.If you want to test your installation go to your browser and type the following

http://youripaddress/apache2-default/

This should display welcome message then your installation is correct.

Default document root directory for apache2 is /var/www

If you want to change the default document root directory in apache2 you have to modify /etc/apache2/sites-available/default file.Edit this file and change the path to where ever you want to change.

Now you need to install PHP4 and PHP5 modules for apache2

If you want to run PHP5 and PHP4 supprt at the same time it is not possible, we must run one of them as CGI, the other one as Apache module. We will use PHP5 as Apache module and PHP4 as CGI.

If you want to install PHP5 from debian packages you need to enter the one of the source list in your /etc/apt/sources.list file

deb http://packages.dotdeb.org stable all
deb-src http://packages.dotdeb.org stable all

Now you need to run the following command to update source list

#apt-get update

Now you need to install following modules to support PHP5 and PHP4

#apt-get install libapache2-mod-php5 php4-cgi php5-curl php5-dev php5-gd php5-gmp php5-imap php5-ldap php5-mcrypt php5-mhash php5-ming php5-mysql php5-mysqli php5-odbc php5-pdo-mysql php5-pdo-sqlite php5-pear php5-pspell php5-snmp php5-sybase php5-tidy php4-curl php4-domxml php4-gd php4-gmp php4-imap php4-ldap php4-mcal php4-mcrypt php4-mhash php4-ming php4-mysql php4-odbc php4-pspell php4-recode php4-snmp php4-xslt php4-xdebug curl libwww-perl imagemagick

Now you need to change the following line from /etc/apache2/apache2.conf file

DirectoryIndex index.html index.cgi index.pl index.php index.xhtml

to

DirectoryIndex index.html index.htm index.shtml index.cgi index.pl index.php index.php4 index.xhtml

and add these two lines in the section where you can find AddType and AddHandler directives

AddHandler php-script .php4
Action php-script /cgi-bin/php4

This will make sure that PHP files with the extension .php4 are executed as CGI. PHP files with the extension .php will be run by the Apache2-PHP5 module.

Next, we have to enable a few Apache modules, like for example the actions module otherwise we cannot run PHP4 as CGI

#a2enmod actions ssl rewrite suexec include

Now you need to restart your apache server using the following command

#/etc/init.d/apache2 restart

By Default apache2 package you will be given the package apache2-mpm-worker, other packages are available:

apache2-mpm-worker

The worker MPM provides a threaded implementation for Apache2. It is considerably faster than the traditional model, and is the recommended MPM.

apache2-mpm-prefork

This Multi-Processing Module (MPM) implements a non-threaded, pre-forking web server that handles requests in a manner similar to Apache 1.3. It is appropriate for sites that need to avoid threading for compatibility with non-thread-safe libraries.

#apt-get install apache2

#apt-get install apache2-mpm-prefork

That's it basic apache2 installation finished.If you want to test your installation go to your browser and type the following

http://youripaddress/apache2-default/

This should display welcome message then your installation is correct.

Default document root directory for apache2 is /var/www

If you want to change the default document root directory in apache2 you have to modify /etc/apache2/sites-available/default file.Edit this file and change the path to where ever you want to change.

Install PHP5 support for Apache2

If you want to install PHP5 from debian packages you need to enter the one of the source list in your /etc/apt/sources.list file

deb http://packages.dotdeb.org stable all
deb-src http://packages.dotdeb.org stable all

or

deb http://people.debian.org/~dexter php5 sarge
deb-src http://people.debian.org/~dexter php5 sarge

Now you need to save your file and run the following command to take our new changes effect

#apt-get update

Now you need to install PHP5 required packages for apache

#apt-get install php5 libapache2-mod-php5 php5-curl php5-gd

that's it PHP5 for apache2 installed now you need to do the following

#cd /etc/apache2/mods-enabled/

#ln -s /etc/apache2/mods-available/php5.load

#ln -s /etc/apache2/mods-available/php5.conf

Now you need to restart your apache server using the following command

#/etc/init.d/apache2 restart

Now you apache server is ready with PHP5 support

Limit physical access and booting capabilities

  • Enable BIOS password
  • Disable floppy booting
  • Set a LILO or GRUB password (/etc/lilo.conf or /boot/grub/menu.lst, respectively);
    check that the LILO or GRUB configuration file is read-protected.

Partitioning

  • Separate user-writable data, non-system data, and rapidly changing run-time data to their own partitions
  • Set nosuid,noexec,nodev mount options in /etc/fstab on ext2 partitions such as /tmp

Password hygiene and login security

  • Set a good root password
  • Enable password shadowing and MD5
  • Install and use PAM - Add MD5 support to PAM and make sure that (generally speaking) entries in /etc/pam.d/ files which grant access to the machine have the second field in the pam.d file set to "requisite" or "required".
  • Tweak /etc/pam.d/login so as to only permit local root logins.
  • Also mark authorized tty:s in /etc/security/access.conf and generally set up this file to limit root logins as much as possible.
  • Add pam_limits.so if you want to set per-user limits
  • Tweak /etc/pam.d/passwd: set minimum length of passwords higher (6 characters maybe) and enable md5
  • Add group wheel to /etc/group if desired; add pam_wheel.so group=wheel entry to /etc/pam.d/su
  • For custom per-user controls, use pam_listfile.so entries where appropriate
  • Have an /etc/pam.d/other file and set it up with tight security
  • Set up limits in /etc/security/limits.conf (note that /etc/limits is not used if you are using PAM)
  • Tighten up /etc/login.defs; also, if you enabled MD5 and/or PAM, make sure you make the corresponding

Changes here, too

  • Disable root ftp access in /etc/ftpusers
  • Disable network root login; use su or sudo.

Other local security issues

  • Kernel patches uptodate
  • Tighten up logfile permissions (/var/log/{last,fail}log, Apache logs)
  • Verify that setuid checking is enabled in /etc/checksecurity.conf
  • Consider making some log files append-only and configuration files immutable using chattr (ext2 filesystems only)
  • Set up file integrity (Common tools used for this are sXid, AIDE (Advanced Intrusion Detection Environment), TripWire (non-free; the new version will be GPL), integrit and samhain.
  • Install debsums
  • Consider replacing locate with slocate
  • Log everything to a local printer

Limit network access

  • Install and configure ssh (suggest PermitRootLogin No in /etc/ssh, PermitEmptyPasswords No; note other suggestions in text also)
  • Consider disabling or removing in.telnetd
  • Generally, disable gratuitous services in /etc/inetd.conf using update-inetd --disable (or disable inetd altogether, or use a replacement such as xinetd or rlinetd)
  • Disable other gratuitous network services; mail, ftp, DNS, www etc should not be running
    if you do not need them and monitor them regularly.
  • For those services which you do need, do not just use the most common programs, look for more secure versions shipped with Debian (or from other sources). Whatever you end up running,make sure you understand the risks.
  • Set up chroot jails for outside users and daemons.
  • Configure firewall and tcpwrappers (i.e. hosts_access); note trick for /etc/hosts.deny in text
  • If you run ftp, set up your ftpd server to always run chrooted to the user's home director
  • If you run X, disable xhost authentication and go with ssh instead; better yet, disable remote X if you can (add -nolisten tcp to the X command line and turn off XDMCP in /etc/X11/xdm/xdm-config by setting the requestPort to 0)
  • Disable outside access to printers
  • Tunnel any IMAP or POP sessions through SSL or ssh; install stunnel if you want to provide this service to remote mail users Set up a loghost and configure other machines to send logs to this host (/etc/syslog.conf)
  • Secure BIND, Sendmail, and other complex daemons (run in a chroot jail; run as non-root pseudo-user)
    Install snort or a similar logging tool.
  • Do without NIS and RPC if you can (disable portmap).

Policy issues

  • Educate users about the whys and hows of your policies. When you have prohibited something which is regularly available on other systems, provide documentation which explains how to accomplish similar results using other, more secure means.
  • Prohibit use of protocols which use cleartext passwords (telnet, rsh and friends; ftp, imap, http)
  • Prohibit programs which use SVGAlib.
  • Use disk quotas.

For more Security Tips and Configuration For Debian Click here

By Default apache2 package you will be given the package apache2-mpm-worker, other packages are available:

apache2-mpm-worker

The worker MPM provides a threaded implementation for Apache2. It is considerably faster than the traditional model, and is the recommended MPM.

apache2-mpm-prefork

This Multi-Processing Module (MPM) implements a non-threaded, pre-forking web server that handles requests in a manner similar to Apache 1.3. It is appropriate for sites that need to avoid threading for compatibility with non-thread-safe libraries.

#apt-get install apache2

#apt-get install apache2-mpm-prefork

Run the script “apache2-ssl-certificate” i.e

# apache2-ssl-certificate

and you can see the following screen and enter all the required information.

Creating self-signed certificate

replace it with one signed by a certification authority (CA)

enter your ServerName at the Common Name prompt

If you want your certificate to expire after x days call this programm

with -days x

Generating a 1024 bit RSA private key

..........................................++++++..........++++++

writing new private key to '/etc/apache2/ssl/apache.pem'

-----

You are about to be asked to enter information that will be incorporated

into your certificate request.

What you are about to enter is what is called a Distinguished Name or a DN.

There are quite a few fields but you can leave some blank

For some fields there will be a default value,

If you enter '.', the field will be left blank.

-----

Country Name (2 letter code) [GB]:

State or Province Name (full name) [Some-State]:

Locality Name (eg, city) []:

Organization Name (eg, company; recommended) []:

Organizational Unit Name (eg, section) []:

server name (eg. ssl.domain.tld; required!!!) []:

Email Address []:

Run the script “a2enmod ssl” i.e

# a2enmod ssl

This Will automatically generates a symbolic link between mods- available and mods – enabled

Make a copy of '/etc/apache2/sites-available/default' in the /etc/apache2/sites-available/default file - call it 'ssl'

# cp /etc/apache2/sites-available/default /etc/apache2/sites-available/ssl

Make a sym-link to this new site configuration for this use

# ln -s /etc/apache2/sites-available/ssl /etc/apache2/sites-enabled/

(or)
#a2ensite ssl

If you want to change the any basic configuration settings change in /etc/apache2/apache2.conf and if you want to change the default document root change in /etc/apache2/sites-available/default file and restart the apache server.

To Restart Apache server use the following command

#/etc/init.d/apache2 restart

Now we need to change the port address in /etc/apache2/ports.conf by default it will listen port 80 and now we are installing with SSL we need to change port 443 to listen

Listen 443

Edit /etc/apache2/sites-available/ssl (or whatever you called your new ssl site's config) and change port 80 in the name of the site to 443.

Add below two lines some where in /etc/apache2/apache2.conf file

SSLEngine On

SSLCertificateFile /etc/apache2/ssl/apache.pem

Edit SSLCertificateFile /etc/apache2/ssl/apache.pem and enter the locations of certificate file and certificate key file .Below one is the example

Ex:- SSLCertificateFile /etc/apache2/ssl/online.test.net.crt
SSLCertificateKeyFile /etc/apache2/ssl/online.test.net.key

Set ServerSignature off, follow these steps edit the /etc/apache2/apache2.conf file and add these two lines

ServerSignature Off
ServerTokens ProductOnly

If you want to add support of php and cgi scripts install the following packages libapache2-mod-php4,php4-cli,php44-common,php4-cgi

# apt-get install libapache2-mod-php4 php4-cli php4-common php4-cgi

If you want to allow the different index files types check for the following line in /etc/apache2/apache2.conf file

DirectoryIndex index.html index.cgi index.pl index.php index.xhtml index.shtml

Restart the apache server

/etc/init.d/apache2 restart

If you want apache server web interface or GUI tools click here

Media Access Control address, a hardware address that uniquely identifies each node of a network. In IEEE 802 networks, the Data Link Control (DLC) layer of the OSI Reference Model is divided into two sublayers: the Logical Link Control (LLC) layer and the Media Access Control (MAC) layer. The MAC layer interfaces directly with the network medium.Consequently, each different type of network medium requires a different MAC layer. On networks that do not conform to the IEEE 802 standards but do conform to the OSI Reference Model, the node address is called the Data Link Control (DLC) address.

If you want to change your network card mac address you need to use simple utility called mac changer.MAC changer is a utility for manipulating the MAC address of network interfaces

Possible usages

You’re in a DHCP network with some kind of IP-based restriction

You’ve a cluster that boot with BOOTP and you want to have a clean set of MACs

Debug MAC based routes

MAC Changer Features

Set specific MAC address of a network interface

Set the MAC randomly

Set a MAC of another vendor

Set another MAC of the same vendor

Set a MAC of the same kind (eg: wireless card)

Display a vendor MAC list (today, 6800 items) to choose from

Install MAC Changer in Debian

#apt-get install macchanger

This will complete the installation.

If you Find your MAC address using the following command

ifconfig

eth0 Link encap:Ethernet HWaddr 00:0C:29:A8:D0:FA
inet addr:172.20.22.35 Bcast:172.20.22.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fea8:d0fa/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:7690 errors:0 dropped:0 overruns:0 frame:0
TX packets:6399 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:4284579 (4.0 MiB) TX bytes:876317 (855.7 KiB)
Interrupt:177 Base address:0×1080

In the above example MAC Address is 00:0C:29:A8:D0:FA

If you want to configure MAC Changer you need to stop the networking services using the following command

#/etc/init.d/networking stop

Now you need to configure your MAC address using the following examples

MAC Changer Syntax

macchanger [options] device

Examples

# macchanger eth1

Current MAC: 00:09:a5:eb:23:f7 (Hansung Eletronic Industries Development Co., Ltd)
Faked MAC: 00:09:a5:eb:23:f8 (Hansung Eletronic Industries Development Co., Ltd)

# macchanger –endding eth1

Current MAC: 00:09:a5:eb:23:f8 (Hansung Eletronic Industries Development Co., Ltd)
Faked MAC: 00:09:a5:6f:31:23 (Hansung Eletronic Industries Development Co., Ltd)

# macchanger –another eth1

Current MAC: 00:09:a5:6f:31:23 (Hansung Eletronic Industries Development Co., Ltd)
Faked MAC: 00:11:18:5b:3a:1f (Blx Ic Design Corp., Ltd.)

# macchanger -A eth1

Current MAC: 00:06:5b:f6:f3:48 (Dell Computer Corp.)
Faked MAC: 00:0d:11:93:0c:4f (Dentsply - Gendex)

# macchanger -r eth1

Current MAC: 00:0d:11:93:0c:4f (Dentsply - Gendex)
Faked MAC: 3c:f1:89:f9:1f:ce (unknown)

# macchanger –mac=01:23:45:67:89:AB eth1

Current MAC: 00:40:96:43:87:65 [wireless] (Cisco/Aironet 4800/340)
Faked MAC: 01:23:45:67:89:ab (unknown)

# ./macchanger –list=Cray

Misc MACs:
Num MAC Vendor
— — ——
065 - 00:00:7d - Cray Research Superservers,Inc
068 - 00:00:80 - Cray Communications (formerly Dowty Network Services)
317 - 00:40:a6 - Cray Research Inc.

Here is the list of available options for MAC Changer

-h, -help

Show summary of options.

-V, -version

Show version of program.

-e, -endding

Don’t change the vendor bytes.

-a, -another

Set random vendor MAC of the same kind.

-A Set random vendor MAC of any kind.

-r, -random

Set fully random MAC.

-l, -list[=keyword]

Print known vendors (with keyword in the vendor’s description string)

-m, –mac XX:XX:XX:XX:XX:XX

Set the MAC XX:XX:XX:XX:XX:XX

If you completed the your MAC address changes you need to start the networking service using the following command

#/etc/init.d/networking start

What is Ethernet Bonding ?

Ethernet bonding refers to aggregating multiple ethernet channels together to form a single channel. This is primarily used for redundancy in ethernet paths or for load balancing. This page refers in particular to performing ethernet bonding under linux, and so does not limit itself to discussion of 802.3ad Trunk Aggregation.

Bonding Types

The linux kernel bonding module supports a number of bonding types.

Round Robin

Packets are transmitted in a round robin fashion over the available slave interfaces. Provides both load balancing and fault tolerance

Active Backup

One slave interface is active at any time. If one interface fails, another interface takes over the MAC address and becomes the active interface. Provides fault tolerance only. Doesn't require special switch support

Balance XOR

Tranmissions are balanced across the slave interfaces based on ((source MAC) XOR (dest MAC)) modula slave count. The same slave is selected for each destination MAC. Provides load balancing and fault tolerance.

Broadcast

Transmits everything on all slave interfaces. Provides fault tolerance.

802.3ad

This is classic IEEE 802.3ad Dynamic link aggregation. This requires 802.3ad support in the switch and driver support for retrieving the speed and duplex of each slave.

Balance TLB

Adaptive Transmit Load Balancing. Incoming traffic is received on the active slave only, outgoing traffic is distributed according to the current load on each slave. Doesn't require special switch support

Balance ALB

Adaptive Load Balancing - provides both transmit load balancing (TLB) and receive load balancing for IPv4 via ARP negotiation. Doesn't require special switch support, but does require the ability to change the MAC address of a device while it is open

Setup Bonding Ethernet on Debian with a 2.4 kernel

To use Bonding Ethernet for High-Availability (fail-over) on Debian (Woody, Sarge or Sid with a 2.4.x kernel) you need to:

install package ifenslave-2.4.To install this package follow this command

#apt-get install ifenslave-2.4

make sure the real NICs kernel modules are loaded automatically

edit /etc/network/interfaces to look like this:

iface bond0 inet static
address 10.31.1.5
netmask 255.255.255.0
network 10.31.1.0
gateway 10.31.1.254
up /sbin/ifenslave bond0 eth0
up /sbin/ifenslave bond0 eth1

comment or borrow the lines referring to your real NICs in the same file

add the following lines to your /etc/modutils/arch/i386:

alias bond0 bonding

options bonding mode=1 miimon=100 downdelay=200 updelay=200

Now run the following command for update

#update-modules

Setup Bonding Ethernet on Debian with a 2.6 kernel

To use Bonding Ethernet for High-Availability (fail-over) on Debian (Woody, Sarge or Sid with a 2.4.x kernel) you need to:

install package ifenslave-2.6.To install this package follow this command

#apt-get install ifenslave-2.6

make sure the real NICs kernel modules are loaded automatically

edit /etc/network/interfaces to look like this:

iface bond0 inet static
address 10.31.1.5
netmask 255.255.255.0
network 10.31.1.0
gateway 10.31.1.254
up /sbin/ifenslave bond0 eth0
up /sbin/ifenslave bond0 eth1

comment or borrow the lines referring to your real NICs in the same file

add the following lines to your /etc/modprobe.d/arch/i386:

alias bond0 bonding

options bonding mode=1 miimon=100 downdelay=200 updelay=200

Basics of IP networking

A Debian host may have several interfaces each with a different Internet Protocol (IP) address. Interfaces may be of several different types, including:

  • Loopback: lo
  • Ethernet: eth0, eth1
  • Wi-Fi: wlan0, wlan1, wifi0,
  • Token Ring: tr0, tr1
  • PPP: ppp0, ppp1

There is a wide range of other network devices available, including SLIP, PLIP (serial and parallel line IP), "shaper" devices for controlling the traffic on certain interfaces, frame relay, AX.25, X.25, ARCnet, and LocalTalk.

Every network interface connected directly to the Internet (or to any IP-based network) is identified by a unique 32 bit IP address. The IP address can be divided into the part that addresses the network and the part that addresses the host. If you take an IP address, set to 1 the bits that are part of the network address and set to 0 the bits that are part of the host address then you get the so-called netmask of the network.

Traditionally, IP networks were grouped into classes whose net address parts were 8, 16 or 24 bits in length. This system was inflexible and wasted many IP addresses, so today IPv4 networks are allocated with network address parts of varying length.

               IP addresses                           net mask          length
     Class A   1.0.0.0     - 126.255.255.255  255.0.0.0        =  /8
     Class B   128.0.0.0  - 191.255.255.255  255.255.0.0     = /16
     Class C   192.0.0.0  - 223.255.255.255  255.255.255.0  = /24
 

IP addresses not in these ranges are used for special purposes.

There are address ranges in each class reserved for use on local area networks (LANs). These addresses are guaranteed not to conflict with any addresses on the Internet proper. (By the same token, if one of these addresses is assigned to a host then that host must not access the Internet directly but must access it through a gateway that acts as a proxy for individual services or else does Network Address Translation.) These address ranges are given in the following table along with the number of ranges in each class.

     network addresses                         length  how many
     Class A   10.x.x.x                             /8      1
     Class B   172.16.x.x -  172.31.x.x       /16     16
     Class C   192.168.0.x - 192.168.255.x /24     256
 

The first address in an IP network is the address of the network itself. The last address is the broadcast address for the network. All other addresses may be allocated to hosts on the network. Of these, the first or the last address is usually allocated to the Internet gateway for the network.

The routing table contains the kernel's information on how to send IP packets to their destinations. Here is a sample routing table printout for a Debian host on a local area network (LAN) with IP address 192.168.50.x/24. Host 192.168.50.1 (also on the LAN) is a router for the corporate network 172.20.x.x/16 and host 192.168.50.254 (also on the LAN) is a router for the Internet at large.

     # route
     Kernel IP routing table
     Destination   Gateway          Genmask       Flags Metric Ref Use Iface
     127.0.0.0      *                   255.0.0.0       U      0       0     2   lo
     192.168.50.0 *                   255.255.255.0 U      0       0   137  eth0
     172.20.0.0    192.168.50.1    255.255.0.0    UG    1       0     7   eth0
     default         192.168.50.254 0.0.0.0          UG     1       0    36  eth0
  • The first line after the heading says that traffic destined for network 127.x.x.x will be routed through lo, the loopback interface.
  • The second line says that traffic destined for hosts on the LAN will be routed through eth0.
  • The third line says that traffic destined for the corporate network will be routed toward gateway 192.168.50.1 also through eth0.
  • The fourth line says that traffic destined for the Internet at large will be routed toward gateway 192.168.50.254 also through eth0.

IP addresses in the table may also appear as names that are obtained by looking up addresses in /etc/networks or by using the C Library resolver.

In addition to routing, the kernel can perform network address translation, traffic shaping and filtering.

This article can be found here

Setting your hostname

Setting up your hostname upon a Debian installation is very straightforward. You can directly query, or set, the hostname with the hostname command.

As an user you can see your current hostname with:

$ /bin/hostname 
 
Example

To set the hostname directly you can become root and run:

/bin/hostname newname

When your system boots it will automatically read the hostname from the file /etc/hostname

Setting up DNS

When it comes to DNS setup Debian doesn't differ from other distributions. You can add hostname and IP addresses to the file /etc/hosts for static lokups.

To cause your machine to consult with a particular server for name lookups you simply add their addresses to /etc/resolv.conf.

For example a machine which should perform lookups from the DNS server at IP address 192.168.1.1 would have a resolv.conf file looking like this:

search test.com
nameserver 192.168.3.2

Setting up IP address.

The IP addresses associated with any network cards you might have are read from the file /etc/network/interfaces.

A sample entry for a machine with a static address would look something like this:

# The loopback network interface
auto lo
iface lo inet loopback
 
# The primary network interface
auto eth0
iface eth0 inet static
 address 192.168.3.90
 gateway 192.168.3.1
 netmask 255.255.255.0
 network 192.168.3.0
 broadcast 192.168.3.255
 

Here we've setup the IP addresss (192.168.3.90), the default gateway (192.168.3.1), and the netmask.

For a machine running DHCP the setup would look much simpler:

# The loopback network interface
auto lo
iface lo inet loopback
 
# The primary network interface - use DHCP to find our address
auto eth0
iface eth0 inet dhcp
 

(If you're using a DHCP based setup you must have a DHCP client package installed - usually one of pump,dhcpcd or dhcp3-client.)If you make changes to this file you can cause them to take effect by running:

/etc/init.d/networking restart

Setting up Second IP address or Virtual IP address in Debian

If you are a server system administrator or normal user some time you need to assign a second ipaddress to your debian machine.For this you need to edit the /etc/network/interfaces file and you need to add the following syntax.Below one is the only example you need to chnage according to your ip address settings

                                        auto eth0:1
                                               iface eth0:1 inet static
                                               address 192.168.1.60
                                               netmask 255.255.255.0
                                               network x.x.x.x
                                               broadcast x.x.x.x
                                                gateway x.x.x.x
    
           You need to enter all the details like address,netmask,network,broadcast and gateways values after
         entering all the values  save this file and you need to restart networking services in debian using 
         the following command  to take effect of our new  ipaddress.
 
            #/etc/init.d/networking restart
 
           If you want to check your new ip is assigned or not use the following command
           
           #/sbin/ifconfig

Setting your default gateway.

If you read the previous section then you'll see that the default route for a hos with a static IP address can be set in /etc/network/interfaces.If you wish to view your current default route/gateway then you can run:

# netstat -nr
Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
192.168.3.0     0.0.0.0          255.255.255.0   U         0      0         0 eth0
0.0.0.0         192.168.3.1      0.0.0.0            UG        0      0         0 eth0
 

Alternatively you can use the route command:

# /sbin/route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
192.168.3.0     *                255.255.255.0   U        0      0         0   eth0
default         router            0.0.0.0            UG       0      0         0   eth0

(Here the see the hostname router instead of the IP address 192.168.3.1 - to avoid that run "/sbin/route -n").

To change your default route you must first remove the current one:

/sbin/route del default gw 192.168.3.1
 

Once this has done you'll have no gateway and be unable to talk to non-local hosts.Add the new route with :

/sbin/route add default gw 192.168.3.100
 

Network testing basics

Install netkit-ping, traceroute, dnsutils, ipchains (for 2.2 kernel), iptables (for 2.4 kernel), and net-tools packages and:

     $ ping google.com               # check Internet connection
     $ traceroute google.com      # trace IP packets
     $ ifconfig                           # check host config
     $ route -n                         # check routing config
     $ dig [@dns-server.com] host.dom [{a|mx|any}] |less # check host.dom DNS records by dns-server.com 
                                                                                 # for a {a|mx|any} record
     $ ipchains -L -n |less         # check packet filter (2.2 kernel)
     $ iptables -L -n |less         # check packet filter (2.4 kernel)
     $ netstat -a                    # find all open ports
     $ netstat -l --inet            # find listening ports
     $ netstat -ln --tcp           # find listening TCP ports (numeric)

Followers

Video Post