30 November, 2010

fork bomb explained...

 


Don't try this @ your home ....Injurious to your computer's health, else  you will be...



Defining the fork bomb . . .

                   A fork bomb is simply a line of some characters entered into the command line of a Unix system, and when the enter key is pressed, within seconds the computer will crash... The little program we entered in to the bash shell act as a process & make multiple copies of itself, setting off a chain reaction and thus quickly exhausting the system’s resources. Most computer operating systems can be  simply crashed or at least brought to a coma stagewhen users, even those without superuser privileges, launches this 'logical bomb' that eat up all memory and CPU time. "Forkbomb" does nothing but launch two or more copies of itself upon startup. Since these copies do the same in turn, this sets off a chain reaction with an exponentially growing number of processes. A fork bomb process "explodes" by recursively  spawning copies of itself using the Unix system call fork().




Working of the 'bomb'...
  
              A process begins  execution when it's execution environment and corresponding threads are created. Before  execution the process has to take a room in the process table, which is a data structure for holding  information required by the kernel to run the process such as...

      > Process state
      > Several process IDs
      > User IDs for determining process privileges
      > Pointer to text structure for shared text areas
      > Pointer to page table for memory management
      > Scheduling parameters,  priority values
      > Timers for resource usage etc...


                A fork bomb creates a large number of processes very quickly and begins execution one after the other by seizing the process table. So whenever a free slot occurs in the process table, another copy of the bomb process enters it and start spawning new bombs. When process table becomes saturated, no new programs may start until another process terminates. Even if that happens, it is not likely that a useful program may be started since the instances of the bomb program will each attempt to take any newly-available slot themselves.


                In addition to using space in the process table, each child process of a fork bomb uses further processor-time and memory. As a result of this, the system and existing programs slow down and become much more unresponsive and difficult or even impossible to use.

see the defenition for fork bomb in wikipedia,
                In computing, the fork bomb is a form of denial-of-service attack against a computer system which makes use of the fork operation (or equivalent functionality) whereby a running process can create another running process. Fork bombs count as wabbits: they typically do not spread as worms or viruses. To incapacitate a system, they rely on the (generally valid) assumption that the number of programs and processes which may execute simultaneously on a computer has a limit.




Some bombs that you can try @ your friend's pc


Fork Bomb in windows

 Open up notepad and type the string below and and save
 it as fork.bat :


   %0|%0


 On double clicking this file,it will lead to total CPU jam 
 by opening a large no. of processes of command prompt.




In UNIX C or C++:


 Compile and execute the following C/C++ code snippet
 in Unix to understand (???) the bomb...

#include <unistd.h>
int main(void)
{
    for(;;)      //for(;;) or while(1) makes an infinite loop
    fork();
    return 0;
}


Bash Shell Fork Bomb


Following is the most coolest one i had ever seen. Take the bash terminal and just type in the following code....

   : (){ : |:& };:

This code is the elegant and most beautiful example of a fork bomb.


:()       _  define ':' , like a function call
{         _  beginning of what to do when we say ':'
    :      _  load another copy of the ':' function into
               memory...
    |      _  ...and pipe its output to...
    :      _  ...another copy of ':' function, which has to be
               loaded into memory (therefore, ':|:' simply gets 
               two copies of ':' loaded whenever ':' is called)
    &     _  disown the functions, that is if the first ':' is
               killed, all of the functions that it has started
               should NOT be auto-killed...
}         _  end of the definition of ':'
;          _  Having defined ':', like in structures etc... we
               should now...
:          _  ...call ':', initiating a chain-reaction: each ':' will
               start two more.


Simply the above function is the same as the code below

forkbomb(){ forkbomb|forkbomb & } ; forkbomb



How to get out of the bomb . . .
             One may have to reboot the system to resume its normal operation destroying all running copies of it. Trying to use a program to kill the rogue processes normally requires creating another process — this is  an impossible task if the host machine has no empty slots in its process table, or no space in its memory structures. Furthermore, as the processes of the bomb are terminated (for example, by using the kill command), process slots become free and the remaining fork bomb threads can continue reproducing again, either because there are multiple CPU cores active in the system, and/or because the scheduler moved control away from kill(8) due to the time slice being used up.


A simple solution is that we can stop (“freez”) the bomb's processes, so that a subsequent kill/killall can terminate them without any of the parts re-replicating due to newly available process slots:


killall -STOP bombprocess
killall -KILL  bombprocess



...Bye till the fire and smoke settles...
Read rest of entry

28 November, 2010

How to share /home directory between two linux installations

            Frequent re-installations of operating system due to crashes  is always been a problem for many of the linux users, and my case is also the same.... Everytime i start with doing something like trying some new commands or editing some configuration files and finally ends up with an 'OS crash' and a fresh installation thereafter. Now it's been a very usual matter that i may have to install a fresh copy of linux distro probably once in a month. Sometimes the crash may occur due to installation of a new theme (last week editing some theme files manually after it's installation made my 10.04box stand on nails...), sometimes the crash may be the by-product of installation of an incompatible version of application etc...

While fighting with all these crashes and re-installations the major problem is related to backing up of the data and personal files stored in the /home folder. Usually the contents of the /home contains files and directories including apache's root directory, downloads, files received over bluetooth, joomla/html/php projects etc. So it's very important to back up data all the time Ubuntu is reinstalled.

Solution

One of the best solution to avoid this kind of frequent backup-restore problem is separate the /home directory from the root directory during the installation. The advantages of this separation comes in two ways

1. When a crash occurs to the OS the /home directory remains intact because it is a separate disk partition. So on reinstalling after the crash we can map the old /home partition of the crashed one as the /home of the new linux. This makes it possible to access the files as if before the crash occured.

2. It's easy to share the /home folder between any no of linux distributions installed parellely on your machine. During installation of each of the distro, we can select the partition to be shared as its /home. Better keep the filesystem type (eg:- ext4) same while selecting the /home of other distro as it's new /home. This can be useful even with linux distributions of different architecture using similar filesystem types(Ubuntu and fedora can share a common /home if the /home is mounted as ext4).

On the ground...


Select the manual partitioning options


Setting up the root partition 


Selecting the /home partition of the previously crashed or parellelly installed linux.


 
Mounting the /home partition of old linux as /home of new linux. Don't check the format box. If mistaken you may lose all the data due to disk format
Read rest of entry

26 November, 2010

Choosing the right laptop for my friend

                       Last week i was looking out for a laptop for my friend. I had been instructed to check out for a notebook that cost below 50,000/-. He suggested me to checkout for a Dell or Vaio. The brand name is nowadays a big factor for any product and first word like 'dell' or 'vaio' from consumer is nothing because of this brand effect. He was looking for a professional + entertainment box. So I started checking out a right one for him.

I just compared the dell and vaio for him and felt that a dell will solve his need. Vaio is little bit costlier than dell, also you feel a difference in  configurations of vaio and dell at the same price. Dell laptops provides better hardware configuration than the Sony laptops @ same price range. Eventhough competition is live in the market, dells are being sold out more for the average customer, you can feel this if you tal
k to sum guys in the retail shops in the Ernakulam city.  I thinkthis may be due to  two  reasons from my  viewpoint. Thefirst reason i felts is the decent mix of hardware configuration @ moderate price in dells laptop  Average customers prefers laptops at price ranging from 35,000/- to 50,000/-. And the dells Inspiron series is a nice option at this price range providing a minimum combination of Intel's core i3 processor | 3gb ram | 1 gb graphics| ~300 GB HDD.

The secondreason may be the brand name Dell have built up so far. They were in the main stream of the market for the past years by providing products having significant difference in performance and quality than the cheaper counterparts from lenovo, acer etc... The cheaper ones usually ends up early due to battery problems or heating problems etc. From my personal experience also, dell seems to be nice notebook due to its perfomnce, ergonomics, battery life and support with the main stream operatng systems like windows, ubuntu, fedora etc... But initially there were some problems with availability service / repair. But the opening up of  new service centers will cover this problem to a great extent.

My first decision was to checkout for the XPS15 on dell's website. Its cool and handy, Impressedat its pretty appearence, they have come up with an appealing architecture for  hinges of the XPS. It may cost near 50k, since the price given is 45000/- in the website. We have purchased an Inspiron for @silentlover143, 4 months ago via online. That made a profit around 4K than the direct purchase from the retail shops. You have to pay only delivery charges in extra which may cost below 2K, and got the product delivered to home withn 2 weeks. But on further query we found that online purchase takes more than one an half months in between order & delivery here in EKM. 





So we decided to hang on with the new Inspiron series, it's too got a similar hinge of XPS, painted black and offering two series of configuration. There is a difference of 5K rupees in between models with core i3 and core i5, having RAM and HDD of 3gb|320gb and 4gb|500gb respectively with ATI graphics card included. The 14 inch and 15 inch screen options also differs in a price of 3000/- in core i5 series and around 500/- in core i3 series.

Inspiron seems to be a coolest optionnear 45k price range with a desent configuration and pretty look. Since the new XPS may take further weeks to reach on the hand of retailers for direct sale, and also costlier due to addons like speakers from JBL, Nvidia's presence, etc... built on the same processor family and memory of Inspiron machines, I made my suggestionfor my friend to go on for an Inspiron instead of waiting more and wasting extra bucks for the XPS...
Read rest of entry

23 November, 2010

Easiest way to add nautilus scripts in Ubuntu

                  Here is a bit tutorial for adding nautilus scritps in ubuntu that will help you to increase the system accessibility. These scripts can be run by simply clicking the right mouse button and selecting any from the 'scripts' menu. The imporatnt advantage of the nautilus scripts is its easiness, for example we dont need a an image processing standalone application to rotate an image or convert it to another format or to mirror it... The only think that we need is to select the image and right clicking on it and choosing any of the scripts... its simple and can be accessed as shown in the figure...



Installing Nautilus scripts in Ubuntu 

Nautilus scripts are available for dowloading from G-script site. You can use the link here  to download it directly to your pc. Follow the steps below to to complete the installation.

  • Untar the downloaded file using the following command
 $ tar -xvzf  nautilus-scripts.tar.gz
  •  You can see the scripts arranged in a heirarchical manner inside the extracted folder. Copy the contents of the extracted nautilus-scripts folder  to the .gnome2/nautilus-scripts folder in your home directory. Since it a hidden folder you can't see it @ the first time. Click Ctrl + H key after enterin the home directory to see the hidden directory.
  • That's all for the installation... You can access the scripts by selecting a file > right clicking it > and choosing any of the scripts arranged in categories under the scripts menu.
Hope you enjoyed th tip...
Read rest of entry

22 November, 2010

Basic javascript programs


 1. A javascript to implement variable usage
<html>
<title>Variable Using Script</title>
<body>
<script>
      var greetings;
      greetings='Hi, How are you?';
      alert(greetings);
</script>
</body>
</html>

2. A javascript to implement the pop-up boxes 
<html>
<title>Script for prompt</title>
<script>
var username;
var greeting;
username = prompt("What is your name?");
username=username.toUpperCase();
greeting="Hi, "+username;
alert(greeting);
</script>
</body>
</html>
</script>
</html>

3.Implementing the eval() function in javascript

          In javascript every input is read as string. We need to convert it to numbers for processing if the input is a number 
<html>
<title>Sum of Two Numbers</title>
<script>
var num1,num2;
var sum;
var msg;
num1=prompt("Enter the first number: ");
num1=eval(num1);
num2=prompt("Enter the second number: ");
num2=eval(num2);
sum=num1+num2;
msg="Sum= "+sum;
alert(msg);
</script></html>

4.  Using switch case in javascript.
<html>
<title>Switch Case</title>
<body>
<script>
       var num,day;
       num=prompt("Enter an integer: ");
       switch(num%7)
       {
              case 1: day="Sunday";break;
              case 2: day="Monday";break;
              case 3: day="Tuesday";break;
              case 4: day="Wednessday";break;
              case 5: day="Thursday";break;
              case 6: day="Friday";break;
              case 0: day="Saturday";break;
              default: day="Invalid Day Number!!\n";
       }
       alert("Day: "+day);
</script>
</body>
</html>

5. Implementing for loop in javascript
<html>
<title>For Loop</title>
<body>
<script>
       var i;
       for(i=0;i<10;i++)
       {
              alert("This is the message no: "+i);
       }
</script>
</body>
</html>

6. Generating local information from the browser using javascript
<html>
<title>Information</title>
<body>
<script>
       document.bgColor="blue";
       alert("Background: "+document.bgColor);
       alert("Domain: "+document.domain);
       alert("URL: "+document.location);
       alert("Last Modified: "+document.lastModified);
       alert("Last Page: "+document.referrer);
       alert("Title: "+document.title);
</script>
</body>
</html>

7.Writing dynamic javascript contents on to html page to display in browser 
<html>
<title>Dynamic Write</title>
<body>
<script>
       var name;
       name=prompt("Enter your name: ");
</script>
        Hi how are you?
<script>
       document.write(name);
</script>
</body>
</html>

8. Implementing onclick events and functions within a form using javascript
<html>
<title>Script for Form Variable Changing</title>
<body>
<script>
       function changebuttonValue()
       {
               document.myForm.button.value="changed";
       }
       function changeText()
       {
               document.myForm.text1.value="Enter you name";
       }
</script>
<form name=myForm>
<input type=text name=text1 onMouseOver='changeText();'>
<br>
<input type=button name='button' value=Enter onClick='changebuttonValue();'>
</form>
</body>
</html>

9. opening a new browser window using javascript
<html>
<title>Open a New Window</title>
<body>
<input type=button value="Show New Window" onClick="newWindow();">
<input type=button value="Close Window" onClick="closeWindow();">
<script>
       var new1;
       function newWindow()
       {
              //document.write("Hi");
              new1=window.open("frame1.html","Name","height=450,width=450");
              new1.focus();
       }
       function closeWindow()
       {
              new1.close();
       }
</script>
</body>
</html><hr align="left" size="1" width="100%">


Read rest of entry

a Javascript a day | my javascript tutorial . . .


                 Here i share my basic experimentsi had done with javascript. Its not enough for making a geekness with that, but only for making the first lessons of javascript ...

What is javascript ?

JavaScript is a scripting language that will allow you to add real programming to your webpages. You can create small application type processes with JavaScript, like a calculator or a primitive game of some sort. Important uses of javascript are
  • Browser Detection
    • Detecting the browser used by a visitor at your page. Depending on the browser, another page specifically designed for that browser can then be loaded. 
  • Cookies
    • Storing information on the visitor's computer, then retrieving this information automatically next time the user visits your page. This technique is called "cookies".
  • Control Browsers
    • Opening pages in customized windows, where you specify if the browser's buttons, menu line, status line or whatever should be present.
  • Validate Forms
    • Validating inputs to fields before submitting a form. An example would be validating the entered email address to see if it has an @ in it, since if not, it's not a valid address. 
 
where is the playground ?

The browser will use the 
<script type="text/javascript"> and </script> to tell where javascript starts and ends respectively.

The <script> …… </script>  Tag can be included in

  • <head> section
  • <body> section
  •  Both <head> section and <body> section
  •  In an External file with .js extension    
    • Eg : <script type="text/javascript" src="xxx.js"></script> 
To declare a variable in JavaScript, use the var command.    Eg : var state, city, zip, country; 

Basics

  • Write directly into the document.
     >> document.write("Welcome to my world!!!");

  • Write using POPUP Boxes
     Alert Box
     >> alert("Welcome to my world!!!");

     Confirm Box

     >>if (confirm("Do you agree")) 

               {alert("You agree")}
           else{alert ("You do not agree")};

    Prompt Box
    >> username=prompt("Please enter your 

                    name","Enter your name here");  

Check out this link to make out the rest.
Read rest of entry

21 November, 2010

My first java applet program

              This is a blog about embedding a simple java applet inside a web page. A java applet is actually a runnable java program that can be embedded in a website for showing some graphics or making the web page interactive. It all runs by itself and any modern web browser with java plugin can run applets. So we create a sample java program first and then compile it to make the .class file ie the runnable. Then this runnable is embedded in the web page in a mechanism similar to embedding pictures inside the html file using html tags.

So before you starting the applet programming you need a java programming environment within your system including javac compiler and Java Runtime Environment.

I started doing the applet programming as it is a topic in my Web Commerce paper. Still i didn't got enough time to invest for it, but here is the basic things that I came across while discovering the kick of applets with my ubuntu box... 
1. First open up your text editor and paint all the code inside it, save it with .java extension. Use the code snippet  below or download from here,
Read rest of entry

08 November, 2010

C program in UNIX to for TCP communication through sockets

Here is a C program in  Unix that introduces the basics of tcp communication by creating sockets. Here the cleint program and server programs communicates by passing messages to the sockets. 

Inorder to run this program store each program in  separate C files and compile it. Inorder to make it working run the programs simultaneosly in two terminals. 

tcp client program
/*program to create tcp client*/
#include<stdio.h>
#include<sys/types.h>
#include<sys/socket.h>
#include<arpa/inet.h>
#include<string.h>
#include<unistd.h>
#include<netinet/in.h>
#include<stdlib.h>
#include<sys/ipc.h>
#include<limits.h>
#include<fcntl.h>
#include<sys/shm.h>
main()
{
    int fd1,sid,f2,f3,f4,f1;
    char msg1[25],msg2[25];
   
    struct sockaddr_in client,server;
    client.sin_family=AF_INET;
    client.sin_port=htons(0);
    client.sin_addr.s_addr=htonl(INADDR_ANY);
    server.sin_family=AF_INET;
    server.sin_port=htons(1235); //please change this number while copying....
    server.sin_addr.s_addr=htonl(INADDR_ANY);
    sid=socket(AF_INET,SOCK_STREAM,0);
    if(sid<0)
        printf("socket not created\n");//please change this number while copying....
    else
    {
        printf("socket created\n");
        f1=bind(sid,(struct sockaddr*)&client,sizeof(struct sockaddr_in));
        if(f1==-1)
            printf("socket not bind\n");
        else
        {
            printf("socket binded\n");           
            f2=connect(sid,(struct sockaddr*)&server,sizeof(struct sockaddr_in));
            if(f2==-1)
                printf("connection request not send\n");
            else
            {               
                printf("\n\nconnection established\n\n");
                printf("Enter msg\n");
                scanf("%s",msg1);
                send(sid,msg1,sizeof(msg1),0);
                printf("msg send\n");
                recv(sid,msg2,sizeof(msg2),0);
                printf("received\n");
                printf("msg received is:%s\n",msg2);
            }
        }
    }
}







tcp server program

/*program to create tcp server*/
#include<stdio.h>
#include<sys/types.h>
#include<sys/socket.h>
#include<stdlib.h>
#include<arpa/inet.h>
#include<string.h>
#include<unistd.h>
#include<netinet/in.h>
int main()
{
    int sid,f1,f2,f3,f4,f5,p;
    char msg1[25],msg2[25];
    struct sockaddr_in client,server;
    server.sin_family=AF_INET;
    server.sin_port=htons(1235);  //please change this number while copying....
    server.sin_addr.s_addr=htonl(INADDR_ANY);
    sid=socket(AF_INET,SOCK_STREAM,0);
    if(sid<0)
        printf("socket not created\n");
    else
    {
        printf("socket created\n");
        f1=bind(sid,(struct sockaddr*)&server,sizeof(struct sockaddr_in));
        if(f1<0)
            printf("socket not bind\n");
        else
        {
            printf("socket bind\n");
            f2=listen(sid,5);
            p=sizeof(struct sockaddr_in);
            f3=accept(sid,(struct sockaddr*)&client,&p);
            if(f3<0)
                printf("connection not accepted\n");
            else
            {
                printf("connection accepted\n");
                recv(f3,msg1,sizeof(msg1),0);
                printf("Message recieved from client:%s\n",msg1);
                printf("Enter the msg\n");
                scanf("%s",msg2);
                f5=send(f3,msg2,sizeof(msg2),0);
                printf("Message send\n");
            }
        }
    }
    return 1;
}
Read rest of entry

18 October, 2010

Download flash videos in Ubuntu without any application

Here is a simple trick that you can use to download your favourite flash videos from Youtube or metacafe without any application. You can stop your search for an apt application for downloading youtube videos... installing it on linux...Just leave everything...


Just login to the youtube and click on some videos to play it.


While the video is streaming, check the /tmp folder in the Ubuntu's file system. There you can see the same video file being updated with filename like Flash26YGf2.flv


You can copy this video file to some other place to make it viewed later. If you reload the the webpage or open some other video in the same tab/window of the web browser then the previous video file will be overwritten with the new one. So better is to copy the flash video file just after it is completely buffered in the web browser.


This tip has one another advantage too. If you want to see the end part of a flash video file which is about 1 hour length, you dont need to download the complete video from the beginning. You can seek the video into desired portion in the website. Then video file in the tmp directory will be starting from the new positon to which you seeked it.


So this technique is simple and cool where you need only a flash video player embedded in the web browser only to save the video. This methode can be used in situation where you  can play  video but blocked from downloading it since you have no account registered in those websites.
Read rest of entry

14 October, 2010

How to add sudo to last command typed in bash terminal



Its most common that you might forget to type in the 'sudo' command along with some other commands. I have faced this problem many times and usually end up by typing the entire command with sudo keyword again. Here is a technique that we can use to avoid retyping the command again after typing sudo.

Consider that i have to install a package called blueman system with the apt package manager via the terminal. Here i am not adding the sudo command before the apt command



Then type the following command to avoid rexecuting the command with all permissions

 $ sudo !!


See here the bash automatically retyped the command with sudo. 



Read rest of entry

11 October, 2010

Troubleshooting Network problems in Ubuntu


                Internet connectivity is one of the important means of communication in todays life. So troubleshooting the problems in our own networks or reconfiguring it for the easiness is not to be praised as a "geekness". In my opinion you don't need to be a geek for setting an internet connection or recovering your machine from a network problem.

Before getting into more troubles just checkout wheather the physical network components (cables, NICs, and so on) are connected properly and working. If everything is right then proceed to the following steps



Checking the Connectivity to a Host

The troubleshooting is done in a bottom up manner. So we will troubleshoot the network layer first and then move on to transport layer. Here we will check the connetivity by pinging  to your default gateway. You should have either configured the default gateway in the /etc/network/interfaces file, i have written a post about it in the last month or leave it to the system using service such as DHCP. To check your default gateway in the actual routing table, use the ip command as follows:

$ ip route


The gateway for the default route in this example is  192.168.0.5 To make sure wheather there is internet connectivity to that gateway, use the ping command as follows, passing the address for your default gateway:

$ ping 192.168.0.5

By default, ping continues until you press Ctrl+c. Other important ping options include the following:
$ ping -a 10.0.0.1
            [You can here a buzzer sound @ each pings]
$ ping -c 4 10.0.0.1 
            [Ping 4 times and exit (default in Windows)]
$ ping -q -c 5 10.0.0.1 
            [Show summary of pings (works best with -c)]
$ sudo ping -f 10.0.0.1 
            [Send a flood of pings (must be root)]
$ ping -i 3 10.0.0.1 
            [Send packets in 3-second intervals]
$ sudo ping -I eth0 10.0.0.1  
            [Set source to eth0 (use if multiple NICs)]



Use the ping flood option with caution, if the packet size is larger than usual  it can cause connections to stand out.

Checking Address Resolution Protocol (ARP)


If you’re not able to ping your gateway, you may have an issue at the Ethernet hardware address layer. The Address Resolution Protocol (ARP) can be used to find information at the MAC layer (hardware layer). 

ARP stands for Address Resolution Protocol, which is used to  find  the  media  access control [MAC] address of a network neighbour for a given IP Address.


To view and configure ARP entries, we can use the arp or ip neighbor command. Arp  command displays  the  kernel’s IPv4 network neighbour cache. It can add entries to the table, delete one or display the current content.

$ arp -v    [List ARP cache entries by name]



Above command will show the names of other computers that the local computer’s ARP cache knows about and the associated hardware type and hardware address of each computer’s NIC. You can disable name resolution to see those computers’ IP addresses instead of the hostname by using the following command:

$ arp -vn     [List ARP cache entries by IP address]

          To delete an entry from the ARP cache, use 
          the -d option:
              $ sudo arp -d 10.0.0.50
                   [Delete address 10.0.0.50 from ARP cache]

          Instead of just letting ARP dynamically learn 
          about other systems, you can add static ARP 
          entries to the cache using the -s option:
               $ sudo arp -s 10.0.0.51 00:0B:6A:02:EC:95


To query a subnet to see if an IP is already in use, and to find the MAC address of the device using it, use the arping command. The arping command continuously queries for the address until the command is ended by typing Ctrl+c. Typically, you just want to know if the target is alive, so you can run one of the following commands:

$ arping -f 10.0.0.50 
[Query 10.0.0.50 and stop at the first reply]

                      
$ arping -c 2 10.0.0.51 
[Query 10.0.0.50 and stop after 2 counts]


Tracing Routes to Hosts

After verifying that you can ping your gateway and even reach machines that are outside of your network you can use traceroute (traceroute package should be installed) to find the problem correctly.

$ traceroute  www.mywebsite.com  
[Follow the route taken to a host]
 

If there are lines of asterisks (*) in the end of  the list  it is because of the firewalls inside your office/college network that block traffic to the target. However, if you see several asterisks before the destination, those can indicate congestion or network failures and points to bottleneck issues.

traceroute command options are
$ traceroute -I www.google.com 
                        Use ICMP packets to trace a route
$ traceroute -p 25 www.google.com 
                        Connect to port 25 in trace
$ traceroute -n www.google.com 
                        Disable name resolution in trace
$ tracepath www.google.com 
                        Use UDP to trace the route

Using the ip command...
You can do the same activities with ip command similar to route command. Here are three different ways to show the same basic routing information:

$ ip route show 
[Display basic routing information]

options for adding and deleting routes with ip are as follows:
$ sudo ip r add 192.168.0.0/24 via 10.0.0.100 dev eth0                  - Add route to interface
$ sudo ip r add 192.168.0.0/24 via 10.0.0.100  
                           - Add route no interface
$ sudo ip r del 192.168.0.0/24 
                           - Delete route

To make a new route permanent, edit the /etc/network/interfaces file and place the information about the new route in that file. For example, to add the route added with the ip command above, add the following lines to /etc/network/interfaces:
       iface eth0 inet static
    address 192.168.0.0
    netmask 255.255.255.0
    gateway 10.0.0.100

Read rest of entry
 

Terminal Diary | techblog Copyright © 2009 Gadget Blog is Designed by jintu jacob Powered by Blogger