Syed Jahanzaib – Personal Blog to Share Knowledge !

October 19, 2012

Howto mount windows shared folder in Ubuntu

Filed under: Linux Related — Tags: , — Syed Jahanzaib / Pinochio~:) @ 11:00 AM

First create a folder where you want to mount windows folder in. Then mount the target windows shared folder in it using below commands.

mkdir /mnt/winfolder
mount -t cifs //10.0.0.1/share-name /mnt/winfolder -o username=zaib,password=mypassword,domain=mydomain

 

# 10.0.0.1 is Windows System where our required folder is shared

# change the user name , password, and domain as per your local settings.

October 10, 2012

October 8, 2012

SQUID URL Redirection

Filed under: Linux Related — Tags: , , , — Syed Jahanzaib / Pinochio~:) @ 9:11 AM


Following is a method to redirect any URL to another URL. for example if you want that when user opens google.com.pk , he must be redirected to google.com.sa , you can use the following simple PHP redirector to fulfill this requirement.

First Add the redirector location in squid.conf

nano /etc/squid/squid.conf

url_rewrite_program /etc/squid/url_redirect.php
 url_rewrite_children 5

Save & Exit.

Now create the url redirector by

nano /etc/squid/url_redirect.php

#!/usr/bin/php
# Syed Jahanzaib / aacable@hotmail.com / https://aacable.wordpress.com
# Squid URL Rewrite program : Codes picked from the internet.

 <?php
 $temp = array();

 while ( $input = fgets(STDIN) ) {
 // Split the output (space delimited) from squid into an array.
 $temp = split(' ', $input);

 // Set the URL from squid to a temporary holder.
 $output = $temp[0] . "\n";

 // Clean the Requesting IP Address field up.
 $ip = split('/',rtrim($temp[1], "/-"));

 if (preg_match("/^http:\/\/www.google.com.pk/i", $temp[0])) {
 $output = "301:http://www.google.com.sa\n";
 }

 echo $output;
 }

Save & Exit.

Assign execute permission by

chmod +x /etc/squid/url_redirect.php

Now restart / recon squid service and from client end try to open google.com.pk & you will be redirected to google.com.sa transparently :)~

 

Examples:

Before URL Redirection , squid log showed

101.11.11.161 TCP_MISS/200 71205 GET http://www.google.com.pk/ – DIRECT/74.125.236.120 text/html

After URL Redirection, squid log showed

1 101.11.11.161 TCP_MISS/301 309 GET http://www.google.com.pk/ – NONE/-
101.11.11.161 TCP_MISS/200 74892 GET http://www.google.com.sa/ – DIRECT/74.125.236.127 text/html

.

.

.

 

Regard’s
Syed Jahanzaib