Syed Jahanzaib Personal Blog to Share Knowledge !

August 26, 2013

Mystry of ethernet not appearing in Ubuntu under VM after mac change

Filed under: Linux Related, VMware Related — Tags: — Syed Jahanzaib / Pinochio~:) @ 8:41 AM

Ubuntu

Recently I was doing an remote installation of Ubuntu Server as a guest VM in ESXI 5.1 in INDIA/PUNE. It was OS requirement to change the default dynamic mac created by VM to some other fixed mac address because of an application requirement which was bind with the specific mac address. After changing mac address to required mac address e.g: 00:0h:c1:96:1c:98 via esxi client in guest vm networking properties , when I rebooted Ubuntu, the Ethernet adapter didn’t not appeared in the networking interfaces list.If i manualy try to bring up the interface by ifconfig eth0 up or ifconfig eth1 up , I receive following error.

SIOCSIFADDR: no such device
eth0: ERROR while getting interface flags: No such device
Bind socket to interface: no such device
Failed to bring up eth0

When I revert it to default (dynamic) it works ok.

After investigating deeply, it revealed that it occurred because if we clone a virtual machine , it creates a new MAC address for each network adapter. The guest operating system detects this is a new network adapter that has been inserted, but retains configuration for the previous network adapter (name and mac).

So here is how I fixed it.

Login to your Ubuntu server (which is installed under vm) with root access ,

Open the file /etc/udev/rules.d/70-persistent-net.rules in nano.

nano /etc/udev/rules.d/70-persistent-net.rules


You will see something like below . . . (After cloning of mac)

# This file was automatically generated by the /lib/udev/write_net_rules
# program, run by the persistent-net-generator.rules rules file.
# You can modify it, as long as you keep each rule on a single
# line, and change only the value of the NAME= key.

# PCI device 0x1022:0x2000 (pcnet32)  # Entry Ethernet adapter before cloning
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:11:3b:6a:8c", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"

# PCI device 0x1022:0x2000 (pcnet32)  # Entry Ethernet adapter after cloning
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0h:c1:96:1c:98", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"

.

Now simply remove the first entry which is old interface entry with mac 00:0c:11:3b:6a:8c,

and in second entry which is eth1, change it to eth0

so after editing the file will look like following.

# This file was automatically generated by the /lib/udev/write_net_rules
# program, run by the persistent-net-generator.rules rules file.
# You can modify it, as long as you keep each rule on a single
# line, and change only the value of the NAME= key.
# Syed Jahanzaib . aacable@hotmai.com . https://aacable.wordpress.com

# PCI device 0x1022:0x2000 (pcnet32)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0h:c1:96:1c:98", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"

Save the file and and exit.

Now simply reboot the Ubuntu server, and then check your interface by

ifconfig

Hopefully it will appear in the list.

.

TIP: To avoid such issues, always change the mac address before OS installation :)~  / Zaib

.

Regard’s
Syed Jahanzaib

August 23, 2013

Lotus Notes wants to open some emails with browser, rather than within Notes itself !

Filed under: IBM Related — Tags: — Syed Jahanzaib / Pinochio~:) @ 4:27 PM

lotus

Today, One of our user faced problem that when he tried to open certain emails , it gives option to open it in my web browser, rather than within Notes itself. it showed all of the html formatting characters in the notes, rendering it almost unreadable. I applied fresh install of Notes but no use. The client was using Lotus notes 8.5.2

This is how I solved it.

Open Lotus Notes Client

Goto Files / Preferences

In the right window, click on ADDITION OPTIONS, Tick on DISABLE EMBEDDED BROWSER FOR MIME FORMAT

As showed in the example below , , ,

lotus-disable-embedded

 

 

Now restart Notes Client, and the problem solved 🙂

 

Regard’s

Syed Jahanzaib

Lotus Notes: Field: ‘tmpRepeatsText’: Array index out of bound while opening TO DO

Filed under: IBM Related — Tags: , , — Syed Jahanzaib / Pinochio~:) @ 4:15 PM

One of our Lotus notes users received following error while opening TO DO mail

Field: ‘tmpRepeatsText’: Array index out of bound

lotus-to-do-error

 

I fixed it by using

load convert mail\[maildatabase] * mail85.ntf

 

Regard’s
Syed Jahanzaib

Short References / Notes For UBUNTU / Mysql and Squid


♥♥♥   My Love Is For Ubuntu   ♥♥♥

By

♥♥♥   Syed Jahanzaib   ♥♥♥

LINUX RELATED: [UBUNTU]


Find and Delete ZERO SIZE FILES

(in folder name /var/log/mikrotik)

find /var/log/mikrotik/ -name 'mikrotik*' -size 0 -print0 | xargs -0 rm

MYSQL SERVICE & DB Check by bash

#!/bin/bash
# 20-Jun-2016
# Syed Jahanzaib
# https://aacable.wordpress.com aacable at hotmail dot com
#set -x
SQLUSER="root"
SQLPASS="zaib1234"
TMPFILE="/tmp/simupdate.txt"
VALUE="2"
DB="radius"
SRV="mysql"
# Check if $SRV (in this case mysql) is running or not, if NOT, then exit the script
SRVSTATUS=$(pgrep $SRV | wc -l);
if [ "$SRVSTATUS" -ne 1 ];
then
echo "-$SRV is down. Pleasec check your $srv service first.
Exiting ...";
exit 1
else
echo "-$SRV is accessible OK. Proceeding further ..."
fi

# Check if $DB (in this case radius ) is accessible or not, if NOT, then exit the script
RESULT=`mysql -u $SQLUSER -p$SQLPASS --skip-column-names -e "SHOW DATABASES LIKE '$DB'"`
if [ "$RESULT" == "$DB" ]; then
echo "-$DB database exist OK. Proceeding further ..."
else
echo "-$DB database does not exist!"
exit 1
fi

BASH VARIABLE TESTS

In Bash you quite often need to check to see if a variable has been set or has a value other than an empty string. This can be done using the -n or -z string comparison operators.

The -n operator checks whether the string is not null. Effectively, this will return true for every case except where the string contains no characters. ie:

VAR="hello"
if [ -n "$VAR" ]; then
echo "VAR is not empty"
fi

Similarly, the -z operator checks whether the string is null. ie:

VAR=""
if [ -z "$VAR" ]; then
echo "VAR is empty"
fi

Note the spaces


Date Time Functions

DATE=`date`
TODAY=$(date +”%Y-%m-%d”)
TODAYDIGIT=`echo $TODAY  | sed -e ‘s/-//g’`
MONTH=$(date +”-%m”)
CMONTH=`echo $MONTH  | sed -e ‘s/-//g’`
MONTHYEAR=$(date +”%B-%Y”)
ALPHAMONTHYEAR=`echo $MONTHYEAR #| sed -e ‘s/-//g’`
ONEMONTHBACK=$(date +%Y-%m-%d  -d “1 months ago”)


Using SED to remove empty lines from a file

sed -i '/^\s*$/d' /temp/test.sh

Using SED to remove brackets in line/file

to remove bracket from text
like we want to remove brackets from following

[test]

echo '[test]' | sed 's/\(\[\|\]\)//g'

Example:

cat /tmp/test.txt | awk '{print $2}' | sed 's/\(\[\|\]\)//g' | sed 's#/#\ #g'

Using SED to remove word with special characters.

Remove word with special characters in file by cat and sed

Example: Contents of file name file.txt are

/temp/fullbackup.tar.gz

and now we want to remove /temp/ word only. here how to do it.


cat file.txt | sed -e 's/\/temp\///'


Add User in Ubuntu and grant SUDO (admin rights)


sudo useradd -m -p zaib1234 zaib
sudo useradd zaib sudo

 


 Installing phpmyadmin

 sudo apt-get install phpmyadmin apache2-utils


 

Howto Enable MYSQL remote connectivity

Connect to mysql shell and issue issue these commands

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'root';

FLUSH PRIVILEGES;

and on new version of mysql  use

GRANT ALL ON *.* TO 'root'@'%' IDENTIFIED BY 'root';

FLUSH PRIVILEGES;

Also From /etc/mysql/my.cnf

Comment this line:

#bind-address  = 127.0.0.1

Then run

service mysql restart

 


How to reset USB device like usb modem without PLUG/UNPLUG physically

The following script will help you in resetting USB device (without physically unplug/plug). It was very useful for me in one case where server was remotely located and no one was physically present there to plug/unplug DLINK USB GSM modem which hangs frequently. So as a short term solution i created an script which first check for USB BUS, then using usbreset it simply reset that usb device. I scheduled it on hourly basis and it worked very good.

resetusb.sh

cat resetusb.sh
USBBUS1=`lsusb | grep D-Link | awk '{print $2}'`
USBBUS2=`lsusb | grep D-Link | awk '{print $4}' |  sed 's/://'`

echo -e "USB Bus1 = $USBBUS1"
echo -e "USB Bus2 = $USBBUS2"

/temp/usbreset /dev/bus/usb/$USBBUS1/$USBBUS2

# Playsmsd restart so that if its in stuck position it should come ALIVE again ; ) : ) zaib
echo playsmsd restart | at now + 1 min

You can create usbreset program from following this url.

http://askubuntu.com/questions/645/how-do-you-reset-a-usb-device-from-the-command-line

OR another link which I have not tested so far..

http://davidjb.com/blog/2012/06/restartreset-usb-in-ubuntu-12-04-without-rebooting/

 


 

How to run script every x minute via CRON Job

Edit cron jobs by

crontab -e

then add your script by using

# To run script every one minute
* * * * * /path/your_script.sh

# To run script after FIVE minutes [Example MRTG command with logs]
*/5 * * * *  /etc/myscript.sh

# OR [Example MRTG command with logs]
*/5 * * * * env LANG=C mrtg /etc/mrtg.cfg --logging /var/log/mrtg.log

# Run Script at at 5:00pm Daily
00 17 * * * /temp/sms.sh

# Run in night at 00:00 hours to send notifications to users whose account have been expired today.
@daily /temp/script.sh

# Run Script after every hour
@daily /temp/script.sh

# Run script on reboot 
@reboot /temp/rebootscript.sh

How to set Date/Time via CLI on Ubuntu / Linux

If you want to set date and time on Ubuntu box via command/CLI and sync to hardware Bios. use following

sudo date --set="3 OCT 2014 15:54:00"
sudo hwclock --systohc --utc

 

How to configure / add IP address in UBUNTU via CLI / Command

Sometimes it is required to configure interface card by CLI (command line interface) , for example if you are doing any configuration on remote server via putty, and you want to configure another interface on that server, OR if you are using server edition of ubuntu which dont have GUI, then you will have to do it via CLI.

Configuring a static IP from the command line is a very short task. All you need to edit is one configuration file and restart the networking service.
All you need to know is the settings for your network.

I will show how to set a static IP of <strong>192.168.2.2</strong> on a network with a gateway and dns of <strong>192.168.2.1</strong>

Open the configuration file in your favorite editor (mine is nano)

Open terminal and type the following command:

nano /etc/network/interfaces

.
Remove previous entries for your ethernet (for example eth0 section only)
.
Add a section as showed in the following example:

# Adding static ip for eth0 / Syed jahanzaib
auto eth0
iface eth0 inet static
address 192.168.5.2
netmask 255.255.255.0
network 192.168.5.0 # You can disable this line
broadcast 192.168.5.255 # You can disable this line
gateway 192.168.5.1 # You can disable this if you dont have any gateway - or if its a test lab rat :p
dns-nameservers 192.168.5.1

Save & Exit the file.
Now Restart the network service

/etc/init.d/networking restart

You can now verify your new ip by

ifconfig eth0

 

HOWTO CHANGE MAC ADDRESS FROM CLI / Command

sudo ifconfig eth0 down
sudo ifconfig eth0 hw ether 00:12:34:BL:AA:AH
sudo ifconfig eth0 up
# if apache is running, dont forget to restart it so it can take new mac, useful in some scenarios
# service apache2 restart

 

HOWTO  DELETE  FILES  OLDER  THEN  ‘X’  DAYS …


find /path/to/files* -mtime +5 -exec rm {} \;


 

To Clear Linux Console History

history -c 
history -w

First command clears the history, and the second writes the now (empty) history file.


 

Find what application/process is using the port

type:

sudo netstat -lpn |grep :8080

and press Enter.

You will get an output similar to this one

tcp6       0      0 :::8080                 :::*                    LISTEN      6782/java

I have got the process Id, which is 6782, now this is the process that is using port 8080.

Kill the process, type:

kill 6782
fuser -n tcp 8080

lsof -w -n -i tcp:8080

netstat | grep 8080

$ sudo -i
$ netstat -tulpn

 

PHP prompts to save file in Apache2

If you open any php file hosted on your linux base system, and it give syou option to OPEN/SAVE rather then displaying content, then install following

sudo apt-get install libapache2-mod-php5
sudo a2enmod php5
sudo /etc/init.d/apache2 restart

 

Test USB port functionality


root@radius:~# cat /temp/testusb.sh
## Search for a working USB port (/dev/ttyUSB)

work=false
for port in /dev/ttyUSB*
do
[[ -e $port ]] || continue
gcom -d $port info &> /tmp/testusb
testUSB=`cat /tmp/testusb | grep "Error\|Can't"`
if [ -z "$testUSB" ]; then
work=$port
break
fi
done
rm -rf /tmp/testusb

if [ $work != false ]; then
echo "$work is working!"
else
echo 'Not found a working USB port'
fi


 

To restart Networking , issue the following command.

To restart Networking services to apply changes you made with your interfaces , issue the following command.

/etc/init.d/networking stop
/etc/init.d/networking start

OR

/etc/init.d/networking restart

OR some other commands for the same

sudo initctl restart network-manager
sudo initctl restart network-interface INTERFACE=eth0

OR

sudo ifconfig eth0 down
sudo ifconfig eth0 up

Static Route lost when ethernet cable unplug/plug [8th-MAR-2016] for UBUNTU 12.x

It is observed that if you have made static route in ubuntu 12.x, they get lost when ethernet cable unplug/plug. to make the persistent on boot/unplug+plug situation, use following.


# The primary network interface

auto eth1

iface eth1 inet static

address 192.168.101.20

netmask 255.255.255.0

dns-nameservers 192.168.100.2

#ROUTE 1 static

up route add -net 10.0.0.0/8 gw 192.168.101.10 dev eth1

#ROUTE 2 static

up route add -net 172.0.0.0/8 gw 192.168.101.10 dev eth1


 

Howto to ADD / DELETE Route

Adding default Gateway

route add default gw 192.168.2.1 dev eth1

Deleting all default Gateways

ip route del default

Add Route for Local Network using Gateway

route add -net 172.16.0.0 netmask 255.255.0.0 gw 192.168.2.1 dev eth0

Delete Route …

route del -net 172.16.0.0 netmask 255.255.0.0 gw 192.168.2.1 dev eth0

 

Ubuntu / Debian Linux: Services Configuration Tool to Start / Stop System Services

apt-get install sysv-rc-conf

then run sysv-rc-conf


 

Howto disable ipv6 in ubuntu.  [12.4]

First edit sysctl.conf file in any editor , e.g:

nano /etc/sysctl.conf

and add following lines in the end

# IPv6
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
net.ipv6.conf.lo.disable_ipv6 = 1

OR

use following to add them directly to file using echo command

echo >> /etc/sysctl.conf  net.ipv6.conf.all.disable_ipv6 = 1
echo >> /etc/sysctl.conf net.ipv6.conf.default.disable_ipv6 = 1
echo >> /etc/sysctl.conf net.ipv6.conf.lo.disable_ipv6 = 1


Save and Exit and execute following to activate changes 🙂

sysctl -p

 

HOWTO change default text EDITOR in CLI useful for Ubuntu 13 crontab)

export EDITOR=/usr/bin/nano

 

HOWTO INSTALL WEBMIN ON YOUR UBUNTU BOX:

I assumed that you have installed and configure your Linux box (preferably Ubuntu, but any flavor can do the job, this is the main quality of Linux OS 🙂 ~
To install Webmin , first add its repositories to sources.list, to do this first open sources.list

nano /etc/apt/sources.list

Now paste the following lines in the end of this file.

deb http://download.webmin.com/download/repository sarge contrib
deb http://webmin.mirror.somersettechsolutions.co.uk/repository sarge contrib
deb http://archive.canonical.com/ lucid partner

Save & Exit.

OR add them via echo command

echo >> /etc/apt/sources.list deb http://download.webmin.com/download/repository sarge contrib
echo >> /etc/apt/sources.list deb http://webmin.mirror.somersettechsolutions.co.uk/repository sarge contrib
echo >> /etc/apt/sources.list deb http://archive.canonical.com/ lucid partner

Save & Exit.

Now update apt-get and install webmin using

apt-get update
apt-get install webmin

It will take some time to install webmin depend on your internet connection (usually less then 10 minutes) , afterward you can access it using

https://yourlinuxboxip:10000

(TIP: you can change the webmin port by editing in /etc/webmin/miniserv.conf and change the port number to any port you like, for example 443 or 1234)


 

IPTABLES Related:

To view IPTABLES rules, use following

iptables -L
iptables -t nat -L

==============================

To clear all iptables rules, use following

iptables -F
iptables -X
iptables -t nat -F
iptables -t nat -X
iptables -t mangle -F
iptables -t mangle -X

==============================

To Block Ip RANGE from accessing your linux box (in INPUT chain)

iptables -A INPUT -m iprange --src-range 1.2.3.4-5.6.7.8 -p tcp --dport 8080 -j DROP

To Block Single Ip from accessing your linux box (in INPUT chain)

iptables -A INPUT --src 1.2.3.4 -j DROP

To Block Single Ip from accessing SSH port 22 of your linux box (in INPUT chain)

iptables -A INPUT --src 1.2.3.4 -p tcp --dport 22 -j DROP

To Block all users from accessing SSH port 22 of your linux box (in INPUT chain)

iptables -A INPUT -p tcp --dport 22 -j DROP

DNAT port 80 request coming from LAN systems to squid 8080 ($SQUID_PORT) , This is to make your squid as transparent proxy

iptables -t nat -A PREROUTING -i LAN_Interface -p tcp --dport 80 -j DNAT --to SQUID_IP:PORT

==============================


 

To Delete single iptables rule via number or name

iptables -vnL –line-numbers
iptables -L INPUT –line-numbers
iptables -D INPUT 4

 

Using Putty from Shortcut to login to remote linux server without password [Jz]

To login to remote Linux server using PUTTY with out password, you can use public keys or quick way is to use shortcut trick. Not recommended if your system is not secure or used by other people,
For example:

C:\temp\putty.exe -ssh root@192.168.1.1 -pw yourpassword

TIP: Change the C:\temp to match your folder where putty.exe is available.

To login from Mikrotik to linux and Linux to Linux, read the below . . .

https://aacable.wordpress.com/2011/11/25/howto-login-on-remote-mikrotik-linux-without-password-to-execute-commands/


 

Bandwidth Monitoring tool for Ethernet Interface [Jz]

There are plenty of tools to do the task, I found bwm-ng the quickest 🙂
To install it on DEBIAN/UBUNTU , use

apt-get install bwm-ng

To install it on FEDORA / CENTOS, use

yum -y install bwm-ng

To run it , type

bwm-ng

Use following shortcut to tune bwm-ng

Press + to set time interval, default is set to 0.5 seconds which is too short, make it at least 1.00 or 1.1 to get mroe stable value.

Press u to get DATA in kb (kilobits), default is set to KB (Kilo Bytes)

To see data of eth0, with kilobits, and 1 second refresh rate , use following . . .

bwm-ng +I eth0 -u bits -t 1000


 

SQUID LOGS & Others[Jz]

To view SQUID access logs for all users, use

tail -f /var/log/squid/access.log

To view SQUID access logs for CACHE HIT

tail -f /var/log/squid/access.log |grep HIT

To view SQUID access logs for specific user ip, use

tail -f /var/log/squid/access.log |grep 192.168.1.20

To view SQUID process

ps aux |grep squid
ps aux |grep storeurl.pl # if you have url rewrite program configured like for youtube caching

Start SQUID in diagnostic mode (no daemon mode)

If you have some problems in your squid config and its not starting, then start squid in debug mode,
use following command

squid -d1N

it will start in no daemon mode and will show you details and errors if any.

BLOCK WEB SITES IN SQUID [HTTPS SUPPORT TOO]

Add in squid.conf and reload squid


acl fb dstdomain .facebook.com
http_access deny CONNECT fb all
acl badsites dstdomain .us.il.yimg.com .msg.yahoo.com .pager.yahoo.com
acl badsites dstdomain .rareedge.com .ytunnelpro.com .chat.yahoo.com
acl badsites dstdomain .voice.yahoo.com
http_access deny fb

Howto block User IP or series in SQUID ACL

If you want to block specific IP series in SQUID via ACL and want to redirect it to a local page (useful for non payment reminder) use following


#Allow Web Server access where our ad page is hosted , it can be local or remote whatever you like : p
acl allow_web_server dst 192.18.100.10
http_access allow allow_web_server

# Create ACL to block EXPIRED USERS pool and redirect it to advertisement page
acl expired_clients src 192.168.100.0/24
http_access deny expired_clients
deny_info http://101.11.11.240/nonpayment/nonpayment.htm expired_clients


 

SCRIPT TO CHECK SQUID or any other service STATUS AND START IT IF REQUIRED [Jz]

Following script [checksquid.sh] will check SQUID service status , and if it found squid stop, it will start it auto, if the squid is already running , it will do nothing :)

First create file in any folder or temp folder by


mkdir /temp
touch /temp/checksquid.sh
chmod +x  /temp/checksquid.sh

Now edit this file


nano /temp/checksquid.sh

& paste the following code

#!/bin/bash
pid=`pidof $1`
if [ $pid == ]; then
echo $1 service is NOT running, Trying to start again . . .
service $1 start
else
echo $1 service is Running OK , no further action required, EXITING  . . .
fi

.

Save & Exit.

Test it by running


/temp/checksquid.sh squid

You can check any service status with above command, if the service is not running , it will try to start with.

You can create its cron entry to run it after every 5 minutes.

For example, add it using CRON by following


crontab -e

and add following line

*/5 * * * * /temp/checksquid.sh

 

GENERAL LINUX COMMANDS [Jz]

To view Disk information

df -h

To view free memory

# in Megabytes

free -m

# in Gigabytes

free -g

To view Linux Release and architecture

lsb-release -a

You will something like below

root@server:~# lsb_release -a
Distributor ID: Ubuntu
Description:    Ubuntu 10.04.4
LTSRelease:        10.04
Codename:       lucid

To view Linux Architecture if its 32bit (x86) or 64bit

uname -a

root@server:~# uname -a
Linux server 2.6.32-50-server #112-Ubuntu SMP Tue Jul 9 20:45:08 UTC 2013 x86_64 GNU/Linux


x86_64 shows that the architecture is 64 bit


if you see something i386 , or i686 ,  it means you have 32 bit version.

.

To view CPU support

cat /proc/cpuinfo

and look for flag “lm” in the flags: column. If it’s there then it’s 64bit CPU.


 

TO EMPTY ANY FILE FROM COMMAND PROMPT

To empty any file contents, For example if you want to clear all the contents in the squid.conf file , so that you can start with new, use following

cat /dev/null /etc/squid/squid.conf

TO ADD ANY WORD IN STARTING OF EVERY LINE IN ANY FILE [Jz]

One way to do this is to use awk.


awk '{ printf YOURTEXT; print }'  CURRENT_FILENAME  &gt; OUTPUT_FILENAME

If you want to modify the file in place, you can use sed with the -i switch.


sed -i -e 's_.*_YOURTEXT;_'  CURRENT_FILENAME

.
.

Adding PROXY for command line programs like WGET [Jz]


 

http_proxy=http://127.0.0.1:8080

To test if SQUID service is not responding to requests, and restart ,

.

http_proxy=http://127.0.0.1:8080 /wget http://ya.ru -O /dev/null || squid -k reload

 

Mount USB in Ubuntu Server (12.x or any)

You can either install “usb-mount”, or mount it manually
Get the information (what is the device, e.g. /dev/sdb1):

fdisk -l

Create any foldeer where you will mount your USB, like in /usb

mkdir /usb

Mount the USB drive:

mount -t ntfs /dev/sdb1 /usb

-t is the filesystem type. Most flash drives are NTFS formatted if used on windows, or FAT32 (vfat).

To Unmount the drive:

Either:

umount /dev/sdb1
Or:
umount /usb

 


Mysql Related Commands

Following are few MYSQL related stuff for personnel reference.

To print RM Managers from DB

use radius;
show tables;
select * from rm_managers limit 0 , 30;

to execute commands in mysql terminal

go        (\g) Send command to mysql server.
exit      (\q) Exit mysql. Same as quit.

To search from table (for online radius users)

SELECT * FROM radacct WHERE acctstoptime IS NULL;

To search from table with specific condition matched;

SELECT username, owner from rm_users where username='zaib' AND owner='admin';

To view MYSQL command history

cat ~/.mysql_history

Create DB in mysql

create database test;
create user 'zaib'@'localhost' identified by 'zaib';
grant all on test.* to zaib@localhost;

RESULT:

mysql> create database test;
Query OK, 1 row affected (0.00 sec)

mysql> create user 'zaib'@'localhost' identified by 'zaib';
Query OK, 0 rows affected (0.00 sec)

mysql> grant all on test.* to zaib@localhost;
Query OK, 0 rows affected (0.00 sec)

Adding Virtual NIC in ubuntu

To add virutal nic in ubuntu, issue this command you can also add these commands in startup as well.


ip link add link eth0 address 11:22:33:44:55:66 eth0.1 type macvlan

ifconfig eth0.1 up

ifconfig eth0.1 10.0.0.2


Change MYSQL old ROOT password

mysql -u root -pOLDPASSWORD
use mysql;
update user set password=PASSWORD('NEW-PASSWORD') where User='root';
flush privileges;

CHANGE RADIUS USER PASSWORD FOR RADIUS MANAGER IN MYSQL

use mysql;
SET PASSWORD FOR 'radius'@'localhost' = PASSWORD('NEW-PASSWORD');
SET PASSWORD FOR 'conntrack'@'localhost' = PASSWORD('NEW-PASSWORD');

#Then change password in radius manager related Files for user 'radius'

/etc/radiusmanager.cfg
/var/www/radiusmanager/config/system_cfg.php
/usr/local/etc/raddb/sql.conf

Change the password to new password in above files.


Howto install ‘sendemail’ tool to send email via Gmail ID.

Very Well with Tested For UBUNTU 12.4 / 32bit …

Quick copy paste …

apt-get -y install libio-socket-ssl-perl libnet-ssleay-perl perl

wget http://caspian.dotconf.net/menu/Software/SendEmail/sendEmail-v1.56.tar.gz

tar zxvf sendEmail-v1.56.tar.gz

cd sendEmail-v1.56/

To test email use following command, make sure to change the GMAIL ID and password.

# To send simple email

/temp/sendEmail-v1.56/sendEmail -u "Test Email - subject" -o tls=yes -s smtp.gmail.com:587 -t RECEIVER-EMAIL@gmail.com -xu YOUR-GMAILID@gmail.com -xp GMAIL-PASS -f  YOUR-GMAILID@gmail.com -o -o message-content-type=text -m "this is meail body - zaib"

# To send simple email with file attached
/temp/sendEmail-v1.56/sendEmail -u "Test Email - subject" -o tls=yes -s smtp.gmail.com:587 -t RECEIVER-EMAIL@gmail.com -xu YOUR-GMAILID@gmail.com -xp GMAIL-PASS -f YOUR-GMAILID@gmail.com -o -o message-content-type=text -m "this is meail body - zaib" -o message-file=/temp/test.txt -o message-content


 

 

 

Regard’s
Syed Jahanzaib

August 20, 2013

Monitor Switch Ports Up/Down Status via Mikrotik Dude – Short Notes

Filed under: Cisco Related, Mikrotik Related — Tags: , , — Syed Jahanzaib / Pinochio~:) @ 12:51 PM

3750

final


.

Another Live Example of port monitoring with sms/email/voice alert system in DUDE.

dude

In my network, I have few Cisco switches at various departments connected via FIBER optics. Recently we were having issue of network connectivity in between various switches and devices. I already have a very good setup of Mikrotik base DUDE monitoring system, but it shows only the SWITCH availability status on the screen, I wanted to have a good visual for switch ports too.

I found few ways to accomplish this task using DUDE functions, scripts, etc, but found following method is very simple to start with . It also sends me email when any port goes Down or not in use.

Make sure your switch support SNMP , and SNMP agent is enabled at your SWITCH as well as at your DUDE to match the same. For simplicity you can use PUBLIC as a default community string in the switch. Also In this example I have used CISCO 3750 (in dual stack mode) and add only few ports just for example.

First add your switch in the map so that it can appear in the map as look like below.

As showed in the image below . . .

cisc-map

 


 

 

Adding PROBE for port monitoring

Now to add PORTS monitoring, Open Dude,
Goto PROBES and click on + sign to add new probe.
Use the following data.

Name = PORT 9
Type = SNMP
SNMP Profile = Your SNMP Profile
Oid = iso.org.dod.internet.mgmt.mib-2.interfaces.ifTable.ifEntry.ifOperStatus.10109
Oid Type = integer
Comapre method = ==equal
Integer Value = 1

As showed in the image below . . .

adding-probe-in-probes

Note: Change the OID number to match the port number on your switch , for example I am monitoring port number9 which value is 10109 . You can use SNMPWALK via DUDE to check the OID’s for different ports of your switch.

Now click OK to save

.

.

Adding Switch PORT separately using IP and PROBE

Its time to add PORTs in your map so they can appear separately as showed in the title image

Go back to your MAP,
Right click and ADD new device,
Type your switch IP address, and click on Next,
Now DO NOT  click on Discover , simply click on + sign
In PROBE, Select the PORT 9 probe you created earlier
and click on Apply/OK

As showed in the image below . . .

port9

Click on Finish.

.

.

Now you will see something like below . . .

port-down-status

As you can see the port number 9 is down , so the status is shown correctly.

.

.

Now you can repeat the same procedure to add as much ports you like to monitor.

Something like below image . . .

something

.

.

.

Adding LINKS to monitor port usage

You can also add LINKS to show the port usage 🙂

As showed in the example below . . .

add link

 

 

linkx-snmp

.

.

.

After adding ports / snmp links, and other enhancements , you can see something like below image . .

.

final.

.

.

I will add more methods to monitor the ports. For more info , please read more at following links

http://forum.mikrotik.com/viewtopic.php?f=8&t=46928

http://forum.mikrotik.com/viewtopic.php?t=46419


Updated: 20th October 2015

Howto check Cisco 3750 Port Status via SNMP using BASH to format the output.

</p>
<p style="text-align: left;">PORT1Q=`snmpwalk -Oqv -v1 -c COMMUNITY_NAME IP_ADDRESS 1.3.6.1.2.1.2.2.1.8.10101`
if [ "$PORT1Q" = "1" ]; then
PORT1S="UP"
echo "$PORT1S"
else
PORT1S="DOWN"
echo "$PORT1S"
fi</p>
<p style="text-align: left;">

Regard’s
Syed Jahanzaib

August 16, 2013

ZPH with SQUID 3.x with UBUNTU 12.04 / Mikrotik QUEUE

Filed under: Linux Related, Mikrotik Related — Tags: , , , — Syed Jahanzaib / Pinochio~:) @ 4:31 PM

Last Updated: 22/01/2015  > Minor Updates including mismatch value in marked packets

ZPH in Action 🙂

zph

.

zph-squid3


 

ZPH is a squid patch that enables SQUID to mark cached packets , so that it can later used by the Mikrotik or squid itself to bypass cached contents from Speed Package.

Z.P.H directives config which works with SQUID 2.7 doesn’t work with new version of SQUID i.e 3.x

Use the following directives in /etc/squid3/squid.conf

# ZPH for Squid3 / zaib
qos_flows local-hit=0x30

then reload squid config by

squid -k rec

Now at Mikrotik, use following rules …


 

Queue Rule For Mikrotik 5.x

/ip firewall mangle
add action=mark-packet chain=prerouting comment="MARK_CACHE_HIT_FROM_PROXY_ZAIB" disabled=no dscp=12 new-packet-mark=zph-hit passthrough=no

/queue tree
add burst-limit=0 burst-threshold=0 burst-time=0s comment="Queue for SQUID CACHE HIT for ZPH / zaib" disabled=no limit-at=0 max-limit=0 name=Proxy packet-mark=zph-hit parent=global-out priority=1 queue=default

Queue Rule For Mikrotik 6.x


/ip firewall mangle
add action=mark-packet chain=prerouting comment="MARK_CACHE_HIT_FROM_PROXY_ZAIB" disabled=no dscp=12 new-packet-mark=zph-hit passthrough=no

/queue simple
add max-limit=100M/100M name="ZPH-Proxy Cache Hit Simple Queue / Syed Jahanzaib >aacable@hotmail.com" packet-marks=zph-hit priority=1/1 target="" total-priority=1

.


 

If you have hotspot, then dynamic queue always get on top, so you ahve to apply this line in hotspot user profile, so that every time hotspot user login, zph queue should move on top.

https://aacable.wordpress.com/2013/11/25/mikrotik-hotspot-workaround-for-dynamic-queue-always-remain-above-static-queue/


Regard’s
SYED JAHANZAIB

August 13, 2013

VIDEOCACHE and SQUID Configuration [Short Notes]

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

videocache-header-logo

WAN utilization / 60mb

WAN utilization @ 60 mbps / zaib

First of all , intro to what VIDEOCACHE is ?

” Videocache is a Squid URL plugin to cache videos from famous video sharing portals/websites like Youtube, Metacafe etc. It helps you save bandwidth when a particular video is requested more than once from the same network/machine.

Squid can not cache the videos served dynamically. Videocache fits into squid to help it cache the videos as well. The cached videos are stored on your proxy server’s local storage or on a storage server in your network. These cached videos can be served to your clients at a very fast speed saving your upstream bandwidth. “

Following are some working configuration samples for VIDEOCACHE with SQUID on UBUNTU. Installation of VC is fairly simple as mentioned here step by step

http://cachevideos.com/documentation/

I am not showing howto install VIDEOCACHE plugin as its very simple and briefly described at the author site, I am only posting the working configuration files. Also note that videocache is a paid plugin, which costs around 400$ per year.

If you are looking for something free, you may try the following NIGNX method.

https://aacable.wordpress.com/2012/08/13/youtube-caching-with-squid-nginx/

Also I would like to share that for VIDEOCACHE plugin, you *MUST* have some good hardware with *LOTS OF* memory and STORAGE. Just for an idea, I deployed it at a network of 300 Users which had Dual CPU with multi cores server for proxy  , 128GB RAM, and 24 TB of external HP Storage, CPU was not much utilized, but at full peak time, the memory usage was around 95%, and the storage usage was around 180 GB in just 1 day.

Also you should have some good amount of bandwidth, otherwise videocache will become bottleneck for your network 🙂 , OR schedule VIDEOCACHE to cache only in specific timings, its supported in /etc/videocache.conf

Following is an working Squid 2.7 on Ubuntu Server 10.4 with videocache support. Please modify necessary directives before using , for example cache_mem, hostname, ACL, Ip’s. Also make sure the CACHE_DIR have been changed to match your local directory structure with proper permissions assgined to user proxy or squid , depend on he nix flavor you are using

# SQUID 2.7 CONFIG FILE WITH VIDEOCACHE PLUGIN FOR SQUID/VIDEOS [ Zaib]

# SQUID 2.7 WORKING CONFIG FILE [August 2013] with Videocache Support
# By - Syed Jahanzaib
# Email: aacable@hotmail.com
# Web  : https://aacable.wordpress.com

cache_store_log /var/log/squid/store.log
acl this_machine src 127.0.0.1 192.168.100.1
http_access allow this_machine

# --BEGIN-- videocache config for squid
url_rewrite_program /usr/bin/python /usr/share/videocache/videocache.py
url_rewrite_children 20

acl vc_deny_url url_regex -i \.blip\.tv\/(.*)filename \.hardsextube\.com\/videothumbs \.xtube\.com\/(.*)(Thumb|videowall)

acl vc_url url_regex -i \/youku\/[0-9A-Z]+\/[0-9A-Z\-]+\.(flv|mp4|avi|mkv|mp3|rm|rmvb|m4v|mov|wmv|3gp|mpg|mpeg)
acl vc_url url_regex -i \/(.*)key=[a-z0-9]+(.*)\.flv
acl vc_url url_regex -i \.(youtube|youtube-nocookie)\.com\/feeds\/api\/videos\/[0-9a-zA-Z_-]{11}\/
acl vc_url url_regex -i \.(youtube|youtube-nocookie)\.com\/(videoplayback|get_video|watch|watch_popup|user_watch)\?
acl vc_url url_regex -i \.(youtube|youtube-nocookie)\.com\/(v|e|embed)\/[0-9a-zA-Z_-]{11}

acl vc_dom_r dstdom_regex -i msn\..*\.(com|net)
acl vc_dom_r dstdom_regex -i msnbc\..*\.(com|net)
acl vc_dom_r dstdom_regex -i video\..*\.fbcdn\.net
acl vc_dom_r dstdom_regex -i myspacecdn\..*\.footprint\.net

acl vc_dom dstdomain .stream.aol.com .videos.5min.com msn.com .blip.tv .vid.ec.dmcdn.net .break.com .vimeocdn.com
acl vc_dom dstdomain .cdn.turner.com .dailymotion.com .c.wrzuta.pl .v.imwx.com .mccont.com .myspacecdn.com
acl vc_dom dstdomain .hardsextube.com .public.extremetube.phncdn.com .redtubefiles.com .video.pornhub.phncdn.com
acl vc_dom dstdomain .public.keezmovies.com .public.keezmovies.phncdn.com .slutload-media.com .public.spankwire.com .xtube.com
acl vc_dom dstdomain .public.youporn.phncdn.com .xvideos.com .tube8.com .public.spankwire.phncdn.com .pornhub.com

refresh_pattern \.youtube\.com\/videoplayback\? 120    80%    180 ignore-no-cache override-expire override-lastmod ignore-private
refresh_pattern stream\.aol\.com\/(.*)/[a-zA-Z0-9]+\/(.*)\.(flv|mp4) 120    80%    180 ignore-no-cache override-expire override-lastmod ignore-private
refresh_pattern videos\.5min\.com\/(.*)/[0-9_]+\.(mp4|flv) 120    80%    180 ignore-no-cache override-expire override-lastmod ignore-private
refresh_pattern proxy[a-z0-9\-]?[a-z0-9]?[a-z0-9]?[a-z0-9]?\.dailymotion\.com\/(.*)\.(flv|on2|mp4|avi|mkv|mp3|rm|rmvb|m4v|mov|wmv|3gp|mpg|mpeg) 120    80%    180 ignore-no-cache override-expire override-lastmod ignore-private
refresh_pattern vid\.akm\.dailymotion\.com\/(.*)\.(flv|on2|mp4|avi|mkv|mp3|rm|rmvb|m4v|mov|wmv|3gp|mpg|mpeg) 120    80%    180 ignore-no-cache override-expire override-lastmod ignore-private
refresh_pattern vid\.ec\.dmcdn\.net\/(.*)\.(flv|on2|mp4|avi|mkv|mp3|rm|rmvb|m4v|mov|wmv|3gp|mpg|mpeg) 120    80%    180 ignore-no-cache override-expire override-lastmod ignore-private
refresh_pattern video\.(.*)\.fbcdn\.net\/(.*)/[0-9_]+\.(mp4|flv|avi|mkv|m4v|mov|wmv|3gp|mpg|mpeg) 120    80%    180 ignore-no-cache override-expire override-lastmod ignore-private
refresh_pattern (.*)\.myspacecdn\.com\/(.*)\/[a-zA-Z0-9]+\/vid\.(flv|mp4|avi|mkv|mp3|rm|rmvb|m4v|mov|wmv|3gp|mpg|mpeg) 120    80%    180 ignore-no-cache override-expire override-lastmod ignore-private
refresh_pattern (.*)\.myspacecdn\.(.*)\.footprint\.net\/(.*)\/[a-zA-Z0-9]+\/vid\.(flv|mp4|avi|mkv|mp3|rm|rmvb|m4v|mov|wmv|3gp|mpg|mpeg) 120    80%    180 ignore-no-cache override-expire override-lastmod ignore-private
refresh_pattern c\.wrzuta\.pl\/wv[0-9]+\/[a-z0-9]+/[0-9]+/ 120    80%    180 ignore-no-cache override-expire override-lastmod ignore-private
refresh_pattern c\.wrzuta\.pl\/wa[0-9]+\/[a-z0-9]+ 120    80%    180 ignore-no-cache override-expire override-lastmod ignore-private
refresh_pattern vs[a-z0-9]?[a-z0-9]?[a-z0-9]?\.hardsextube\.com\/(.*)\/(.*)\.(flv|mp4|avi|mkv|mp3|rm|rmvb|m4v|mov|wmv|3gp|mpg|mpeg) 120    80%    180 ignore-no-cache override-expire override-lastmod ignore-private

acl vc_deny_url url_regex -i crossdomain.xml
acl vc_method method GET
acl vc_header req_header X-Requested-With -i videocache
url_rewrite_access deny !vc_method
url_rewrite_access deny vc_header
url_rewrite_access deny vc_deny_url
url_rewrite_access allow vc_dom
url_rewrite_access allow vc_url
url_rewrite_access allow vc_dom_r
redirector_bypass on

#These lines are needed.
acl this_machine src 127.0.0.1
http_access allow this_machine
strip_query_terms off
maximum_object_size 1000 MB

# --END-- videocache config for squid

# PORT and Transparent Option
http_port 8080 transparent
store_dir_select_algorithm round-robin

# Cache folders, change them according to your need, its an example of 500 GB
cache_dir aufs /cache1 512000 16 256

memory_replacement_policy heap LFUDA
cache_replacement_policy heap GDSF

# If you want to enable DATE time n SQUID Logs,use following
emulate_httpd_log on
logformat squid %tl %6tr %>a %Ss/%03Hs %<st %rm %ru %un %Sh/%<A %mt
log_fqdn off

# How much days to keep users access web logs
# You need to rotate your log files with a cron job. For example:
# 0 0 * * * /usr/local/squid/bin/squid -k rotate
logfile_rotate 14
debug_options ALL,1
cache_access_log /var/log/squid/access.log
cache_log /var/log/squid/cache_log.log
cache_store_log /var/log/squid/store.log

# Block Ads [zaib]
#acl adsites dstdomain url_regex "/etc/squid/adslist.txt"
#http_access deny adsites
#deny_info http://192.168.6.1/psb.htm adsites

#I used DNSAMSQ service for fast dns resolving
#so install by using "apt-get install dnsmasq" first
dns_nameservers 127.0.0.1 8.8.8.8
ftp_user anonymous@
ftp_list_width 32
ftp_passive on
ftp_sanitycheck on

#ACL Section mylan myacl
acl all src 0.0.0.0/0.0.0.0
acl manager proto cache_object
acl localhost src 127.0.0.1/255.255.255.255
acl to_localhost dst 127.0.0.0/8
acl SSL_ports port 443 563 # https, snews
#acl SSL_ports port 873 # rsync
acl Safe_ports port 80 # http
acl Safe_ports port 21 # ftp
acl Safe_ports port 443 563 # https, snews
acl Safe_ports port 70 # gopher
acl Safe_ports port 210 # wais
acl Safe_ports port 1025-65535 # unregistered ports
acl Safe_ports port 280 # http-mgmt
acl Safe_ports port 488 # gss-http
acl Safe_ports port 591 # filemaker
acl Safe_ports port 777 # multiling http
acl Safe_ports port 631 # cups
acl Safe_ports port 873 # rsync
acl Safe_ports port 901 # SWAT
acl purge method PURGE
acl CONNECT method CONNECT
http_access allow manager all
http_access deny manager
http_access allow purge localhost
http_access deny purge
http_access deny !Safe_ports
http_access deny CONNECT !SSL_ports
http_access allow localhost
http_access allow all
#http_access allow all2
http_reply_access allow all
#http_reply_access allow all2
icp_access allow all

#==========================
# Administrative Parameters
#==========================

#============================================================$
# SNMP , if you want to generate graphs for SQUID via MRTG / zaib
#============================================================$
acl snmppublic snmp_community zaib
snmp_port 3401
snmp_access allow snmppublic all
snmp_access allow all

# I used UBUNTU so user is proxy, in FEDORA you may use use squid
cache_effective_user proxy
cache_effective_group proxy
cache_mgr SYED_JAHAN_ZAIB
visible_hostname aacable.wordpress.com
unique_hostname aacable@hotmail.com

# Memory , If you have 4 GB of RAM in the server, then use 1 GB
cache_mem 1 GB
minimum_object_size 0 bytes
maximum_object_size_in_memory 1024 KB

# ZPH , to mark content which is in CACHE
tcp_outgoing_tos 0x30 all
zph_mode tos
zph_local 0x30
zph_parent 0
zph_option 136
acl store_rewrite_list urlpath_regex \/(get_video|videoplayback\?id|videoplayback.*id)
acl store_rewrite_list urlpath_regex \.(jp(e?g|e|2)|gif|png|tiff?|bmp|ico|flv|wmv|3gp|mp(4|3)|exe|msi|zip|on2|mar)\?
acl store_rewrite_list_domain url_regex ^http:\/\/([a-zA-Z-]+[0-9-]+)\.[A-Za-z]*\.[A-Za-z]*
acl store_rewrite_list_domain url_regex (([a-z]{1,2}[0-9]{1,3})|([0-9]{1,3}[a-z]{1,2}))\.[a-z]*[0-9]?\.[a-z]{3}
acl store_rewrite_list_path urlpath_regex \.(jp(e?g|e|2)|gif|png|tiff?|bmp|ico|flv|avc|zip|mp3|3gp|rar|on2|mar|exe)$
acl store_rewrite_list_domain_CDN url_regex \.rapidshare\.com.*\/[0-9]*\/.*\/[^\/]* ^http:\/\/(www\.ziddu\.com.*\.[^\/]{3,4})\/(.*) \.doubleclick\.net.*
acl store_rewrite_list_domain_CDN url_regex ^http:\/\/[.a-z0-9]*\.photobucket\.com.*\.[a-z]{3}$ quantserve\.com
acl store_rewrite_list_domain_CDN url_regex ^http:\/\/[a-z]+[0-9]\.google\.co(m|\.id)
acl store_rewrite_list_domain_CDN url_regex ^http:\/\/\.www[0-9][0-9]\.indowebster\.com\/(.*)(rar|zip|flv|wm(a|v)|3gp|mp(4|3)|exe|msi|avi|(mp(e?g|a|e|1|2|3|4))|cab|exe)
acl dontrewrite url_regex redbot\.org \.php
acl getmethod method GET
##
refresh_pattern -i \.htm 120 50% 10080 reload-into-ims
refresh_pattern -i \.html 120 50% 10080 reload-into-ims
refresh_pattern ^http://*.facebook.com/* 720 100% 4320
refresh_pattern ^http://mail.yahoo.com/.* 720 100% 4320
refresh_pattern ^http://*.yahoo.*/.* 720 100% 4320
refresh_pattern ^http://*.yimg.*/.* 720 100% 4320
refresh_pattern ^http://*.gmail.*/.* 720 100% 4320
refresh_pattern ^http://*.google.*/.* 720 100% 4320
refresh_pattern ^http://*.kaskus.*/.* 720 100% 4320
refresh_pattern ^http://*.googlesyndication.*/.* 720 100% 4320
refresh_pattern ^http://*.plasa.*/.* 720 100% 4320
refresh_pattern ^http://*.telkom.*/.* 720 100% 4320
##

# 1 year = 525600 mins, 1 month = 43800 mins
refresh_pattern imeem.*\.flv  0 0% 0     override-lastmod override-expire
refresh_pattern \.rapidshare.*\/[0-9]*\/.*\/[^\/]*   161280    90%    161280 ignore-reload

refresh_pattern (get_video\?|videoplayback\?|videodownload\?|\.flv?)    10800 80% 10800 ignore-no-cache  ignore-private override-expire override-lastmod reload-into-ims
refresh_pattern (get_video\?|videoplayback\?id|videoplayback.*id|videodownload\?|\.flv?)    10800 80% 10800 ignore-no-cache  ignore-private override-expire override-lastmod reload-into-ims
#refresh_pattern -i (get_video\?|videoplayback\?id|videoplayback.*id||videodownload\?|\.flv?)       10800 80% 10800 ignore-no-cache  ignore-private override-expire override-lastmod reload-into-ims
refresh_pattern \.(ico|video-stats) 10800 80% 10800    override-expire ignore-reload ignore-no-cache  ignore-private ignore-auth override-lastmod
refresh_pattern \.etology\?                       10800 80% 10800    override-expire ignore-reload ignore-no-cache
refresh_pattern galleries\.video(\?|sz)               10800 80% 10800    override-expire ignore-reload ignore-no-cache
refresh_pattern brazzers\?                       10800 80% 10800    override-expire ignore-reload ignore-no-cache
refresh_pattern \.adtology\?                      10800 80% 10800    override-expire ignore-reload ignore-no-cache
#refresh_pattern ^.*(utm\.gif|ads\?|rmxads\.com|ad\.z5x\.net|bh\.contextweb\.com|bstats\.adbrite\.com|a1\.interclick\.com|ad\.trafficmp\.com|ads\.cubics\.com|ad\.xtendmedia\.com|\.googlesyndication\.com|advertising\.com|yieldmanager|game-advertising\.com|pixel\.quantserve\.com|adperium\.com|doubleclick\.net|adserving\.cpxinteractive\.com|syndication\.com|media.fastclick.net).* 10800 20% 10800 ignore-no-cache  ignore-private override-expire ignore-reload ignore-auth   negative-ttl=40320 max-stale=10
refresh_pattern ^.*safebrowsing.*google  10800 80% 10800 override-expire ignore-reload ignore-no-cache ignore-private ignore-auth
refresh_pattern ^http://((cbk|mt|khm|mlt)[0-9]?)\.google\.co(m|\.uk) 10800 80% 10800 override-expire ignore-reload   ignore-private
refresh_pattern ytimg\.com.*\.jpg                   10800 80% 10800    override-expire ignore-reload
refresh_pattern images\.friendster\.com.*\.(png|gif)           10800 80% 10800    override-expire ignore-reload
refresh_pattern garena\.com                                   10800 80% 10800     override-expire reload-into-ims
refresh_pattern photobucket.*\.(jp(e?g|e|2)|tiff?|bmp|gif|png)  10800 80% 10800     override-expire ignore-reload
refresh_pattern vid\.akm\.dailymotion\.com.*\.on2\?           10800 80% 10800 ignore-no-cache override-expire override-lastmod
refresh_pattern mediafire.com\/images.*\.(jp(e?g|e|2)|tiff?|bmp|gif|png)    10800 80% 10800 reload-into-ims override-expire ignore-private
refresh_pattern ^http:\/\/images|pics|thumbs[0-9]\.      10800 80% 10800 reload-into-ims ignore-no-cache  ignore-reload override-expire
refresh_pattern ^http:\/\/www.onemanga.com.*\/           10800 80% 10800 reload-into-ims ignore-no-cache  ignore-reload override-expire

# ANTI VIRUS
refresh_pattern guru.avg.com/.*\.(bin)                      10800 80% 10800 ignore-no-cache  ignore-reload  reload-into-ims
refresh_pattern (avgate|avira).*(idx|gz)$                           10800 80% 10800 ignore-no-cache  ignore-reload  reload-into-ims
refresh_pattern kaspersky.*\.avc$                                   10800 80% 10800 ignore-no-cache  ignore-reload  reload-into-ims
refresh_pattern kaspersky                                           10800 80% 10800 ignore-no-cache  ignore-reload  reload-into-ims
refresh_pattern update.nai.com/.*\.(gem|zip|mcs)                    10800 80% 10800 ignore-no-cache  ignore-reload  reload-into-ims
refresh_pattern ^http:\/\/liveupdate.symantecliveupdate.com.*\(zip)     10800 80% 10800 ignore-no-cache  ignore-reload  reload-into-ims

refresh_pattern windowsupdate.com/.*\.(cab|exe)             10800  80%  10800 ignore-no-cache  ignore-reload  reload-into-ims
refresh_pattern update.microsoft.com/.*\.(cab|exe)             10800  80%  10800 ignore-no-cache  ignore-reload  reload-into-ims
refresh_pattern download.microsoft.com/.*\.(cab|exe)             10800  80%  10800 ignore-no-cache  ignore-reload  reload-into-ims

#images facebook
refresh_pattern ((facebook.com)|(85.131.151.39)).*\.(jpg|png|gif)      10800 80% 10800 ignore-reload  override-expire ignore-no-cache
refresh_pattern -i \.fbcdn.net.*\.(jpg|gif|png|swf|mp3)                  10800 80% 10800 ignore-reload  override-expire ignore-no-cache
refresh_pattern  static\.ak\.fbcdn\.net*\.(jpg|gif|png)                  10800 80% 10800 ignore-reload  override-expire ignore-no-cache
refresh_pattern ^http:\/\/profile\.ak\.fbcdn.net*\.(jpg|gif|png)      10800 80% 10800 ignore-reload  override-expire ignore-no-cache

#banner IIX
refresh_pattern ^http:\/\/openx.*\.(jp(e?g|e|2)|gif|pn[pg]|swf|ico|css|tiff?) 10800 99999% 10800 reload-into-ims  ignore-reload override-expire ignore-no-cache
refresh_pattern ^http:\/\/ads(1|2|3).kompas.com.*\/           10800 99999% 10800 reload-into-ims  ignore-reload override-expire ignore-no-cache
refresh_pattern ^http:\/\/img.ads.kompas.com.*\/           10800 99999% 10800 reload-into-ims  ignore-reload override-expire ignore-no-cache
refresh_pattern .kompasimages.com.*\.(jpg|gif|png|swf)       10800 99999% 10800 reload-into-ims  ignore-reload override-expire ignore-no-cache
refresh_pattern ^http:\/\/openx.kompas.com.*\/           10800 99999% 10800 reload-into-ims  ignore-reload override-expire ignore-no-cache
refresh_pattern kaskus.\us.*\.(jp(e?g|e|2)|gif|png|swf)        10800 99999% 10800 reload-into-ims  ignore-reload override-expire ignore-no-cache
refresh_pattern ^http:\/\/img.kaskus.us.*\.(jpg|gif|png|swf)       10800 99999% 10800 reload-into-ims  ignore-reload override-expire ignore-no-cache

#IIX DOWNLOAD
refresh_pattern ^http:\/\/\.www[0-9][0-9]\.indowebster\.com\/(.*)(mp3|rar|zip|flv|wmv|3gp|mp(4|3)|exe|msi|zip) 10800 99999% 10800 reload-into-ims  ignore-reload override-expire ignore-no-cache    ignore-auth

#All File
refresh_pattern -i \.(3gp|7z|ace|asx|avi|bin|cab|dat|deb|divx|dvr-ms)      10800 80% 10800 ignore-no-cache  ignore-private override-expire override-lastmod reload-into-ims
refresh_pattern -i \.(rar|jar|gz|tgz|bz2|iso|m1v|m2(v|p)|mo(d|v))          10800 80% 10800 ignore-no-cache  ignore-private override-expire override-lastmod reload-into-ims
refresh_pattern -i \.(jp(e?g|e|2)|gif|pn[pg]|bm?|tiff?|ico|swf|css|js)     10800 80% 10800 ignore-no-cache  ignore-private override-expire override-lastmod reload-into-ims
refresh_pattern -i \.(mp(e?g|a|e|1|2|3|4)|mk(a|v)|ms(i|u|p)|og(x|v|a|g)|rar|rm|r(a|p)m|snd|vob|wav) 10800 80% 10800 ignore-no-cache ignore-private override-expire override-lastmod reload-into-ims
refresh_pattern -i \.(pp(s|t)|wax|wm(a|v)|wmx|wpl|zip|cb(r|z|t))     10800 80% 10800 ignore-no-cache ignore-private override-expire override-lastmod reload-into-ims

#########################################################################

refresh_pattern (cgi-bin|\?)       0      0%      0
refresh_pattern ^gopher:    1440    0%    1440
refresh_pattern ^ftp:         10080     95%     10800 override-lastmod reload-into-ims
refresh_pattern         .     180     95% 10800 override-lastmod reload-into-ims

global_internal_static off
retry_on_error on
buffered_logs on
read_ahead_gap 32 KB

#header_access Accept-Encoding deny  all
client_persistent_connections off
server_persistent_connections on
half_closed_clients off
strip_query_terms off
quick_abort_min 0 KB
quick_abort_max 0 KB
quick_abort_pct 100
vary_ignore_expire on
reload_into_ims on
pipeline_prefetch on
read_timeout 30 minute
client_lifetime 6 hour
positive_dns_ttl 6 hour
pconn_timeout 15 second
request_timeout 1 minute
log_icp_queries off
ipcache_size 16384
ipcache_low 98
ipcache_high 99
log_fqdn off
fqdncache_size 16384
memory_pools off
forwarded_for on
client_db off
max_filedescriptors 8192

if you are using SQUID 3.1.19 (Ubuntu 12.4 default isntallation) then use following, pretty much same hmmm 🙂

SQUID 3.1.19 CONFIG FILE in /etc/squid3/squid.conf

# SQUID 3.1.19 CONFIG FILE WITH VIDEOCACHE PLUGIN FOR SQUID/VIDEOS [ Zaib]
# SQUID 3.1.19 WORKING CONFIG FILE [August 2013] with Videocache Support
# By - Syed Jahanzaib
# Email: aacable@hotmail.com
# Web  : https://aacable.wordpress.com

cache_store_log /var/log/squid3/store.log
acl this_machine src 127.0.0.1 192.168.100.1 # Change this ip to match your's
http_access allow this_machine

# --BEGIN-- videocache config for squid
#
# PASTE THIS FILE AT THE TOP OF YOUR SQUID CONFIGURATION FILE
#
# (C) Copyright White Magnet Software Private Limited
# Company Website : http://whitemagnet.com/
# Product Website : http://cachevideos.com/
#
# Videocache Version : Trial
#
# This configuration is for Squid versions 3.x ZABBO
url_rewrite_program /usr/bin/python /usr/share/videocache/videocache.py
url_rewrite_children 20

acl vc_deny_url url_regex -i \.blip\.tv\/(.*)filename \.hardsextube\.com\/videothumbs \.xtube\.com\/(.*)(Thumb|videowall)

acl vc_url url_regex -i \/youku\/[0-9A-Z]+\/[0-9A-Z\-]+\.(flv|mp4|avi|mkv|mp3|rm|rmvb|m4v|mov|wmv|3gp|mpg|mpeg)
acl vc_url url_regex -i \/(.*)key=[a-z0-9]+(.*)\.flv
acl vc_url url_regex -i \.(youtube|youtube-nocookie)\.com\/feeds\/api\/videos\/[0-9a-zA-Z_-]{11}\/
acl vc_url url_regex -i \.(youtube|youtube-nocookie)\.com\/(videoplayback|get_video|watch|watch_popup|user_watch)\?
acl vc_url url_regex -i \.(youtube|youtube-nocookie)\.com\/(v|e|embed)\/[0-9a-zA-Z_-]{11}

acl vc_dom_r dstdom_regex -i msn\..*\.(com|net)
acl vc_dom_r dstdom_regex -i msnbc\..*\.(com|net)
acl vc_dom_r dstdom_regex -i video\..*\.fbcdn\.net
acl vc_dom_r dstdom_regex -i myspacecdn\..*\.footprint\.net

acl vc_dom dstdomain .stream.aol.com .videos.5min.com msn.com .blip.tv .vid.ec.dmcdn.net .break.com .vimeocdn.com
acl vc_dom dstdomain .cdn.turner.com .dailymotion.com .c.wrzuta.pl .v.imwx.com .mccont.com .myspacecdn.com
acl vc_dom dstdomain .hardsextube.com .public.extremetube.phncdn.com .redtubefiles.com .video.pornhub.phncdn.com
acl vc_dom dstdomain .public.keezmovies.com .public.keezmovies.phncdn.com .slutload-media.com .public.spankwire.com .xtube.com
acl vc_dom dstdomain .public.youporn.phncdn.com .xvideos.com .tube8.com .public.spankwire.phncdn.com .pornhub.com

refresh_pattern \.youtube\.com\/videoplayback\? 120    80%    180 ignore-no-cache ignore-no-store override-expire override-lastmod ignore-private
refresh_pattern stream\.aol\.com\/(.*)/[a-zA-Z0-9]+\/(.*)\.(flv|mp4) 120    80%    180 ignore-no-cache ignore-no-store override-expire override-lastmod ignore-private
refresh_pattern videos\.5min\.com\/(.*)/[0-9_]+\.(mp4|flv) 120    80%    180 ignore-no-cache ignore-no-store override-expire override-lastmod ignore-private
refresh_pattern proxy[a-z0-9\-]?[a-z0-9]?[a-z0-9]?[a-z0-9]?\.dailymotion\.com\/(.*)\.(flv|on2|mp4|avi|mkv|mp3|rm|rmvb|m4v|mov|wmv|3gp|mpg|mpeg) 120    80%    180 ignore-no-cache ignore-no-store override-expire override-lastmod ignore-private
refresh_pattern vid\.akm\.dailymotion\.com\/(.*)\.(flv|on2|mp4|avi|mkv|mp3|rm|rmvb|m4v|mov|wmv|3gp|mpg|mpeg) 120    80%    180 ignore-no-cache ignore-no-store override-expire override-lastmod ignore-private
refresh_pattern vid\.ec\.dmcdn\.net\/(.*)\.(flv|on2|mp4|avi|mkv|mp3|rm|rmvb|m4v|mov|wmv|3gp|mpg|mpeg) 120    80%    180 ignore-no-cache ignore-no-store override-expire override-lastmod ignore-private
refresh_pattern video\.(.*)\.fbcdn\.net\/(.*)/[0-9_]+\.(mp4|flv|avi|mkv|m4v|mov|wmv|3gp|mpg|mpeg) 120    80%    180 ignore-no-cache ignore-no-store override-expire override-lastmod ignore-private
refresh_pattern (.*)\.myspacecdn\.com\/(.*)\/[a-zA-Z0-9]+\/vid\.(flv|mp4|avi|mkv|mp3|rm|rmvb|m4v|mov|wmv|3gp|mpg|mpeg) 120    80%    180 ignore-no-cache ignore-no-store override-expire override-lastmod ignore-private
refresh_pattern (.*)\.myspacecdn\.(.*)\.footprint\.net\/(.*)\/[a-zA-Z0-9]+\/vid\.(flv|mp4|avi|mkv|mp3|rm|rmvb|m4v|mov|wmv|3gp|mpg|mpeg) 120    80%    180 ignore-no-cache ignore-no-store override-expire override-lastmod ignore-private
refresh_pattern c\.wrzuta\.pl\/wv[0-9]+\/[a-z0-9]+/[0-9]+/ 120    80%    180 ignore-no-cache ignore-no-store override-expire override-lastmod ignore-private
refresh_pattern c\.wrzuta\.pl\/wa[0-9]+\/[a-z0-9]+ 120    80%    180 ignore-no-cache ignore-no-store override-expire override-lastmod ignore-private
refresh_pattern vs[a-z0-9]?[a-z0-9]?[a-z0-9]?\.hardsextube\.com\/(.*)\/(.*)\.(flv|mp4|avi|mkv|mp3|rm|rmvb|m4v|mov|wmv|3gp|mpg|mpeg) 120    80%    180 ignore-no-cache ignore-no-store override-expire override-lastmod ignore-private

acl vc_deny_url url_regex -i crossdomain.xml
acl vc_method method GET
acl vc_header req_header X-Requested-With -i videocache
url_rewrite_access deny !vc_method
url_rewrite_access deny vc_header
url_rewrite_access deny vc_deny_url
url_rewrite_access allow vc_dom
url_rewrite_access allow vc_url
url_rewrite_access allow vc_dom_r
url_rewrite_bypass on
#These lines are needed.
acl this_machine src 127.0.0.1
http_access allow this_machine
strip_query_terms off
maximum_object_size 10 GB
# --END-- videocache config for squid

# SQUID 3.x CONFIG FILE

# PORT and Transparent Option
#http_port 8080
http_port 8080 transparent
icp_port 0

store_dir_select_algorithm round-robin

# Cache Direcotries on external Storage, for sure you should change it
# Each folder is of 1.5 TB in space
cache_dir aufs /cache-1/squid-cache-1 1500000 16 256
cache_dir aufs /cache-2/squid-cache-2 15000000 16 256
cache_dir aufs /cache-3/squid-cache-3 15000000 16 256
cache_dir aufs /cache-4/squid-cache-4 15000000 16 256
cache_dir aufs /cache-5/squid-cache-5 15000000 16 256
cache_dir aufs /cache-6/squid-cache-6 15000000 16 256
cache_dir aufs /cache-7/squid-cache-7 15000000 16 256
cache_dir aufs /cache-8/squid-cache-8 15000000 16 256
cache_dir aufs /cache-9/squid-cache-9 15000000 16 256
cache_dir aufs /cache-10/squid-cache-10 15000000 16 256
cache_dir aufs /cache-11/squid-cache-11 15000000 16 256
cache_dir aufs /cache-12/squid-cache-12 1500000 16 256

#cache_dir ufs /mnt/hdd2/cache2 200000 16 256 # If you have secondary HDD
memory_replacement_policy heap LFUDA
cache_replacement_policy heap GDSF

# If you want to enable DATE time n SQUID Logs,use following
emulate_httpd_log on
logformat squid %tl %6tr %>a %Ss/%03Hs %<st %rm %ru %un %Sh/%<A %mt
log_fqdn off

# How much days to keep users access web logs
# You need to rotate your log files with a cron job. For example:
# 0 0 * * * /usr/local/squid/bin/squid -k rotate
logfile_rotate 14
debug_options ALL,1
cache_access_log /var/log/squid3/access.log
cache_log  /var/log/squid3/cache_log.log
cache_store_log /var/log/squid3/store.log

# Block Ads [zaib]
#acl adsites dstdomain url_regex "/etc/squid/adslist.txt"
#http_access deny adsites
#deny_info http://192.168.6.1/psb.htm adsites

#I used DNSAMSQ service for fast dns resolving
#so install by using "apt-get install dnsmasq" first
dns_nameservers 127.0.0.1 8.8.8.8
ftp_user anonymous@
ftp_list_width 32
ftp_passive on
ftp_sanitycheck on

#ACL Section mylan myacl
acl all src 0.0.0.0/0.0.0.0 # ALLOW ALL, you may want to change this /zaib
acl manager proto cache_object
acl localhost src 127.0.0.1/255.255.255.255
acl to_localhost dst 127.0.0.0/8
acl SSL_ports port 443 563 # https, snews
acl SSL_ports port 873 # rsync
acl Safe_ports port 80 # http
acl Safe_ports port 21 # ftp
acl Safe_ports port 443 563 # https, snews
acl Safe_ports port 70 # gopher
acl Safe_ports port 210 # wais
acl Safe_ports port 1025-65535 # unregistered ports
acl Safe_ports port 280 # http-mgmt
acl Safe_ports port 488 # gss-http
acl Safe_ports port 591 # filemaker
acl Safe_ports port 777 # multiling http
acl Safe_ports port 631 # cups
acl Safe_ports port 873 # rsync
acl Safe_ports port 901 # SWAT
acl purge method PURGE
acl CONNECT method CONNECT
http_access allow manager all
http_access deny manager
http_access allow purge localhost
http_access deny purge
http_access deny !Safe_ports
http_access deny CONNECT !SSL_ports
http_access allow localhost
http_access allow all
#http_access allow all2
http_reply_access allow all
#http_reply_access allow all2
icp_access allow all

#==========================
# Administrative Parameters
#==========================

#============================================================$
# SNMP , if you want to generate graphs for SQUID via MRTG
#============================================================$
#acl snmppublic snmp_community zaib
#snmp_port 3401
#snmp_access allow snmppublic all
#snmp_access allow all

# I used UBUNTU so user is proxy, in FEDORA you may use use squid
cache_effective_user proxy
cache_effective_group proxy
cache_mgr SYED_JAHAN_ZAIB
visible_hostname aacable.wordpress.com
unique_hostname aacable@hotmail.com

# Memory, in this example, teh squid box have 32 B of RAM
cache_mem 8 GB # Change it as per your hardware config, you may want to lower it down
minimum_object_size 0 bytes
maximum_object_size_in_memory 5 MB # Change it as per your hardware config, you may want to lower it down if you have low ram

# 1 year = 525600 mins, 1 month = 43800 mins
refresh_pattern imeem.*\.flv  0 0% 0     override-lastmod override-expire
refresh_pattern \.rapidshare.*\/[0-9]*\/.*\/[^\/]*   161280    90%    161280 ignore-reload

refresh_pattern (get_video\?|videoplayback\?|videodownload\?|\.flv?)    10800 80% 10800 ignore-no-cache  ignore-private override-expire override-lastmod reload-into-ims
refresh_pattern (get_video\?|videoplayback\?id|videoplayback.*id|videodownload\?|\.flv?)    10800 80% 10800 ignore-no-cache  ignore-private override-expire override-lastmod reload-into-ims
#refresh_pattern -i (get_video\?|videoplayback\?id|videoplayback.*id||videodownload\?|\.flv?)       10800 80% 10800 ignore-no-cache  ignore-private override-expire override-lastmod reload-into-ims
refresh_pattern \.(ico|video-stats) 10800 80% 10800    override-expire ignore-reload ignore-no-cache  ignore-private ignore-auth override-lastmod
refresh_pattern \.etology\?                       10800 80% 10800    override-expire ignore-reload ignore-no-cache
refresh_pattern galleries\.video(\?|sz)               10800 80% 10800    override-expire ignore-reload ignore-no-cache
refresh_pattern brazzers\?                       10800 80% 10800    override-expire ignore-reload ignore-no-cache
refresh_pattern \.adtology\?                      10800 80% 10800    override-expire ignore-reload ignore-no-cache
#refresh_pattern ^.*(utm\.gif|ads\?|rmxads\.com|ad\.z5x\.net|bh\.contextweb\.com|bstats\.adbrite\.com|a1\.interclick\.com|ad\.trafficmp\.com|ads\.cubics\.com|ad\.xtendmedia\.com|\.googlesyndication\.com|advertising\.com|yieldmanager|game-advertising\.com|pixel\.quantserve\.com|adperium\.com|doubleclick\.net|adserving\.cpxinteractive\.com|syndication\.com|media.fastclick.net).* 10800 20% 10800 ignore-no-cache  ignore-private override-expire ignore-reload ignore-auth   negative-ttl=40320 max-stale=10
refresh_pattern ^.*safebrowsing.*google  10800 80% 10800 override-expire ignore-reload ignore-no-cache ignore-private ignore-auth
refresh_pattern ^http://((cbk|mt|khm|mlt)[0-9]?)\.google\.co(m|\.uk) 10800 80% 10800 override-expire ignore-reload   ignore-private
refresh_pattern ytimg\.com.*\.jpg                   10800 80% 10800    override-expire ignore-reload
refresh_pattern images\.friendster\.com.*\.(png|gif)           10800 80% 10800    override-expire ignore-reload
refresh_pattern garena\.com                                   10800 80% 10800     override-expire reload-into-ims
refresh_pattern photobucket.*\.(jp(e?g|e|2)|tiff?|bmp|gif|png)  10800 80% 10800     override-expire ignore-reload
refresh_pattern vid\.akm\.dailymotion\.com.*\.on2\?           10800 80% 10800 ignore-no-cache override-expire override-lastmod
refresh_pattern mediafire.com\/images.*\.(jp(e?g|e|2)|tiff?|bmp|gif|png)    10800 80% 10800 reload-into-ims override-expire ignore-private
refresh_pattern ^http:\/\/images|pics|thumbs[0-9]\.      10800 80% 10800 reload-into-ims ignore-no-cache  ignore-reload override-expire
refresh_pattern ^http:\/\/www.onemanga.com.*\/           10800 80% 10800 reload-into-ims ignore-no-cache  ignore-reload override-expire

# ANTI VIRUS
refresh_pattern guru.avg.com/.*\.(bin)                      10800 80% 10800 ignore-no-cache  ignore-reload  reload-into-ims
refresh_pattern (avgate|avira).*(idx|gz)$                           10800 80% 10800 ignore-no-cache  ignore-reload  reload-into-ims
refresh_pattern kaspersky.*\.avc$                                   10800 80% 10800 ignore-no-cache  ignore-reload  reload-into-ims
refresh_pattern kaspersky                                           10800 80% 10800 ignore-no-cache  ignore-reload  reload-into-ims
refresh_pattern update.nai.com/.*\.(gem|zip|mcs)                    10800 80% 10800 ignore-no-cache  ignore-reload  reload-into-ims
refresh_pattern ^http:\/\/liveupdate.symantecliveupdate.com.*\(zip)     10800 80% 10800 ignore-no-cache  ignore-reload  reload-into-ims

refresh_pattern windowsupdate.com/.*\.(cab|exe)             10800  80%  10800 ignore-no-cache  ignore-reload  reload-into-ims
refresh_pattern update.microsoft.com/.*\.(cab|exe)             10800  80%  10800 ignore-no-cache  ignore-reload  reload-into-ims
refresh_pattern download.microsoft.com/.*\.(cab|exe)             10800  80%  10800 ignore-no-cache  ignore-reload  reload-into-ims

#images facebook
refresh_pattern ((facebook.com)|(85.131.151.39)).*\.(jpg|png|gif)      10800 80% 10800 ignore-reload  override-expire ignore-no-cache
refresh_pattern -i \.fbcdn.net.*\.(jpg|gif|png|swf|mp3)                  10800 80% 10800 ignore-reload  override-expire ignore-no-cache
refresh_pattern  static\.ak\.fbcdn\.net*\.(jpg|gif|png)                  10800 80% 10800 ignore-reload  override-expire ignore-no-cache
refresh_pattern ^http:\/\/profile\.ak\.fbcdn.net*\.(jpg|gif|png)      10800 80% 10800 ignore-reload  override-expire ignore-no-cache

#banner IIX
refresh_pattern ^http:\/\/openx.*\.(jp(e?g|e|2)|gif|pn[pg]|swf|ico|css|tiff?) 10800 99999% 10800 reload-into-ims  ignore-reload override-expire ignore-no-cache
refresh_pattern ^http:\/\/ads(1|2|3).kompas.com.*\/           10800 99999% 10800 reload-into-ims  ignore-reload override-expire ignore-no-cache
refresh_pattern ^http:\/\/img.ads.kompas.com.*\/           10800 99999% 10800 reload-into-ims  ignore-reload override-expire ignore-no-cache
refresh_pattern .kompasimages.com.*\.(jpg|gif|png|swf)       10800 99999% 10800 reload-into-ims  ignore-reload override-expire ignore-no-cache
refresh_pattern ^http:\/\/openx.kompas.com.*\/           10800 99999% 10800 reload-into-ims  ignore-reload override-expire ignore-no-cache
refresh_pattern kaskus.\us.*\.(jp(e?g|e|2)|gif|png|swf)        10800 99999% 10800 reload-into-ims  ignore-reload override-expire ignore-no-cache
refresh_pattern ^http:\/\/img.kaskus.us.*\.(jpg|gif|png|swf)       10800 99999% 10800 reload-into-ims  ignore-reload override-expire ignore-no-cache

#IIX DOWNLOAD
refresh_pattern ^http:\/\/\.www[0-9][0-9]\.indowebster\.com\/(.*)(mp3|rar|zip|flv|wmv|3gp|mp(4|3)|exe|msi|zip) 10800 99999% 10800 reload-into-ims  ignore-reload override-expire ignore-no-cache    ignore-auth

#All File
refresh_pattern -i \.(3gp|7z|ace|asx|avi|bin|cab|dat|deb|divx|dvr-ms)      10800 80% 10800 ignore-no-cache  ignore-private override-expire override-lastmod reload-into-ims
refresh_pattern -i \.(rar|jar|gz|tgz|bz2|iso|m1v|m2(v|p)|mo(d|v))          10800 80% 10800 ignore-no-cache  ignore-private override-expire override-lastmod reload-into-ims
refresh_pattern -i \.(jp(e?g|e|2)|gif|pn[pg]|bm?|tiff?|ico|swf|css|js)     10800 80% 10800 ignore-no-cache  ignore-private override-expire override-lastmod reload-into-ims
refresh_pattern -i \.(mp(e?g|a|e|1|2|3|4)|mk(a|v)|ms(i|u|p)|og(x|v|a|g)|rar|rm|r(a|p)m|snd|vob|wav) 10800 80% 10800 ignore-no-cache ignore-private override-expire override-lastmod reload-into-ims
refresh_pattern -i \.(pp(s|t)|wax|wm(a|v)|wmx|wpl|zip|cb(r|z|t))     10800 80% 10800 ignore-no-cache ignore-private override-expire override-lastmod reload-into-ims

#########################################################################

refresh_pattern (cgi-bin|\?)       0      0%      0
refresh_pattern ^gopher:    1440    0%    1440
refresh_pattern ^ftp:         10080     95%     10800 override-lastmod reload-into-ims
refresh_pattern         .     180     95% 10800 override-lastmod reload-into-ims

global_internal_static off
retry_on_error on
buffered_logs on
read_ahead_gap 32 KB

#header_access Accept-Encoding deny  all
client_persistent_connections off
server_persistent_connections on
half_closed_clients off
strip_query_terms off
quick_abort_min 0 KB
quick_abort_max 0 KB
quick_abort_pct 100
vary_ignore_expire on
reload_into_ims on
pipeline_prefetch on
read_timeout 30 minute
client_lifetime 6 hour
positive_dns_ttl 6 hour
pconn_timeout 15 second
request_timeout 1 minute
log_icp_queries off
ipcache_size 16384
ipcache_low 98
ipcache_high 99
log_fqdn off
fqdncache_size 16384
memory_pools off
forwarded_for on
client_db off
max_filedescriptors 8192

# ZAIB
# ZPH for Squid 3.3.19
qos_flows local-hit=0x30

After videocache is installed, following is the fine tunned config file. Don’t forget to change the host ip (192.168.100.1) to match your own server ip

VIDEO CACHE CONFIG FILE in /etc/videocache.conf

[main]

# file : /etc/videocache.conf
# (C) Copyright White Magnet Software Private Limited
# Company Website : http://whitemagnet.com/
# Product Website : http://cachevideos.com/

# WORKING SAMPLE FILE [JULY 2013] - Syed Jahanzaib
# Email: aacable@hotmail.com
# Web  : https://aacable.wordpress.com

# version : cxxxxxxb

client_email = your_registered_emai_address@hotmail.com
cache_host = 192.168.100.1
videocache_user = proxy

# This option is used to define the cache directories where Videocache will store
# cached videos. We can specify multiple caching directories separated by ‘|’.
# Examples:
#   base_dir = /videocache/
#   base_dir = /cache/videocache2/ | /hdd2/videocache/ | /home/videocache/
base_dir = /cache1/vc/

disk_avail_threshold = 15000
disk_cleanup_strategy = 1
enable_videocache = 1
offline_mode = 0
base_dir_selection = 2
enable_store_log_monitoring = 1
squid_store_log = /var/log/squid3/store.log
this_proxy = 127.0.0.1:8080
hit_threshold = 1
max_cache_processes = 10
max_cache_speed = 0
max_cache_queue_size = 100000
cache_period =
proxy =
proxy_username =
proxy_password =
max_video_size = 0
min_video_size = 0
force_video_size = 1
scheduler_pidfile = /var/run/videocache.pid
logdir = /var/log/videocache/
logformat = %tl %p %s %i %w %c %v %m %d
scheduler_logformat = %tl %p %s %i %w %c %v %m %d
cleaner_logformat = %tl %p %s %w %c %v %m %d
timeformat = %d/%b/%Y:%H:%M:%S
enable_videocache_log = 1
enable_scheduler_log = 1
enable_cleaner_log = 1
enable_trace_log = 1
logfile = videocache.log
scheduler_logfile = scheduler.log
cleaner_logfile = cleaner.log
tracefile = trace.log
max_logfile_size = 10
max_scheduler_logfile_size = 10
max_cleaner_logfile_size = 10
max_tracefile_size = 10
max_logfile_backups = 10
max_scheduler_logfile_backups = 5
max_cleaner_logfile_backups = 1
max_tracefile_backups = 1

enable_youtube_cache = 1

# This options determines if Videocache will cache different YouTube video
# formats separately. Please select an appropriate algorithm from the listed below.
# Available strategies:
#   1 : (disabled) Don't check for YouTube video formats. Cache one of the formats
#       and serve it for requests for all kinds of formats.
#   2 : (strict) Strictly check for YouTube formats and cache all formats separately.
#       Consumes maximum bandwidth.
#   3 : (approximate) Check YouTube formats but with approximation. For example,
#       if a client asked for a video in 480p format and we already have 360p
#       format of the same video in cache, then serve 360p format and vice-versa.
# Default : 3
enable_youtube_format_support = 3
enable_youtube_html5_videos = 1
enable_youtube_3d_videos = 1
enable_youtube_partial_caching = 1
max_youtube_video_quality = 720p
min_youtube_views = 0
enable_aol_cache = 1
enable_bing_cache = 1
enable_bliptv_cache = 1
enable_breakcom_cache = 1
enable_cnn_cache = 1
enable_dailymotion_cache = 1
enable_facebook_cache = 1
enable_megavideo_cache = 1
enable_metacafe_cache = 1
enable_myspace_cache = 1
enable_vimeo_cache = 1
enable_weather_cache = 1
enable_wrzuta_cache = 1
enable_youku_cache = 1
enable_extremetube_cache = 1
enable_hardsextube_cache = 1
enable_keezmovies_cache = 1
enable_pornhub_cache = 1
enable_redtube_cache = 1
enable_slutload_cache = 1
enable_spankwire_cache = 1
enable_tube8_cache = 1
enable_xhamster_cache = 1
enable_xtube_cache = 1
enable_xvideos_cache = 1
enable_youporn_cache = 1

skip_apache_conf = 0
apache_conf_dir = /etc/apache2/conf.d/
hide_cache_dirs = 1
rpc_host = 127.0.0.1
rpc_port = 9100


To restart Videocache and related services, use following commands

vc-update

    service apache2 restart

    vc-scheduler -s restart

    service squid3 restart

To view Video cache Logs in live for info and troubleshooting

tail -f /var/log/videocache/videocache.log

tail -f /var/log/videocache/scheduler.log

tail -f /var/log/squid3/access.log

Sample image of logs at live server

VC-CACHE

VC-CACHE

☼☼☼☼☼☼☼☼

Regard’s
Syed Jahanzaib

August 5, 2013

BIM TS3100 Library: Incompatible Magazine!


Recently we replaced our 7 years old IBM TS3200 Tape Library with the new TS3100 FC. For about a week, It worked fine , but when yesterday, our support personnel changed the tape cartridges, and tried to login to the WEBGUI of library to manage and move the tape to drive, it showed following error on screen.

tape error

 

and the tape library showed this “Scanning” message on its panel and none of any function worked properly

IMAG0480

I tried every possible method of re installing drivers, pulling magazines manually from back using Access hole (small hatches, facing rear of the library) with pin, but no use.

 

After carefully deep inspection, I found out that the support personnel remove the MAGAZINE FIDUCIALS by mistake (plastic part attached with the every level of magazine where the cartridge is placed) , the support personnel thought it was some sort of un necessary packing ☻

As showed in the image below . . .

 

fudicials

 

IMAG0518

After placing the Magazine Fiducials back to its place, every thing worked fine.
Also make sure that you are using the latest Firmware, it helps too 🙂

Magazine Fiducials  are location sensors utilized by the library accessors.

Possibly it may help some one else too, because in my personal experience, If you don’t have SLA or service contract with the IBM or there vendors, you won’t gonna find much support over the web or in local market.

 

Regard’s
Syed Jahanzaib

Create a free website or blog at WordPress.com.