Syed Jahanzaib Personal Blog to Share Knowledge !

October 31, 2013

Monitoring Mikrotik with Linux base MRTG [References]

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

Following post is about how to monitor Mikrotik Ssytem / Routerboard to create live graphs with history for every aspect, like CPU, Memory, Voltage, Amps, Interface etc. It comes very useful when you remotely administrating the system and you need to know what happens over the period of time and have an overview on every internal instance of the system.

I wrote another article that explains well on howto install MRTG in Ubuntu and monitor anything with it, but WORDPRESS coding ruins the code badly, but still you can get idea from it from following URL.

https://aacable.wordpress.com/tag/mrtg-installation-on-ubuntu/

So basically you have to first install MRTG on linux, then you can use that mrtg installation to monitor any devices in your network (which supports snmp that includes mikrotik as well)


1- MIKROTIK SECTION

 

# Enabling SNMP on Mikrotik

First Enable SNMP service (with public as community string or whatever you like on your mikrotik. Make sure no firewall rule is blocking SNMP traffic from/to the monitoring server.

Open Terminal in mikrotik and paste the following command. Or you can configure it via going to IP > SNMP


/snmp community
set [ find default=yes ] addresses=0.0.0.0/0 authentication-password="" authentication-protocol=MD5 encryption-password="" encryption-protocol=DES name=public read-access=yes \
security=none write-access=no

/snmp
set contact=Syed-Jahanzaib enabled=yes engine-id="" location=aacable-wordpress-com trap-community=public trap-generators="" trap-target="" trap-version=1

Now proceed further 🙂


 

1. Monitoring Mikrotik Simple Queue with Linux base MRTG (for monitoring performance and track purposes)

To monitor simple QUEUE via Linux base MRTG, you can use following config as an example 😀

First you have to check your simple queue OID (numeric value which is used by MRTG to poll specific data from the remote server) in mikrotik. for example you have a queue to allow 100M for proxy cached marked packets.

sq-ch

Open Terminal and print OID for Simple Queue number 0 (your can be changed, but in general Queue for proxy hit packets should be on ** TOP ** )


[admin@MikroTik] /queue simple print

Flags: X - disabled, I - invalid, D - dynamic

0    ;;; Simple Queue for squid Proxy CACHE HIT Packet Allow Unlimited Bandwidth
name=SQ-for-cache-hit interface=all parent=none packet-marks=Cache direction=both priority=8 queue=default-small/default-small limit-at=0/0 max-limit=100M/100M burst-limit=0/0
burst-threshold=0/0 burst-time=0s/0s total-queue=default-small

Now check its OID value which will be used in MRTG to graph the values. Do remember, If you move/delete/add particular Queue , the oid value will change, simply note down new value and recreate graphs with the new values. Also on every system these OIDs are different, simply take a print oid to use them.


[admin@MikroTik] /queue simple print oid

Flags: X - disabled, I - invalid, D - dynamic

0    ;;; Simple Queue for squid Proxy CACHE HIT Packet Allow Unlimited Bandwidth
name=.1.3.6.1.4.1.14988.1.1.2.1.1.2.12534 bytes-in=.1.3.6.1.4.1.14988.1.1.2.1.1.8.12534 bytes-out=.1.3.6.1.4.1.14988.1.1.2.1.1.8.12534 packets-in=.1.3.6.1.4.1.14988.1.1.2.1.1.10.12534
packets-out=.1.3.6.1.4.1.14988.1.1.2.1.1.11.12534 queues-in=.1.3.6.1.4.1.14988.1.1.2.1.1.12.12534 queues-out=.1.3.6.1.4.1.14988.1.1.2.1.1.13.12534

As showed in the image below . . .

qu-oid

Now we have to take bytes-in and bytes-out value for graphing purposes. which is in our case are

.1.3.6.1.4.1.14988.1.1.2.1.1.8.12534
.1.3.6.1.4.1.14988.1.1.2.1.1.9.12534

Now you can simply use the below CFG file to create Graphs for the mikrotik simple queue.


Target[mikrotik-simple-queue-in-out]: .1.3.6.1.4.1.14988.1.1.2.1.1.8.12534&.1.3.6.1.4.1.14988.1.1.2.1.1.9.12534:public@10.0.0.1
MaxBytes[mikrotik-simple-queue-in-out]: 100000000
#Options[mikrotik-simple-queue-in-out]: bits
Title[mikrotik-simple-queue-in-out]: Mikrotik QUEUE for Cache HIT
PageTop[mikrotik-simple-queue-in-out]: <H1>Mikrotik QUEUE for Cache HIT</H1>
#Maintainer: Syed Jahanzaib

 

SAMPLE GRAPH FOR THE SIMPLE QUEUE MONITORING VIA MRTG (AS SHOWED ABOVE)

QUEUE-SAMPLE


Sample Graphs for ccr_1036

Following are sample graphs showing various aspects of Mikrotik CCR 1036.

 

1- cpu

 

active users

 

combined wan usage for 3 dsl

 

cpu tempr

 

memory monitor

 

ping status

 

rb amp

 

rb fan-2 speed rpm

 

rb tempr

 

rb voltage

 

rb watts

 


 

SAMPLE CFG FILES (WORKING GOOD WITH MIKROTIK CCR_1036  ROUTERBOARD MODEL.

 

Mikrotik CCR General  OID’s


active-fan: .1.3.6.1.4.1.14988.1.1.3.9.0
voltage: .1.3.6.1.4.1.14988.1.1.3.8.0
temperature: .1.3.6.1.4.1.14988.1.1.3.10.0
processor-temperature: .1.3.6.1.4.1.14988.1.1.3.11.0
current: .1.3.6.1.4.1.14988.1.1.3.13.0
power-consumption: .1.3.6.1.4.1.14988.1.1.3.12.0
psu1-state: .1.3.6.1.4.1.14988.1.1.3.15.0
psu2-state: .1.3.6.1.4.1.14988.1.1.3.16.0
18.0 is i guess fan2 rpm oid, not mentioned in print oid.</pre>
<pre>uptime: .1.3.6.1.2.1.1.3.0
total-memory: .1.3.6.1.2.1.25.2.3.1.5.65536
used-memory: .1.3.6.1.2.1.25.2.3.1.6.65536
cpu-frequency: .1.3.6.1.4.1.14988.1.1.3.14.0
build-time: .1.3.6.1.4.1.14988.1.1.7.6.0


 


# 192.168.100.2 is Mikrotik RB IP Address
# MRTG sample cfg files for Mikrotik CCR Routerboard monitoring
# Syed Jahanzaib
# Last Modified at 14th-JAN-2016

### MIKROTIK CCR_1036 192.168.100.2 CPU load ###
Target[192.168.100.2_cpu]: 1.3.6.1.2.1.25.3.3.1.2.1&1.3.6.1.2.1.25.3.3.1.2.1:public@192.168.100.2
AbsMax[192.168.100.2_cpu]: 100
MaxBytes[192.168.100.2_cpu]: 100
Title[192.168.100.2_cpu]: MIKROTIK CCR_1036 CPU load
PageTop[192.168.100.2_cpu]: <H1>MIKROTIK CCR_1036 CPU load</H1>
Options[192.168.100.2_cpu]: gauge,growright,nopercent, noo
YLegend[192.168.100.2_cpu]: CPU load
ShortLegend[192.168.100.2_cpu]: %
LegendI[192.168.100.2_cpu]: CPU load (percentage)


# MIKROTIK CCR_1036 PPPoE ACTIVE Users
Target[mtPPPoEusers]: 1.3.6.1.4.1.9.9.150.1.1.1.0&1.3.6.1.4.1.9.9.150.1.1.1.0:public@192.168.100.2
Title[mtPPPoEusers]: Active PPPoE Users on MIKROTIK CCR_1036
PageTop[mtPPPoEusers]: <H1>Active PPPoE Users on MIKROTIK CCR_1036</H1>
MaxBytes[mtPPPoEusers]: 1000
Colours[mtPPPoEusers]: B#8888ff,B#8888ff,B#5398ff,B#5398ff
Options[mtPPPoEusers]: gauge,nopercent,noo,integer,growright
LegendI[mtPPPoEusers]: Active PPPoE Users on MT
LegendO[mtPPPoEusers]:
YLegend[mtPPPoEusers]: Active PPPoE Users on MT
Legend1[mtPPPoEusers]: Active PPPoE Users on MT
Legend2[mtPPPoEusers]:


### MONITORING MIKROTIK CCR_1036 CPU TEMP ###
Target[mt.cpu.temp]: 1.3.6.1.4.1.14988.1.1.3.11.0&1.3.6.1.4.1.14988.1.1.3.11.0:public@192.168.100.2 / 10
Options[mt.cpu.temp]: gauge, growright, nopercent, noinfo
MaxBytes[mt.cpu.temp]: 100
Colours[mt.cpu.temp]: RED#ff4f27,Y#fffb15,RED#ff4f27,RED#fffb15
#Unscaled[mt.cpu.temp]: dwmy
YLegend[mt.cpu.temp]: CPU Temprature
Title[mt.cpu.temp]: MIKROTIK CCR_1036 RB CPU Temprature
PageTop[mt.cpu.temp]: <H1>MIKROTIK CCR_1036 RB CPU Temprature</H1>
ShortLegend[mt.cpu.temp]: c
LegendI[mt.cpu.temp]:
LegendO[mt.cpu.temp]: CPU Temp
Legend1[mt.cpu.temp]: CPU Temprature
Legend2[mt.cpu.temp]: CPU Temprature


### MONITORING MIKROTIK CCR_1036 RB TEMP ###
Target[mt.rb.temp]: 1.3.6.1.4.1.14988.1.1.3.10.0&1.3.6.1.4.1.14988.1.1.3.10.0:public@192.168.100.2 / 10
Options[mt.rb.temp]: gauge, growright, nopercent, noinfo
MaxBytes[mt.rb.temp]: 100
Colours[mt.rb.temp]: RED#ff4f27,Y#fffb15,RED#ff4f27,RED#fffb15
#Unscaled[mt.rb.temp]: dwmy
YLegend[mt.rb.temp]: RB Temprature
Title[mt.rb.temp]: MIKROTIK CCR_1036 Router Board Temprature
PageTop[mt.rb.temp]: <H1>MIKROTIK CCR_1036 Router Board Temprature</H1>
ShortLegend[mt.rb.temp]: c
LegendI[mt.rb.temp]:
LegendO[mt.rb.temp]: RB Temp
Legend1[mt.rb.temp]: RB Temprature
Legend2[mt.rb.temp]: RB Temprature

### MONITORING MIKROTIK CCR_1036 VOLTAGE Monitor ###
Target[mt-voltage]: .1.3.6.1.4.1.14988.1.1.3.8.0&1.3.6.1.4.1.14988.1.1.3.8.0:public@192.168.100.2 / 10
Options[mt-voltage]: gauge, growright, nopercent, noinfo
MaxBytes[mt-voltage]: 1000
Colours[mt-voltage]: RED#ff4f27,Y#fffb15,RED#ff4f27,RED#fffb15
#Unscaled[mt-voltage]: dwmy
YLegend[mt-voltage]: Voltaeg Monitor
Title[mt-voltage]: MIKROTIK CCR_1036 Cloudcore RB VOLTAGE Monitor
PageTop[mt-voltage]: <H1>MIKROTIK CCR_1036 Cloudcore RB VOLTAGE Monitor</H1>
ShortLegend[mt-voltage]: c
LegendI[mt-voltage]:
LegendO[mt-voltage]: Voltage
Legend1[mt-voltage]: Voltage
Legend2[mt-voltage]: Voltage


### MONITORING MIKROTIK CCR_1036 power.consumption Watt Usage Monitor ###
Target[mt-powerconsumption]: .1.3.6.1.4.1.14988.1.1.3.12.0&.1.3.6.1.4.1.14988.1.1.3.12.0:public@192.168.100.2 / 10
Options[mt-powerconsumption]: gauge, growright, nopercent, noinfo
MaxBytes[mt-powerconsumption]: 1000
Colours[mt-powerconsumption]: RED#ff4f27,Y#fffb15,RED#ff4f27,RED#fffb15
#Unscaled[mt-powerconsumption]: dwmy
YLegend[mt-powerconsumption]: Watts USAGE Monitor
Title[mt-powerconsumption]: MIKROTIK CCR_1036 Cloudcore RB Watts Usage Monitor
PageTop[mt-powerconsumption]: <H1>MIKROTIK CCR_1036 Cloudcore RB Watts Usage Monitor</H1>
ShortLegend[mt-powerconsumption]: W
LegendI[mt-powerconsumption]:
LegendO[mt-powerconsumption]: power.consumption.wts
Legend1[mt-powerconsumption]: power.consumption.wts
Legend2[mt-powerconsumption]: power.consumption.wts

### MONITORING MIKROTIK CCR_1036 FAN-2 Speed Monitor ###
Target[mt-FAN2-speed]: 1.3.6.1.4.1.14988.1.1.3.18.0&1.3.6.1.4.1.14988.1.1.3.18.0:public@192.168.100.2
Options[mt-FAN2-speed]: gauge, growright, nopercent, noinfo
MaxBytes[mt-FAN2-speed]: 10000
Colours[mt-FAN2-speed]: RED#ff4f27,Y#fffb15,RED#ff4f27,RED#fffb15
#Unscaled[mt-FAN2-speed]: dwmy
YLegend[mt-FAN2-speed]: Watts USAGE Monitor
Title[mt-FAN2-speed]: MIKROTIK CCR_1036 Cloudcore RB FAN-2 Speed Monitor
PageTop[mt-FAN2-speed]: <H1>MIKROTIK CCR_1036 Cloudcore RB FAN-2 Speed Monitor</H1>
ShortLegend[mt-FAN2-speed]: RPM
LegendI[mt-FAN2-speed]:
LegendO[mt-FAN2-speed]: fan-2.rpm.speed
Legend1[mt-FAN2-speed]: fan-2.rpm.speed
Legend2[mt-FAN2-speed]: fan-2.rpm.speed


### MONITORING MIKROTIK CCR_1036 AMP Monitor ###
Target[mt-amp-mon]: 1.3.6.1.4.1.14988.1.1.3.13.0&1.3.6.1.4.1.14988.1.1.3.13.0:public@192.168.100.2 / 1000
Options[mt-amp-mon]: gauge, growright, nopercent, noinfo
MaxBytes[mt-amp-mon]: 10000
Colours[mt-amp-mon]: RED#ff4f27,Y#fffb15,RED#ff4f27,RED#fffb15
#Unscaled[mt-amp-mon]: dwmy
YLegend[mt-amp-mon]: AMP USAGE Monitor
Title[mt-amp-mon]: MIKROTIK CCR_1036 Cloudcore RB AMP Monitor
PageTop[mt-amp-mon]: <H1>MIKROTIK CCR_1036 Cloudcore RB AMP Monitor</H1>
ShortLegend[mt-amp-mon]: amp
LegendI[mt-amp-mon]:
LegendO[mt-amp-mon]: amp.speed
Legend1[mt-amp-mon]: amp.speed
Legend2[mt-amp-mon]: amp.speed


# Percent of MIKROTIK CCR_1036 memory used
Target[ccr_server_mem_ram]: ( 1.3.6.1.2.1.25.2.3.1.6.65536&1.3.6.1.2.1.25.2.3.1.6.65536:public@192.168.100.2) * 100 / ( 1.3.6.1.2.1.25.2.3.1.5.65536&1.3.6.1.2.1.25.2.3.1.5.65536:public@192.168.100.2)
Title[ccr_server_mem_ram]: Memory usage for MIKROTIK CCR_1036 CCR Server
PageTop[ccr_server_mem_ram]: <H1>Memory usage for MIKROTIK CCR_1036 CCR Server</H1>
MaxBytes[ccr_server_mem_ram]: 100
ShortLegend[ccr_server_mem_ram]: %
YLegend[ccr_server_mem_ram]: % of Memory
Legend1[ccr_server_mem_ram]: Used Memory
LegendI[ccr_server_mem_ram]: Used :
LegendO[ccr_server_mem_ram]:
Options[ccr_server_mem_ram]: nopercent, gauge, integer, growright
Unscaled[ccr_server_mem_ram]: ymwd

 


 

 

Regard’s
Syed Jahanzaib

October 23, 2013

DMASOFTLAB RADIUS MANAGER BILLING SYSTEM v 4.1 Finally Released :D

Filed under: Radius Manager — Tags: , — Syed Jahanzaib / Pinochio~:) @ 2:47 PM

Finally DMA has released its new version for Radius Manager Billing System.

Complete info can be found here.

http://www.dmasoftlab.com/cont/revision

 

 *** v 4.1.0 *** 2013-10-23 ***

 

NEW FEATURES:


-enhanced SMTP mailer with authentication and freely configurable port
-SMS alert indicating the account is going to expire ** This was most DEMANDED 😀  , Jz
-support for BulkSMS HTTP->SMS gateway ** This was most DEMANDED 😀  , Jz
-alert type is selectable in user preferences (ACP / UCP) ** This was most DEMANDED 😀  , Jz
-enable traffic report per user in ACP even if global traffic report is disabled
-service change is allowed for Hotspot MAC accounts
-auto logout expired ACP sessions
-FreeRadius 2.2.0 support
-DOCSIS upstream SNR data in CM overview table
-DOCSIS upstream SNR is available for each CM
-CMTS upstream SNR monitoring
-Mikrotik Gigawords support added for NAS disconnection mode (PPP, Hotspot)
-NAS disconnection mode total traffic limits are supported (Hotspot)
-Paypal Express Checkout order summary is available
-PayFast payment gateway support (South Africa)
-separate checkbox for IAS SMS verification
-option for filtering duplicate email and mobile numbers in self registration and IAS purchase
-Hotspot MAC users can edit account details in UCP
-recover lost IAS password
-option in system settings to add new managers and NASs to all services or not
-custom text field on PDF cards (print online time, MB, expiration, other text) ** This was most DEMANDED 😀  , Jz
-syslog record for all unix events and rmscheduler actions ** This was most DEMANDED 😀  , Jz
-syslog event for sent SMS, email ** This was most DEMANDED 😀  , Jz
-selectable user group in card generator module
-massmail select group option ** This was most DEMANDED 😀  , Jz
-prepaid service details on invoice ** This was most DEMANDED 😀  , Jz
-disable accounts due to expired contract (selectable option)
-user definable character set for card PIN codes and passwords
-find traffic data per NAS ** This was most DEMANDED 😀  , Jz
-find traffic data per AP  ** This was most DEMANDED 😀  , Jz
-traffic summary per NAS  ** This was most DEMANDED 😀  , Jz
-traffic summary per AP  ** This was most DEMANDED 😀  , Jz
-bulk email supports UTF8  ** This was most DEMANDED 😀  , Jz
-bulk SMS with group support  ** This was most DEMANDED 😀  , Jz
-separate poller pause for MT API access (radiusmanager.cfg)
-log unsuccessful RADIUS authentications
-restart radiusd automatically when updating / deleting / editing any of NASs
-option to exclude zero priced invoices in postpaid batch billing
-option to exclude disabled accounts in postpaid batch billing
-welcome SMS for all account types (IAS, self registered, regular, Hotspot MAC, DOCSIS)
-filter registration date in list users view   ** This was most DEMANDED 😀  , Jz
-new registration method: mobile number is the user name, auto generated password is sent to cell phone   ** This was most DEMANDED 😀  , Jz
-UCP payment success shows a disconnect button if next service is active
-ACP record login failures  ** This was most DEMANDED 😀  , Jz
-filter activated / not activated classic prepaid cards   ** This was most DEMANDED 😀  , Jz
-notifications sent in user specific language  ** This was most DEMANDED 😀  , Jz
-selectable language per manager  ** This was most DEMANDED 😀  , Jz
-multi language password recovery form
-enhanced password recovery (user name is mandatory due to possible duplicate email addresses)  ** This was most DEMANDED 😀  , Jz
-configurable default sim-use value for self registered users
-user selectable views: list users, list online users, list online cm
-postpaid invoice status in edit user account overview
-disabled next service support (disabled ip pool etc.)
-multiple email address support per account
-show last logoff date in list users view (useful for finding inactive accounts)   ** This was most DEMANDED 😀  , Jz
-self reg email + SMS activation option   ** This was most DEMANDED 😀  , Jz
-captcha in self registration forms  ** This was most DEMANDED 😀  , Jz
-authorize.net extended currency support (USD, CAD, GBP, EUR)
-optimized rmscheduler.php with delayed disconnection to gain speed
-logging new self registered and IAS accounts   ** This was most DEMANDED 😀  , Jz
-quick last invoice overview (showing the last page first)
-added email address validation for UCP user edit, self registration, ACP registration, IAS purchase   ** This was most DEMANDED 😀  , Jz

BUGFIXES:

-sim-use is added to privileged fields
-account refill vulnerability fixed (UCP)
-user coordinate latitude / longitude fix
-rm_services cmcfg field size = 10240, enabling large tftp boot files
-entering privileged user data issue fixed in new user registration form
-carry over adds new credits to zero if the actual balance is negative
-duplicate PIN problem fixed when prefix is used
-generate card show own service only
-store new IAS mobile, email
-new user registration error fixed when apostrophe is used in service name
-rmacnt crash issue fixed
-list refill cards issue fixed
-dhcpd.conf file ownership issue fixed
-sim-use is no more editable when privileged data editing is disabled
-rmscheduler expired CM logout issue fixed
-store email, mobile number in IAS purchase
-ACP edit user restricted mode: disable CPE address fields
-added missing index parameter to 2CheckOut review cart
-self registration upper case user name problem fixed
-dhcpd.conf access mutex problem fixed
-blank password fix for regular and Hotspot MAC accounts
-ACP refill negative balance vulnerability fixed
-PayPal Payments Pro order total price higher than 1000 issue fixed
-scheduled service changes next page problem fixed
-language cookie path traversal vulnerability fixed
-UCP service change vulnerability fixed
-accidental authorize.net double charge issue fixed
-cancel monthly invoice even if it is active (negative amount is allowed)
-ACP / edit IAS grouped thousands price issue fixed
-online payment submit button issue fixed (Chrome issue)
-duplicate accounting issue fixed
-special periods connection problem fixed

October 22, 2013

SSL Inspection with Squid.3

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

UNSTABLE / INCOMPLETE guide dueto time shortage.

probably it will be replaced with squid 3.2 with ssl support and dynamic cert geenration

The aim of writing this basic howto is to find methods in SQUID to inspect SSL / HTTPS traffic at very minimum level. In this method, The SQUID will act as a MITM (man in the middle). The aim behind doing this config is to decrypt HTTPS connections to apply content filtering which is usually not possible with traditional http methods.

Also note that https caching is not recommended , at the date of writing this (January 2014) still, I haven’t found any 100% working method to bypass certificate issues.
The only way is to IMPORT certificate to user browser. Importing is OK  for a small network, like cyber/net Cafe or Office, Where you have FULL/PARTIAL CONTROL over user PC, but its not suitable for large network or where you cannot convince ppl to trust the new cert.

Please be aware that RIPPING and decrypting HTTPS is fundamentally against the reasons for using HTTPS. HTTPS is designed for secure connectivity and privacy. Since secure HTTP connections are encrypted SSL sessions between your browser and the secure site, and are meant to be reliably secure. Your users will not trust you if you use it without proper implementation. Every SSL request to the HTTPS site will present an invalid certificate window. Users will get a certificate miss match with the SSL enabled sites they try to visit. They will have to add exceptions to trust the self-signed cert from above for each site (This bump can be covered by a workaround but I will NOT go in that detail for some reasons)

Also if you are ripping SSL traffic, You’re exposing yourself to potential lawsuits for doing ripping user private stuff and possible hacking purposes.

IMPO, This approach is OK for content filtering purposes or for government surveillance or only according to law . There are methods to bypass CERTIFICATE mismatching and via using iptables nat, you can do transparent redirection of 443 to your proxy.

Compiling SQUID by source code with –enable-ssl

Update apt and install few required packages by following


apt-get update
apt-get install -y build-essential libssl-dev fakeroot devscripts gawk gcc-multilib dpatch

Now create temporary directory where we will download squid source packages for compilation.


mkdir /temp
cd /temp
wget ftp://artfiles.org/squid-cache.org/pub/archive/3.1/squid-3.1.19.tar.gz
tar zxvf squid-3.1.19.tar.gz
cd squid-3.1.19/

Now compile squid with –enable-ssl option

#===========
#For 64bit =
#===========


./configure \
--prefix=/usr \
--exec_prefix=/usr \
--bindir=/usr/sbin \
--sbindir=/usr/sbin \
--libexecdir=/usr/lib/squid \
--sysconfdir=/etc/squid \
--localstatedir=/var/spool/squid \
--datadir=/usr/share/squid \
--enable-async-io=24 \
--with-aufs-threads=24 \
--with-pthreads \
--enable-storeio=aufs \
--enable-linux-netfilter \
--enable-arp-acl \
--enable-epoll \
--enable-removal-policies=heap,lru \
--with-aio --with-dl \
--enable-snmp \
--enable-delay-pools \
--enable-htcp \
--enable-cache-digests \
--disable-unlinkd \
--enable-large-cache-files \
--with-large-files \
--enable-err-languages=English \
--enable-default-err-language=English --with-maxfd=65536 \
--enable-carp \
--enable-ssl \
--enable-follow-x-forwarded-for \
--with-maxfd=65536  \
'amd64-debian-linux' 'build_alias=amd64-debian-linux' 'host_alias=amd64-debian-linux' 'target_alias=amd64-debian-linux' 'CFLAGS=-Wall -g -O2' 'LDFLAGS=-Wl,-Bsymbolic-functions' 'CPPFLAGS='

Now install it


make
make install

Now edit SQUID CONFIG file and paste the following (remove all old entries, make sure to backup original config file for alter retrieval for backup purposes)

nano /etc/squid/squid.conf

Paste Following SAMPLE config file.


# SQUID 3.1.19 CONFIG FILE FOR SSL FILTERING [ Zaib]
# Thsi file also contains many other JUNK ENTRIES FOR CACHING with some VIDEOCACHE entries,
# Remove them if not required
# By - Syed Jahanzaib
# Email: aacable@hotmail.com
# Web  : https://aacable.wordpress.com

# SSL BUMP
always_direct allow all
ssl_bump allow all

# PORT OPTIONS. for http and https
# Repalce the IP 10.0.0.1 as per your local squid box ip
http_port 8080
http_port 10.0.0.1:8081 ssl-bump cert=/etc/squid3/cert/squid.pem key=/etc/squid3/cert/squid.pem

# for videocache, not required for general setup
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
strip_query_terms off
maximum_object_size 1 GB

# 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

# 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|css)      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|jpg|png)     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

# ACCESS CONTROLS OPTIONS
# ====================
acl all src
acl localnet src 101.0.0.0/8 # Your network here
acl localnet src 192.168.1.0/24 # Your network here
acl localhost src 127.0.0.1/32
acl safeports port 21 70 80 210 280 443 488 563 591 631 777 901 81 3128 1025-65535
acl sslports port 443 563 81 2087 8081 10000
acl manager proto cache_object
acl purge method PURGE
acl connect method CONNECT
http_access allow manager localhost
http_access deny manager
http_access allow purge localhost
http_access deny purge
http_access deny !safeports
http_access deny CONNECT !sslports
http_access allow localhost
http_access allow localnet
http_access deny all

# OPTIONS WHICH AFFECT THE CACHE SIZE
# ==============================

cache_mem 512 MB
maximum_object_size_in_memory 4096 KB
memory_replacement_policy heap GDSF
cache_replacement_policy heap LFUDA
minimum_object_size 0 bytes

# 10GB CACHE SIZE [JZ]
# =====================
cache_dir aufs /cache-1 10000 14 256
maximum_object_size 1000 MB
cache_swap_low 95
cache_swap_high 99

# LOGFILE LOCATIONS AND CACHE_DIR [JZ]
# ====================================

access_log /var/log/squid3/access.log
cache_log /var/log/squid3/cache.log
#cache_log /dev/null
cache_store_log none
logfile_rotate 5
log_icp_queries off

# REFRESH PATTERNS AND OTHER TUNING OPTIONS [JZ]
# ==============================================
refresh_pattern ^ftp: 1440 20% 10080 reload-into-ims
refresh_pattern ^gopher: 1440 0% 1440
refresh_pattern -i .(gif|png|jp?g|ico|bmp|tiff?)$ 10080 95% 43200 override-expire override-lastmod reload-into-ims ignore-no-cache ignore-private
refresh_pattern -i .(rpm|cab|deb|exe|msi|msu|zip|tar|xz|bz|bz2|lzma|gz|tgz|rar|bin|7z|doc?|xls?|ppt?|pdf|nth|psd|sis)$ 10080 90% 43200 override-expire override-lastmod reload-into-ims ignore-no-cache ignore-private
refresh_pattern -i .(avi|iso|wav|mid|mp?|mpeg|mov|3gp|wm?|swf|flv|x-flv|axd)$ 43200 95% 432000 override-expire override-lastmod reload-into-ims ignore-no-cache ignore-private
refresh_pattern -i .(html|htm|css|js)$ 1440 75% 40320
refresh_pattern -i .index.(html|htm)$ 0 75% 10080
#refresh_pattern -i (/cgi-bin/|?) 0 0% 0
refresh_pattern . 1440 90% 10080

quick_abort_min 0 KB
quick_abort_max 0 KB
quick_abort_pct 100
store_avg_object_size 13 KB
vary_ignore_expire on

# ANONIMITY OPTIONS
# ===============

request_header_access From deny all
request_header_access Server deny all
request_header_access Link deny all
request_header_access Via deny all
request_header_access X-Forwarded-For deny all

# ADMINISTRATIVE PARAMETERS [JZ]
# ==============================

cache_mgr Syed_jahanzaib
visible_hostname aacable@hotmail.com
cache_effective_user proxy
cache_effective_group proxy
httpd_suppress_version_string on

ftp_list_width 32
ftp_passive on
ftp_sanitycheck on

# DNS SERVER [JZ]
# ===============
dns_nameservers 8.8.8.8

# MISCELLANEOUS [JZ]
# ==================

memory_pools off
client_db off
reload_into_ims on
coredump_dir /cache-1
pipeline_prefetch on
offline_mode off

### END OF SQUID SAMPLE CONFIGURATION ###
### IT WAS MADE ROUGHLY ###

Now Generate SSL certificate which SQUID will present to the end client. For test purposes in a test environment, you can create a self-signed

certificate using OpenSSL by using the following:


cd /etc/squid3

openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout squid.pem -out squid.pem

It will ask few simple questions like country code, use PK if you are in Pakistan, and some other questions, just answer and proceed further

#####

Create cache folder and assign necnessary permissions.


mkdir /cache-1
chown proxy:proxy /cache-1

Now initialize CACHE folders by SQUID


squid -z

Now start SQUID in no daemon mode to verify you dont have any errors in the config file.

squid -d1N

To redirect TRANSPARENTLY  port 80 and 443 to local proxy.

change the eth0 to match your local LAN interface.


iptables -t nat -A PREROUTING -i eth0 -p tcp –dport 80 -j DNAT –to-destination 10.0.0.1:8080
 iptables -t nat -A PREROUTING -i eth0 -p tcp –dport 443 -j DNAT –to-destination 10.0.0.1:8081

To check SQUID port


netstat -nap | grep 8080

netstat -nap | grep 8081



fb-cache

fb-cache-2

With Decryption ↓

with-decryption

With Encryption ↓

with-encryption

October 9, 2013

Ubuntu apt-get not working


ubuntu-logo

Salam Alaekum,

Recently Ubuntu pk archive source stopped working, means no update, no packages can be installed using apt-get install command. probably some issues in pk archive. but later found out issue was something else.

As showed in the image below . . .

1- apt


Solution # 1

Execute following commands (or copy paste to terminal , make sure you are logged in with root)


sudo rm /var/lib/apt/lists/* -vf
sudo apt-get clean
sudo apt-get autoremove
sudo apt-get dist-upgrade
sudo apt-get update --fix-missing
sudo apt-get update


 

Solution # 2 (if above soluiton #1 does not work)

Use the following sources.list as a workaround.

nano /etc/apt/sources.list

Remove all previous lines and add following lines.


 


# Ubuntu apt-get update not working at various PK locations
# Use US base sources as a workaround, they work pretty good  : )
# Syed Jahanzaib , aacable@hotmail.com
# https://aacable.wordpress.com

deb http://us.archive.ubuntu.com/ubuntu/ lucid main restricted
deb-src http://us.archive.ubuntu.com/ubuntu/ lucid main restricted
deb http://us.archive.ubuntu.com/ubuntu/ lucid-updates main restricted
deb-src http://us.archive.ubuntu.com/ubuntu/ lucid-updates main restricted
deb http://us.archive.ubuntu.com/ubuntu/ lucid universe
deb-src http://us.archive.ubuntu.com/ubuntu/ lucid universe
deb http://us.archive.ubuntu.com/ubuntu/ lucid-updates universe
deb-src http://us.archive.ubuntu.com/ubuntu/ lucid-updates universe
deb http://us.archive.ubuntu.com/ubuntu/ lucid multiverse
deb-src http://us.archive.ubuntu.com/ubuntu/ lucid multiverse
deb http://us.archive.ubuntu.com/ubuntu/ lucid-updates multiverse
deb-src http://us.archive.ubuntu.com/ubuntu/ lucid-updates multiverse
deb http://security.ubuntu.com/ubuntu lucid-security main restricted
deb-src http://security.ubuntu.com/ubuntu lucid-security main restricted
deb http://security.ubuntu.com/ubuntu lucid-security universe
deb-src http://security.ubuntu.com/ubuntu lucid-security universe
deb http://security.ubuntu.com/ubuntu lucid-security multiverse
deb-src http://security.ubuntu.com/ubuntu lucid-security multiverse

Save and Exit the file. now issue following update command


apt-get update

Hopefully the issue will be solved : )

As showed in the image below . . .

2- apt

Regard’s
Syed Jahanzaib

October 8, 2013

PPPoE Dialer via DOS Batch File

Filed under: Microsoft Related — Tags: , , , — Syed Jahanzaib / Pinochio~:) @ 1:53 PM

Changelog:

8th Oct , 2013 9:30pm : Entry added  to create network profile folder if not already there (usually on fresh win7)
9th Oct , 2013 01:45pm : Entry added  to create new phonbook profile, it will not overwrite or delete previous one 🙂

Following is a simple and quickest method to create pppoe dialer using MSDOS batch file made for Windows 7, which create a new rasphone profile for PPPoE Dialer. Usually this sort of work is done using VB , or VB/VC# .NET with Dotras type programming languages which does the job nicely with lots of options and fancy look menus etc, but due to my limited knowledge towards programming, I decided to go with my traditional CLI method. I created this batch program in a very short time without much googling.

Phonebook Location to store profiles (new and old)

%userprofile%\AppData\Roaming\Microsoft\Network\Connections\Pbk\

This is just an example, you can modify at as per your requirements , The issue i faced while adding multiple lines was white space at the end, and if there are additional white spaces in the file , rasphone will not detect the new entry. therefore I later used algorithm to remove white spaces.

Any suggestion to improve the method will be highly appreciable . . . Please psot your comment if this batch file is working ok for you . . .

Let’s Start.

Create a new batch file like

notepad c:\dialer.bat

Paste following data and save.

@echo off
rem
rem #########################################
rem ### PPPoE Dialer Script for Windows 7
rem ### Syed Jahanzaib / aacable@hotmail.com
rem ### http://aacablw.wordpress.com
rem #########################################

rem ### Creating pppoe profile in a temporarily text file
echo. 2>  c:\rstemp.txt
echo [AA_PPPoE_Dialer] >> c:\rstemp.txt
echo Encoding=1 >> c:\rstemp.txt
echo PBVersion=1 >> c:\rstemp.txt
echo Type=5  >> c:\rstemp.txt
echo AutoLogon=0 >> c:\rstemp.txt
echo UseRasCredentials=0 >> c:\rstemp.txt
echo LowDateTime=-582619296 >> c:\rstemp.txt
echo HighDateTime=30327625 >> c:\rstemp.txt
echo DialParamsUID=6326979 >> c:\rstemp.txt
echo Guid=359A05BF4C146640949F56383A0F18F5 >> c:\rstemp.txt
echo VpnStrategy=0 >> c:\rstemp.txt
echo ExcludedProtocols=0 >> c:\rstemp.txt
echo LcpExtensions=1 >> c:\rstemp.txt
echo DataEncryption=8 >> c:\rstemp.txt
echo SwCompression=0 >> c:\rstemp.txt
echo NegotiateMultilinkAlways=0 >> c:\rstemp.txt
echo SkipDoubleDialDialog=0 >> c:\rstemp.txt
echo DialMode=0 >> c:\rstemp.txt
echo OverridePref=15 >> c:\rstemp.txt
echo RedialAttempts=3 >> c:\rstemp.txt
echo RedialSeconds=60 >> c:\rstemp.txt
echo IdleDisconnectSeconds=0 >> c:\rstemp.txt
echo RedialOnLinkFailure=1 >> c:\rstemp.txt
echo CallbackMode=0 >> c:\rstemp.txt
echo CustomDialDll= >> c:\rstemp.txt
echo CustomDialFunc= >> c:\rstemp.txt
echo CustomRasDialDll= >> c:\rstemp.txt
echo ForceSecureCompartment=0 >> c:\rstemp.txt
echo DisableIKENameEkuCheck=0 >> c:\rstemp.txt
echo AuthenticateServer=0 >> c:\rstemp.txt
echo ShareMsFilePrint=0 >> c:\rstemp.txt
echo BindMsNetClient=0 >> c:\rstemp.txt
echo SharedPhoneNumbers=0 >> c:\rstemp.txt
echo GlobalDeviceSettings=0 >> c:\rstemp.txt
echo PrerequisiteEntry= >> c:\rstemp.txt
echo PrerequisitePbk= >> c:\rstemp.txt
echo PreferredPort=PPPoE4-0 >> c:\rstemp.txt
echo PreferredDevice=WAN Miniport (PPPOE) >> c:\rstemp.txt
echo PreferredBps=0 >> c:\rstemp.txt
echo PreferredHwFlow=0 >> c:\rstemp.txt
echo PreferredProtocol=0 >> c:\rstemp.txt
echo PreferredCompression=0 >> c:\rstemp.txt
echo PreferredSpeaker=0 >> c:\rstemp.txt
echo PreferredMdmProtocol=0 >> c:\rstemp.txt
echo PreviewUserPw=1 >> c:\rstemp.txt
echo PreviewDomain=0 >> c:\rstemp.txt
echo PreviewPhoneNumber=0 >> c:\rstemp.txt
echo ShowDialingProgress=1 >> c:\rstemp.txt
echo ShowMonitorIconInTaskBar=1 >> c:\rstemp.txt
echo CustomAuthKey=0 >> c:\rstemp.txt
echo AuthRestrictions=552 >> c:\rstemp.txt
echo IpPrioritizeRemote=1 >> c:\rstemp.txt
echo IpInterfaceMetric=0 >> c:\rstemp.txt
echo IpHeaderCompression=0 >> c:\rstemp.txt
echo IpAddress=0.0.0.0 >> c:\rstemp.txt
echo IpDnsAddress=0.0.0.0 >> c:\rstemp.txt
echo IpDns2Address=0.0.0.0 >> c:\rstemp.txt
echo IpWinsAddress=0.0.0.0 >> c:\rstemp.txt
echo IpWins2Address=0.0.0.0 >> c:\rstemp.txt
echo IpAssign=1 >> c:\rstemp.txt
echo IpNameAssign=1 >> c:\rstemp.txt
echo IpDnsFlags=0 >> c:\rstemp.txt
echo IpNBTFlags=0 >> c:\rstemp.txt
echo TcpWindowSize=0 >> c:\rstemp.txt
echo UseFlags=3 >> c:\rstemp.txt
echo IpSecFlags=0 >> c:\rstemp.txt
echo IpDnsSuffix= >> c:\rstemp.txt
echo Ipv6Assign=1 >> c:\rstemp.txt
echo Ipv6Address=:: >> c:\rstemp.txt
echo Ipv6PrefixLength=0 >> c:\rstemp.txt
echo Ipv6PrioritizeRemote=1 >> c:\rstemp.txt
echo Ipv6InterfaceMetric=0 >> c:\rstemp.txt
echo Ipv6NameAssign=1 >> c:\rstemp.txt
echo Ipv6DnsAddress=:: >> c:\rstemp.txt
echo Ipv6Dns2Address=:: >> c:\rstemp.txt
echo Ipv6Prefix=0000000000000000 >> c:\rstemp.txt
echo Ipv6InterfaceId=0000000000000000 >> c:\rstemp.txt
echo DisableClassBasedDefaultRoute=0 >> c:\rstemp.txt
echo DisableMobility=0 >> c:\rstemp.txt
echo NetworkOutageTime=0 >> c:\rstemp.txt
echo ProvisionType=0 >> c:\rstemp.txt
echo PreSharedKey= >> c:\rstemp.txt

echo NETCOMPONENTS= >> c:\rstemp.txt
echo ms_msclient=0 >> c:\rstemp.txt
echo ms_server=0 >> c:\rstemp.txt

echo MEDIA=rastapi >> c:\rstemp.txt
echo Port=PPPoE4-0 >> c:\rstemp.txt
echo Device=WAN Miniport (PPPOE) >> c:\rstemp.txt

echo DEVICE=PPPoE >> c:\rstemp.txt
echo LastSelectedPhone=0 >> c:\rstemp.txt
echo PromoteAlternates=0 >> c:\rstemp.txt
echo TryNextAlternateOnFail=1 >> c:\rstemp.txt

rem ### Removing white spaces so that it can be readable by phone book /zaib
rem echo. 2>  c:\rscompile.bat
rem if [%1]==[] then echo File name missing & goto :EOF >>
(for /f "tokens=1" %%a in (rstemp.txt) do echo %%a) > %~n1aa-rasphone.pbk

rem ### Location for rasphone.pbk [just for reference] /zaib
rem %userprofile%\AppData\Roaming\Microsoft\Network\Connections\Pbk\

rem ### Creating Network Profile Folder to store dialer profile, if its not there already
mkdir %userprofile%\AppData\Roaming\Microsoft\Network
mkdir %userprofile%\AppData\Roaming\Microsoft\Network\Connections
mkdir %userprofile%\AppData\Roaming\Microsoft\Network\Connections\pbk
cls
rem Copy new rasphone.pbk to user network profile /zaib
rem cd %userprofile%\AppData\Roaming\Microsoft\Network\Connections\Pbk\
rem ren rasphone.pbk rasphone.pbk.old
copy c:\aa-rasphone.pbk %userprofile%\AppData\Roaming\Microsoft\Network\Connections\Pbk\

rem ### Create Network Connection Center Icon on Desktop /zaib
rem ### I coulnd't found a way to create shortcut of dialer on desktop, someone please suggest
set linkName=AA-Network Connections
set linkPath=%userprofile%\desktop
set program=C:\WINDOWS\SYSTEM32\ncpa.cpl
set workDir=C:\WINDOWS\system32
set iconfile=%SystemRoot%\system32\SHELL32.dll
set icon=-18
set windowStyle=2
echo Set oWS = WScript.CreateObject("WScript.Shell") > temp.vbs
echo sLinkFile = "%linkPath%\%linkName%.LNK" >> temp.vbs
echo Set oLink = oWS.CreateShortcut(sLinkFile) >> temp.vbs
echo oLink.TargetPath = "%program%" >> temp.vbs
echo oLink.IconLocation = "%iconFile%, %icon%" >> temp.vbs
echo oLink.WindowStyle = "%windowStyle%" >> temp.vbs
echo oLink.WorkingDirectory = "%workdir%" >> temp.vbs
echo oLink.Save >> temp.vbs

WScript.exe temp.vbs
del temp.vbs

rem #
rem ### Show Popup Message box after everything completed /zaib
rem #

mshta javascript:alert("Dialer Installation Completed!!!\n\Please Restart you computern ,Thank You\n\Syed.Jahanzaib! aacable@hotmail.com");close();

rem # THE END #

Now execute it from c:\dialer.bat & then restart your computer. If you dont want to restart the newly created connection will not show in network connections, You have to press F5 in the network connections to display the newly created profile. After restart it will appear auto in network and sharing center.

After successful lab testing, its time to make it a distributable package. To convert it in executable package, you download BATCH to EXE converter.


http://www.f2ko.de/downloads/Bat_To_Exe_Converter.zip

extract and run Bat_To_Exe_Converter.exe

Fill up the required info as shown in teh images below and click on compile.

1- compile

and click on COMPILE , it will create .exe Package. You can also add additional info like ICON file , or product version or info

As showed in the image below . .

2- compile

.

.

End results 🙂

3- info

Regard’s
Syed Jahanzaib

%d bloggers like this: