Add a custom script in Unity HUD

Here is how to add a custom script in Unity HUD/dash for quick access. /usr/share/applications directory has all shortcuts for Unity desktop. So create a file named “mycustomscript.desktop” (or any_name_you_like.desktop) there which has information about the custom script. Additionally an icon could be added by pointing to an image. Files in /usr/share/applications directory have to be created as root.

 [Desktop Entry]
 Version=1.0
 Type=Application
 Terminal=false
 StartupNotify=true
 Icon=/home/vishalj/Pictures/mycustomscript.jpeg
 Name=MyCustomScript
 Comment=My Custom Script for X, Y and Z
 Exec=/home/vishalj/scripts/mycustomscript.sh
 Categories=Application;Productivity
 

Then run sudo update-desktop-database after which you will be able to use Unity HUD for invoking the custom script. Also note that each time you update a .desktop file you have to run update-desktop-database.

vpn : Split Tunnel Concept

Once a user starts a vpn client to connect to company extranet, all network traffic is diverted to the vpn tunnel. Routing gets setup by VPN client such that everything would go down the tunnel. Split tunnel can fix that by keeping traffic for internet from tunnel and only direct extranet traffic to the tunnel. But it comes with few risks on its own. Lets review the concept for a minute.

The VPN tunnel can be configured to work in two modes.

  1. Mandatory (default)
    While a client tunnel is established in mandatory mode, all client traffic is tunneled through it by default. This is the default vpn mode. So accessing yahoo.com will go through vpn tunnel to company extranet which will then route it via its own internet connection after applying access policy etc.
  2. Split Tunneled mode
    Split Tunneling allows configuring specific network routes that are then tunneled and sent to the client’s Extranet adapter; any other traffic goes to the local PC Ethernet or Dialup adapter interface. So Split tunneling allows the user to get access to the Internet or print locally even while the system is tunneled into the company Extranet. But this comes with a security issue because it opens a backdoor into the secure office network from internet via the home system. A hacker can exploit the home system and can use that as a jump box to get into the company network. Or if the system at home is infected it will further that infection into office network. That is why organizations want vpn users to ensure they are up to date and have anti-virus installed and most will provide vpn clients that are tightly controlled to enable the Default mode. Continue reading

xming : Client 4 rejected from IP

If you are getting following error in xming log:

Xming.exe: client 4 rejected from IP XXX.XXX.XXX.XXX

Here are two solutions.

  1. Secure method: Edit: X0.hosts (in the installation directory) and add the ip you want allow. e.g.
    localhost
    XXX.XXX.XXX.XXX
    

    Restart Xming.

  2. Insecure method: Add the “-ac” option to the Xming desktop shortcut. Modify the Desktop Xming shortcut to include the arguments: “:0 -clipboard -multiwindow -ac”. The ac option accepts client requests and quells the error above. Start Xming using the shortcut you just created. Warning: This is same as “xhost +” which will grant anyone access. So only use Xming option -ac or “xhost +” on trusted networks, never on public ones. OR use the solution 1 of additing IP address of known systems on which you will be running X applications..

VPN : Connecting to Nortel VPN from Linux

I moved to Ubuntu full-time a while back. See the first part Migrating from Windows to Linux. But VPN into my office from Linux remained an open issue because my organization uses Nortel Contivity. Ubuntu comes with vpn client but that does not work with Nortel. Then I found vpnc-nortel branch of vpnc open source project that can connect to Nortel vpn servers. In this series I will explain how to connect to Nortel VPN from Ubuntu. You may need to tweak few of these instructions for your favourite Linux version. I am on Ubuntu 11.10 x86_64, using vpnc version 0.5.3-481.

Continue reading

Migrating from Windows to Linux

What would one need to move off of Windows in corporate world? A replacement for Microsoft Office Suit. Linux has LibreOffice as replacement for MS Word, Excel, Power Point etc. If you are a power user of these tools then it will be difficult to migrate to LibreOffice but hey that is a start. If for Outlook, your organization provides access via WebMail interface, then you are in clear with using any email client on Linux that supports Pop or IMAP by making use of DavMail. Though Evolution support a direct access to WebMail or even MAPI, but Evolution itself is very thick and sometimes slow. Then came out Ubuntu 11.10 which provides Thunderbird as the default email client with integration to desktop and Unity. Perfect.

Here is the list of replacements that are available on Linux. I will cover setup for DavMail and Thunderbird in another post. Continue reading

bash : grep for pattern from certain location in the file

Syntax for grep to search for a pattern in a file is very well-known. But there are times when one has to grep for the pattern from a certain location or after a certain offset in the file. For example if we are searching for a pattern in a log file which could appear multiple times. Each time we grep, it will provide us all the matching lines from top to bottom of the file and then we have to find which lines were new since our last run. Using dd, the file can be sliced and then grep can be applied for the pattern on that slice. Lets see an example. Continue reading

dilbert : Working from home

So my boss would not let me work from  home. And then I had the rude awakening when I found the reason behind the whole concept of working in office!

Dilbert Work from Home

Go to the main site by clicking the image and you can read comments by others. I specifically would like to quote one from kattywumpus.

A third form were all possible distractions must be documented, do you have a Dog, how close is the nearest coffee shop, and etc..

snmp : find network information of a system centrally

Anyone can login to a system and run ifconfig or netstat or other similar commands to find the network information of a system. But what will be even better? Do it remotely without logging in to each and every system. How? Using snmpwalk one can retrieve all this information provided that subject has both snmpd running, snmpd supporting network information and the querying host is allowed to make SNMP queries. Lets see how.

Interface table is covered by basic SNMP (just like system information, udp, tcp  socket information, address translation and snmp stats etc). Here is how to query the interface table to get the IP address and Subnet mask information.

unixite@sanbox:~/ > snmpwalk -v1 -c public sandboxS:161 1.3.6.1.2.1.4.20.1.1
iso.3.6.1.2.1.4.20.1.1.1.2.3.4 = IpAddress: 1.2.3.4
iso.3.6.1.2.1.4.20.1.1.127.0.0.1 = IpAddress: 127.0.0.1
iso.3.6.1.2.1.4.20.1.1.192.168.1.10 = IpAddress: 192.168.1.10
iso.3.6.1.2.1.4.20.1.1.10.0.0.2 = IpAddress: 10.0.0.2
unixite@sanbox:~/ > snmpwalk -v1 -c public sandboxS:161 1.3.6.1.2.1.4.20.1.3
iso.3.6.1.2.1.4.20.1.3.1.2.3.4 = IpAddress: 255.0.0.0
iso.3.6.1.2.1.4.20.1.3.127.0.0.1 = IpAddress: 255.0.0.0
iso.3.6.1.2.1.4.20.1.3.192.168.1.10 = IpAddress: 255.255.255.0
iso.3.6.1.2.1.4.20.1.3.10.0.0.2 = IpAddress: 255.255.0.0

First one here retrieves the IP addresses on the system while second one get the subnet masks. -c public has to be changed to right community string and also the version if your supports a different one. My system name here is sandboxS and snmpd is listening on default port 161. If not then you can change the port to match yours.

php : find if IP address is in Network range

Using pear Net_IPv4 module one can find if a given IP address is in provided Network range or on the subnet.

<?php
        // check if IP falls in provided subnet
        include("Net/IPv4.php");

        $ipAddr  = "192.168.1.8";
        $netAddr = "192.168.1.0/29"; // 192.168.1.0 - 192.168.1.7

        $objIP = new Net_IPv4();

        echo $objIP->ipInNetwork($ipAddr, $netAddr) ? "$ipAddr is in $netAddrn" : "$ipAddr is not in $netAddrn";
?>

This requires pear Net_IPv4 module which can be installing in one of the following ways.

pear install Net_IPv4
php pyrus.phar install pear/Net_IPv4