Wednesday, October 17, 2012

Lazy DHCP pool configuration on Cisco IOS

To add a DHCP server to your router you can add these lines on terminal configuration mode:

ip dhcp excluded-address <address start> <address end>
!
ip dhcp pool <pool name>
   network <network> <netmask>
   default-router <router IP>
   dns-server <DNS1> <DNS2>


i.e:

gw#config t
Enter configuration commands, one per line.  End with CNTL/Z.
gw(config)#ip dhcp excluded-address 10.2.17.1 10.2.17.15

gw(config)#ip dhcp pool MyOffice                  #network 10.2.17.0 255.255.255.0
             
#default-router 10.2.17.1
             
#dns-server 10.2.17.201 


Lazy batch resize of jpeg pictures using ImageMagick

The suite ImageMagick provides a tool called convert that will help us to do the trick.

-rwx------ 1 amartin amartin 1.3M Oct 17 14:00 IMAG0315.jpg
$ convert IMAG0315.jpg -density 36 -geometry 40x40% IMAG0315.jpeg
$ ls -lh IMAG0315.jpeg
-rw-r--r-- 1 amartin amartin 301K Oct 17 14:00 resize/IMAG0315.jpeg

If we want to reside a batch of files, whiting the same directory, we can use the following command to convert all the .jpg files to reduces .jpeg:

$ for file in `ls -1 *.jpg| cut -d '.' -f 1`; do convert $file.jpg -density 36 -geometry 40x40% $file.jpeg; done

Lazy install of flash player on Firefox and Chrome on Debian

To install the plugin we download it from Adobe and place it on our downloads folder. We will use the .tar.gz file format.

The file contains this structure:

$ tar -xvzf install_flash_player_11_linux_x86_64.tar.gz
libflashplayer.so
readme.txt
usr/
usr/bin/
usr/bin/flash-player-properties
usr/share/
usr/share/pixmaps/
usr/share/pixmaps/flash-player-properties.png
usr/share/kde4/
usr/share/kde4/services/
usr/share/kde4/services/kcm_adobe_flash_player.desktop
usr/share/applications/
usr/share/applications/flash-player-properties.desktop
usr/share/icons/
usr/share/icons/hicolor/
usr/share/icons/hicolor/32x32/
usr/share/icons/hicolor/32x32/apps/
usr/share/icons/hicolor/32x32/apps/flash-player-properties.png
usr/share/icons/hicolor/22x22/
usr/share/icons/hicolor/22x22/apps/
usr/share/icons/hicolor/22x22/apps/flash-player-properties.png
usr/share/icons/hicolor/24x24/
usr/share/icons/hicolor/24x24/apps/
usr/share/icons/hicolor/24x24/apps/flash-player-properties.png
usr/share/icons/hicolor/16x16/
usr/share/icons/hicolor/16x16/apps/
usr/share/icons/hicolor/16x16/apps/flash-player-properties.png
usr/share/icons/hicolor/48x48/
usr/share/icons/hicolor/48x48/apps/
usr/share/icons/hicolor/48x48/apps/flash-player-properties.png
usr/lib/
usr/lib/kde4/
usr/lib/kde4/kcm_adobe_flash_player.so
usr/lib64/
usr/lib64/kde4/
usr/lib64/kde4/kcm_adobe_flash_player.so


As root, we will excecute this command to install the files:

root# tar -xvzf install_flash_player_11_linux_x86_64.tar.gz -C /

The plugins must be located at /usr/lib/mozilla/plugins, we will check first if there's an old plugin to deactivate:

 /usr/lib/mozilla/plugins# ls -l
total 76
drwxr-xr-x 2 root root    69 Sep 25 12:42 ./
drwxr-xr-x 4 root root    37 Mar 18  2012 ../
lrwxrwxrwx 1 root root    34 Sep 25 12:42 flash-mozilla.so -> /etc/alternatives/flash-mozilla.so
lrwxrwxrwx 1 root root    37 Apr  9  2012 libnpjp2.so -> /usr/local/java/lib/amd64/libnpjp2.so
-rw-r--r-- 1 root root 75448 May 17  2011 skypebuttons.so



There's the bundled flash enabled... we will remove the symlink to disable it.

/usr/lib/mozilla/plugins# rm flash-mozilla.so
rm: remove symbolic link `flash-mozilla.so'? y



Then we copy over the plugin and delete trash from the installation:


/usr/lib/mozilla/plugins# mv /libflashplayer.so .
/usr/lib/mozilla/plugins# rm /readme.txt

And we confirm the permissions will allow our user to read the plugin:

 -rw-rw-r-- 1  501  501 19223376 Sep 29 12:13 libflashplayer.so

Now we can go to youtube.com and check out the latest videos to test our plugin.

Note: You might want to disable the PepperFlash version of Chrome and use only the one from adobe, here's how:

 

Thursday, July 26, 2012

Lazy certificate import for Cisco SSL VPN engine

We'll consider our vpn gateway as sgvpn.mydomain.com, our webvpn gateway sggateway and the external address 165.21.250.150. Our certificate we will suppose has been encoded as PKCS12, named sgvpn-full.pfx in the example:

sing-gw1(config)#crypto pki trustpoint SGVPN

sing-gw1(ca-trustpoint)# fqdn sgvpn.mydomain.com


sing-gw1(ca-trustpoint)# revocation-check crl


sing-gw1(ca-trustpoint)# rsakeypair SGVPN


sing-gw1(ca-trustpoint)#^Z


sing-gw1(config)#crypto ca import SGVPN pkcs12 ftp://myftpaccount:mypassword@myftpipaddress/sgvpn-full.pfx My_Certificate_Password

Now we are ready to add the trust point to our webvpn:

sing-gw1(config)#webvpn gateway sggateway

sing-gw1(webvpn)# ip address 165.21.250.150 port 443

sing-gw1(webvpn)# http-redirect port 80

sing-gw1(webvpn)# ssl trustpoint SGVPN

sing-gw1(webvpn)# logging enable

sing-gw1(webvpn)# inservice

sing-gw1(webvpn)# end


Our webvpn node should be ready to use the new certificate. In case our provider doesn't provide a PKCS12 we can easily transform it using the windows certificates snap-in:

First thing, import the certificate in your system - double click on the certificate, enter the password and automatically select the certificate store location.

After that, locate your certificate in your system - I did import mine in my personal account, your's may vary:


We right click on the certificate, all tasks, export:


We follow the wizard:


We select export the private key:


We need to include all the certificates, and extended properties:


We type our new password (the one we will enter in the command line in the router):


We select a secure place for our certificate:


Click on Finish, and the certificate will be ready to be imported.





Monday, April 9, 2012

Lazy setup java plugin for Firefox on Debian amd64

In order to get it working we need to:

  1. Install Iceweasel from our debian repository: sudo apt-get install iceweasel
  2. Download the last java 64 bits from http://www.java.com/
  3. Install Java accordingly to the instructions provided by the vendor (normally /usr/local/<your_java_directory> and create a sym link to java folder)
  4. Since we are using the new java plugin (libnpjp2.so), we need to create a symb link into the plugins folder: ln -s /usr/local/<your_java_directory>/lib/amd64/libnpjp2.so /usr/lib/mozilla/plugins/ don't try to copy the plugin or you will get an error like "InitializeJVM: Assertion `foundJVM' failed"
  5. Start iceweasel and test the plugin
I managed to get some problems with Java regarding to network configuration - it was trying to use IPV6. Since I don't use Java at all, I disabled the ipv6 from my system editing the file /etc/sysctl.conf adding the line net.ipv6.conf.all.disable_ipv6=1, after that executing sysctl -p made the change effective (alternatively, you can modify Java parameters to disable IPV6 only on it).