Friday, 31 May 2013

How to Install and Configure MRTG on Ubuntu Server 12.04


This post will describe how to install and configure Tobi Oetiker’s MRTG (Multi Router Traffic Grapher) on your Ubuntu home server. Once configured, you’ll be able to use it to monitor the traffic in and out of your home network using the SNMP capability in your network’s gateway\router. MRTG generates static HTML pages containing PNG images which provide a visual representation of this traffic. MRTG typically produces daily, weekly, monthly, and yearly graphs. MRTG is written in perl and works on Unix/Linux as well as Windows. MRTG is free software licensed under the GNU GPL.

Software versions used in this post were as follows:
  • Ubuntu Server v12.04 x64 LTS)
  • mrtg_2.17.3-2ubuntu1_amd64.deb

  • Download and Install

    First, download and install MRTG:
    sudo apt-get install mrtg
    If this is the first time installing MRTG on your server you’ll likely be presented with the following message. Answering “Yes” means that the default configuration file will be installed with permissions set at 640. Answering “No” means that the permissions are set at 644. In this example we’re going to accept the default Yes. No worries though, if you select No the steps in this tutorial will still work.

    Download Offline Installers: Microsoft .NET Framework 4.0, 3.5 SP1, 3.5, 3.0 & 2.0 From Microsoft Servers

    As many of the new Microsoft Windows applications are developed using .NET Framework, it is becoming mandatory to install .NET Framework on our personal computers.

    \
    Microsoft provides .NET Framework installer as a free download available to everyone. But it is an online installer. That means, initially we have to download a small piece of installer and upon starting the installation process the installer automatically connects to Microsoft servers and downloads the required components and completes the installation.
    The online installers works great as long as we have internet connectivity always. But many of us require offline installer to install the software on computers not connected to internet, to save the bandwidth while installing on many computers, etc.

    Sunday, 26 May 2013

    How to Setup Chroot SFTP in Linux (Allow Only SFTP, not SSH)



    If you want to setup an account on your system that will be used only to transfer files (and not to ssh to the system), you should setup SFTP Chroot Jail as explained in this article.
    In a typical sftp scenario (when chroot sftp is not setup), if you use sftp, you can see root’s file as shown below.
    If you want to give sftp access on your system to outside vendors to transfer files, you should not use standard sftp. Instead, you should setup Chroot SFTP Jail as explained below.
    Non-Chroot SFTP Environment
    In the following example (a typical sftp environment), abc can sftp to the system, and view /etc folder and download the files from there.
    # sftp abc@xcessl0gycs.com
    abc@xcessl0gycs's password:
    sftp> pwd
    Remote working directory: /home/abc
    

    Thursday, 23 May 2013

    What’s the Difference Between 127.0.0.0 and 127.0.0.1?



    Sometimes the most elementary of questions yield teachable moments; read on as we delve into how a single digit change between 127.0.0.0 to 127.0.0.1 offers a chance to look at network topology.
    The Question
    What’s the Difference Between 127.0.0.0 and 127.0.0.1?
    I know that both are loopback IPs, but they have another ip mask.
    What’s the difference between them? Can they be used interchangeably?
    ===========================================================================
    
    IPv4 routes
    ===========================================================================
    Active routes:
    Destination               Mask          Gateway        Interface Metric
          0.0.0.0          0.0.0.0      192.168.1.1      192.168.1.6     26
    [...]
        127.0.0.0        255.0.0.0         On-link         127.0.0.1    306
        127.0.0.1  255.255.255.255         On-link         127.0.0.1    306
    What kind of information can we tease out from this table?

    Tuesday, 14 May 2013

    20+ .htaccess Hacks Every Web Developer Should Know About


    Apache's .htaccess(hypertext access) configuration file can be a very powerful tool in a web developer's toolkit if used properly. It can be found in the webroot of your server and can be easily edited using any text editor. In this article I'm going to show you 20 .htaccess hacks and how to use them.
    Before I start with this article I'd like to start by saying that abusing the .htaccess file will hurt the performance of your website. The .htaccess file should only be used if you have no other way to achieve certain things.
    Make sure to back up your current .htaccess file before applying any of the following hacks.

    1. Prevent Hotlinking

    Tired of people using your bandwidth by putting the images hosted on your server on their website? Add the following code at the bottom of your .htaccess file to prevent hotlinking.
    1Options +FollowSymlinks
    2#Protect against hotlinking
    3RewriteEngine On
    4RewriteCond %{HTTP_REFERER} !^$
    5RewriteCond %{HTTP_REFERER} !^http://(www.)?domainname.com/ [nc]
    6RewriteRule .*.(gif|jpg|png)$http://domainname.com/img/stop_stealing_bandwidth.gif[nc]
    NOTE: The following article explains better methods to "prevent" hotlinking:
    Link building secrets by Maurizio Petrone

    Monday, 6 May 2013

    How to check what we have Installed in Debuian/Ubuntu OS


    To check what have install by listing all using dpkg is easy.
    dpkg -l
    To check whether a package is install also easy.
    dpkg -l | grep apache
    The command above is some how redundant, because dpkg support wild characters, doing this instead
    dpkg -l "apache*"
    By doing this, it will also list the package that not install but available in dpkg cache, to install them you can simply apt-get. To indicate the packages installed it shows “ii” and not install shows “un”.

    Shell Script File for Checking Package Installed or not Or If not then Install Package - For Ubuntu OS

    Dpkg: check that unix package is installed. Bash script: install package if not present

    dpkg -s can be used.
    Example: is vlc installed?
    > dpkg -s vlc|grep installed
    Here is some logic in bash script, like installing package if it is not there:
    1
    2
    3
    4
    5
    6
    
    problem=$(dpkg -s vlc|grep installed)
     echo Checking for libxul: $problem
     if [ "" == "$problem" ]; then
          echo "No libxul. Setting up libxul"
          sudo apt-get --force-yes --yes install vlc
     fi