বৃহস্পতিবার, ১৯ সেপ্টেম্বর, ২০১৩

Asterisk Installation on Debian



Asterisk 11 Installation on Debian 6.0.7:
--------------------------------------

Asterisk is an Open Source software PBX (Private Branch Exchange), developed by Mark Specer of Digium. It allows you to make calls to one another which may have connected to other PSTN (Public Switched Telephone Network) and Voice over Internet Protocol(VoIP). Asterisk runs on Linux, BSD, MacOSX and others. Having built-in features like voicemail, conferencing, IVR, queuing etc.
In this article, we are going to see a basic installation and working of Asterisk 11 in Debian Linux Operating Systems.

# apt-get update && apt-get upgrade -y && reboot
# apt-get install build-essential wget libssl-dev libncurses5-dev libnewt-dev  libxml2-dev linux-headers-$(uname -r) libsqlite3-dev uuid-dev

2. Downloading DAHDI, LibPRI and Asterisk Tarballs

Download the source tarballs, these following commands will download current release of DAHDI 2.6, 
LibPRI1.4 and Asterisk11.
# cd /usr/src/
# wget http://downloads.asterisk.org/pub/telephony/libpri/libpri-1.4-current.tar.gz
# wget http://downloads.asterisk.org/pub/telephony/dahdi-linux-complete/
       dahdi-linux-complete-current.tar.gz
# wget http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-11-current.tar.gz
Next, extract the files from source tarballs using “tar command” as shown below.
# tar zxvf dahdi-linux-complete-current.tar.gz
# tar zxvf libpri-1.4-current.tar.gz
# tar zxvf asterisk-11-current.tar.gz

3. Configuring, Compiling And Installing

Go to the each directory from where you have downloaded and extracted the packages and start running the following commands to install DAHDI, LibPRI and Asterisk.

Installing DAHDI.
# cd /usr/src/dahdi-linux-complete-2.6.2+2.6.2/
# make && make install && make config
Installing LibPRI
# cd /usr/src/libpri-1.4.14/
# make && make install
Installing Asterisk

Next, run the “configure” script will vary depending upon whether your system is 32-bit or 64-bit. In the middle, when “menuselect” command executes, select your desired options and then hit “Save and Exit” option and the installation will continuous.
Run this command if you’re installing Asterisk on a 32-bit OS. 
# cd /usr/src/asterisk-11.3.0/
# ./configure && make menuselect && make && make install && make samples && make config
Run this command if you’re installing Asterisk on a 64-bit OS.
# cd /usr/src/asterisk-11.3.0/
# ./configure --libdir=/usr/lib64 && make menuselect && make && make install && make samples
  && make config

Following are the some Asterisk configuration files and their locations.
o    /etc/asterisk/ – configuration files.
o    /var/lib/asterisk/ – contains images, firmware, keys, sounds sample files.
o    /usr/lib/asterisk/modules/ – contains all loadable modules.


Starting DAHDI and Asterisk Services

Enable the DAHDI and Asterisk services at system boot time. 
# chkconfig dahdi on
# chkconfig asterisk on
Start the DAHDI and Asterisk.
# service dahdi start
# service asterisk start

5. Connecting to Asterisk CLI

Run the following command to connect to the Asterisk CLI.


# asterisk -rvvvvv

Asterisk 11.3.0, Copyright (C) 1999 - 2012 Digium, Inc. and others.

Created by Mark Spencer markster@digium.com

Asterisk comes with ABSOLUTELY NO WARRANTY; type 'core show warranty' for details.
This is free software, with components licensed under the GNU General Public
License version 2 and other licenses; you are welcome to redistribute it under
certain conditions. Type 'core show license' for details.

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

Connected to Asterisk 11.3.0 currently running on tecmint (pid = 1820)
tecmint*CLI>

6. Asterisk Console Commands

It’s similar to IOS. From Asterisk terminal anytime you can use ‘Tab key‘ or type ‘?‘ for help or command auto complete.
*CLI>
       

7. Useful Commands from Asterisk CLI

o    restart gracefully – Restart Asterisk gracefully.
o    restart now – Restart immediately.
o    restart when convenient – Restart Asterisk when call is empty.
o    reload – Configuration reload.
o    stop gracefully – Gracefully Asterisk shutdown.
o    stop now – Shutdown immediately.
o    stop when convenient – Shutdown Asterisk when call is empty.

8. Command Line Parameters

Following are the available command line parameters of Asterisk.
-h : Help. Run '/sbin/asterisk -h' to get a list of the available command line parameters.
-C : Starts Asterisk with a different configuration file than the default 
/etc/asterisk/asterisk.conf.
-f : Foreground. Starts Asterisk but does not fork as a background daemon.
-c : Enables console mode. Starts Asterisk in the foreground (implies -f), with a console 
     command line interface (CLI) that can be used to issue commands and view the state of 
     the system.
-r : Remote console. Starts a CLI console which connects to an instance of Asterisk already 
     running on this machine as a background daemon.
-R : Remote console. Starts a CLI console which connects to an instance of Asterisk already 
    running on this machine as a background daemon and attempts to reconnect if disconnected.
-t : Record soundfiles in /var/tmp and move them where they belong after they are done.
-T : Display the time in "Mmm dd hh:mm:ss" format for each line of output to the CLI.
-n : Disable console colorization (for use with -c or -r)
-i: Prompt for cryptographic initialization passcodes at startup.
-p : Run as pseudo-realtime thread. Run with a real-time priority. (Whatever that means.)
-q : Quiet mode (supress output)
-v : Increase verbosity (multiple v's = more verbose)
-V : Display version number and exit.
-d : Enable extra debugging across all modules.
-g : Makes Asterisk dump core in the case of a segmentation violation.
-G  : Run as a group other than the caller.
-U  : Run as a user other than the caller
-x  : Execute command  (only valid with -r)

Autonomous System Number


বৃহস্পতিবার, ২৮ মার্চ, ২০১৩

URL Redirection, SquidGuard, Squint, Sqstat


URL Redirection by squid.conf  :
-----------------------------------------------------
If I want to redirect URL telnet.com.bd to bol-online.com then edit squid.conf file by following information where 172.30.5.0/24 is src network and redirection for src network.
acl mynet src 172.30.5.0/24
acl badsites dstdomain .telnet.com.bd
deny_info http://bol-online.com mynet
http_reply_access deny badsites mynet
then save the squid.conf file and restart squid daemon. Then try by any browser and put telnet.com.bd to address bar output will be bol-online.com

SquidGuard (Web Filter plugin as URL Redirector used to use blacklists)
--------------------------------------------------------------------------------------------

1.       Install squidguard by Apt-get install squidguard
2.    Install blacklists by wget -c http://www.shallalist.de/Downloads/shallalist.tar.gz
3.    Extract shallalist.tar.gz
4.    Copy your required blacklists sush as porn by cp –avr BL/porn /var/lib/squidguard/db/
5.    Create databases from text files by squidGuard –b –C /var/lib/squidguard/db/porn/domains and squidGuard –b –C /var/lib/squidguard/db/porn/urls
6.    Set the permission for read by squid by chown proxy.proxy –R /var/lib/squidguard/db/
7.    Edit squid.conf file by adding url_rewrite_program /usr/bin/squidGuard
8.    Edit /etc/squid/squidGuard.conf file by adding
dest porn {
       domainlist      porn/domains
      
urllist         porn/urls
}
9.    And update acl section by
acl  {
    default {
              pass  !porn all
 redirect http://
}
           }

10. Reload squid by /etc/init.d/squid reload
11. Verify squid and squidGuard loading by viewing log tail -f /var/log/squid3/cache.log
12.  Verify configuration by echo "http://DOMAIN-NAME-HERE / - - GET" | squidGuard –d or browing restricted site from local.
13. Simply add additional restricted site by same as no 8 and 9 step and creating file , db file etc.


Squint (Squid log analyzer and viewer) installation:
--------------------------------------------------------------------

Prerequisites: Squid proxy server, apach2, php5.
 Download squint.tar.gz from internet.
Extract squint.tar.gz
Enter squint directory
cp squint.pl squint.cron.sh /usr/local/bin
cd /usr/local/bin
vim squint.cron.sh
edit to HTTPDCONF=/etc/apache2/apache.conf
execute “squint.cron.sh init” command
execute “squint.cron.sh all” command
edit crontab file and replace Monday to “1” without quote in the line weekly.
Then browse http:// server ip>/squint

Sqstat (To view realtime active user connections):
-----------------------------------------------------------------


prerequisites:
Active PHP Module in Apache:  a2enmod fcgid

apt-get install libapache2-mod-fcgid php5-cgi
extract sqstat-1.20.tar.gz
cp –r sqstat-1.20 /var/www/
cd /var/www/sqstat-1.20
then rename config.inc.php.defaults to config.inc.php
then edit config.inc.php put DEFINE(“SQSTAT_SHOWLEN”,100);
Make sure chachemgr protocol is allowed from localhost.
Browse http:// server ip>/sqstat-1.20/sqstat.php

সোমবার, ২১ জানুয়ারী, ২০১৩

BGP AFI and SAFI


When BGP peers set up their session between them, they send an OPEN message possibly containing optional parameters.
One optional parameter is capabilities. Possible capabilities are Multiprotocol extensions, route refresh, outbound route filtering (ORF), and so on. When the BGP peers exchange the Multiprotocol extension capability, they exchange AFI and SAFI numbers and thus identify what the other BGP speaker is capable of.
IPv6 in BGP is implementated via Multi-Protocol BGP (MPBGP) (RFC 2283), as is MPLS and VPN’s through two new attributes: MP_UNREACH_NLRI and MP_REACH_NLRI. The first two values in these two attributes contain the Address Family Identifier (AFI) and the Subsequent Address Family Identifier (SAFI).
AFI
Meaning
1
IPv4
2
IPv6
.
SAFI
Meaning
1
Unicast
2
Multicast
3
Unicast and multicast
4
MPLS Label
128
MPLS-labeled VPN
If BGP is carrying IPv4 traffic, AFI equals 1, SAFI equals 1 for Unicast, or SAFI equals 4 for MPLS.
If BGP is carrying IPv6 traffic, AFI equals 2, SAFI equals 1 for Unicast, and SAFI equals 2 for multicast.
This is best seen during BGP session negotiation by using the “debug bgp all” command. Obviously use this command with caution and not on full-feed internet peerings.


In the above output you can clearly see these two BGP peers are capable of supporting IPv4 and IPv6 with Unicast and MPLS/VPN’s, along with Route-Refresh.