NS2 and UBUNTU Installation on VMWARE

There are multiple ways that you can adopt to install ns2. As ns2 runs on the linux. so first you will have to install linux. You can install any distribution of linux fedora, ubuntu etc.

So, one way to do the installation is to first install this software called VMWARE. It creates a virtual machine which allows you to run operating system on another operating system just like any other application. Other ways include by installing Ubuntu direct from website using windows installer. Lets look at the first option.

Install Vmware

Install fedora or any other Linux distribution on VMware. Select ‘New Virtual Machine’ option.


Click Next.

Select Typical.
Select Linux and Ubuntu.

Next …
Select Bridged networking.
You can change the hard disk space availability for your virtual machine based on your needs and available space. Click Finish.

Now, that we have create our virtual machine, let us set some more parameters.

Set RAM that will be available for this virtual machine.


This is the important part. Here you give the path of the ISO image of the ubuntu file by selecting the ‘Use ISO image’ option and giving the path by browsing it as follows.

Now, when you click on the start this virtual machine .
For the very first time, when it loads it will start installation. I have done that already. So, my ubuntu is loading.

You can also use FULL SCREEN mode of virtual machine.

Now, let us install ns2. Download ns2 from the following link.
NS2 Download
It is in zipped folder. You will have to extract it twice. Then,
Go to the ns2 folder and run the install file by applying following command.
. /install
Installation starts. It will take a minute or two.

And it ends. Do not worry about the error messages. It will be fine.


Now, let us set environment variables and set the paths.
Run, command ‘gedit ~/.bashrc’.

Set the following paths. Set the right folder hierarchy according to your own like i have set mine as follows.


Now, if we write ns command and press enter. If we see this % sign, this means that our ns2 installation is successful.
FYI, if you dont see the % sign and instead see some errors, run the following command.
sudo apt-get install ns2 nam xgraph
Provide the password. It will download some packaged online and install ns2.
Now, let us create a file. Write some TCL code and run it. Just for fun :)


Let us write some code.
Now, let us run it as follows.




  1. Hi,

    I was following the tutorial to install ns-allinone-2.35 package on my xubuntos-2.1.4 image (ubuntu 8.04) installed on a vmware virtual machine. I have followed all the mentioned steps but still not getting % on terminal when I type ns after installation. Can you help me out please?


    PS: I changed all the paths according to the my package version and it's location

    1. Just saw your message akshay . Sorry for late reply. You need internet connectivity for the installation because it needs to download some packages online. Please make sure internet is enabled on your virtual machine. Then write

      sudo apt-get install ns2 nam

  2. when i give this command "ns" it produced the following error
    Command not found. Similar command is: 'nc'
    will u plz help me its urgent..

    1. thats the message you get when your ns installation is not complete. You can write the following command and run it.

      sudo apt-get install ns2 nam xgraph
      Provide the password. It will download some packaged online and install ns2.

      You surely need internet connectivity for that. Otherwise, your problem cannot be resolved.

  3. Your simple description on installing NS2 is simply awesome.

  4. IPTradex provides best VoIP calls with Lowest rates.

    For more details:

  5. hey i m using linux instead of ubuntu...so please tell me how to write a trace file in it ...after doing all the installation part


  7. Listen to this funny story of mine:

    I play Natural Selection 2 and I was looking for a tutorial on how to install NS2 server, I blindly and successfully installed ns2 (the one in your article) into a vm running ubuntu and I still have not got Natural Selection 2 server.

    I realised this when your tutorial did not say anything about the next steps of configuring the server !

    Anyways, thank you for the mind stimulation when I did all this.

    1. hahaha .. just hillarious ... thats what happens when u follow it without reading it :)

  8. I followed this tutorial but unfortunately didn't able to succeed. I get "The program 'ns' is currently not installed. You can install it by typing:
    sudo apt-get install ns2".
    When I type sudo apt-get install ns2 nam xgraph I get "Reading package lists... Done
    Building dependency tree
    Reading state information... Done
    E: Unable to locate package ns2
    E: Unable to locate package nam
    E: Unable to locate package xgraph

  9. Hey can i install ns-2.34 in ubuntu on vm-ware?

    1. please answer this....

    2. Hey there,

      once , u install ubuntu on vm-ware . U can do anything that u can do on ubuntu . Its no different . You can easily install ubuntu 2.34 on it ..
      Better would be to download ubuntu 2.34 and then install it manually .

      Rather than installing it using this command .

      sudo apt-get install ns2

      Hope u got ur answer.

    3. thank you very much Usman Ashraf Saab

  10. Thank you very much for the post

  11. This comment has been removed by the author.

  12. I also recommend you to watch this ubuntu installation video.

  13. Wonderful bloggers like yourself who would positively reply encouraged me to be more open and engaging in commenting.So know it's helpful.
    Dot Net Training in Chennai

  14. virtual answering service of Marhaba Reception will help you understand the client even when you are not available. Nobody misses an important call using virtual office receptionist. To know more about it contact us marhabareception.com

  15. i read your content. it's unique and great informative.so please share some more content.
    VMware Course in Gurgaon

  16. Thanks a lot for posting this post, Your post has always been an informative source for me.
    Flat Belts Manufacturers

  17. Really your content is so informative. So please share some more content ..
    VMware course in Noida

  18. This information you provided in the blog that is really unique I love it!! Thanks for sharing such a great blog Keep posting..
    VMware training institute in Delhi