Friday, August 07, 2009

Installing VirtualBox Guest Additions on Centos

Notes from:
http://forums.virtualbox.org/viewtopic.php?t=4960

Log in as root and type in terminal:


yum install gcc -y
yum install kernel sources -y
yum install kernel-devel -y



Restart the system.
Mount the VboxGuestAdditions.iso.
Move to the following directory:


cd /media/VBOXADDTIONS_2.2.4_47978



As root execute:


sh ./VBoxLinuxAddtions-x86.run



Restart the system again and good luck!

Thursday, February 19, 2009

Home wirelss network with a Cisco Aironet 1130AG

The office drop a Cisco Aironet 1130ag as they upgraded to a newer release and I was able to get hold of it. I am still trying to learn more about Cisco and hope to have my CCNA in a few months and I tested this new toy with great success..

To start, I flatshare and the broadband connection in my place is shared with other people. The access point from my ISP is on a comon room and I use wireless desktops and laptops. My test environement for the Aironet was the following:



This is read as follows:

I use an Ubuntu box as my desktop connected to the "home" wireless network. This desktop has a nic connected to a small 100Mbits switch on a "private" network. To this switch I connected a small Cisco 805 (also discarded away by my company) that I use to play with "cisco" and as DHCP server. Also connected to the switch I have a Winblowz desktop to run those win32 applications I cannot get rid off and I connected the Cisco Aironet 1130AG to it. The Ubuntu desktop is my gateway to the "home wireless network".

I know I could use the Ubuntu box also as DHCP but .... I wanted to play with Cisco and once that was working (quite easy by the way). I never removed it.

Now.. the plan was to have my private wireless network away from my "flatmates" that I could use with my laptop. At the same time I wanted to surf the net so using the existing configuration would allowed me connect to the "private wireless network" by the Aironet, use the Ubuntu box as gateway (as I do from the windoze box) and jump to the "house wireless network" to get into the internet.

All this was quite easy. Old post on this site shows how to configure the Ubuntu box as gateway and how to configure the Cisco 805 as DHCP server and now will write down the configuration of the Cisco Aironet 1130AG I used (that I got from this site).


To start...

a) connected a console cable to the Aironet and to your pc serial port. I used the ubuntu box and minicom.

b) connected the aironet to the switch using a straight through cable.

c) powered on the aironet and log in with privileged mode. It seems the default password is "Cisco".

d) to have WEP enabled just configure the following:


dot11 ssid myssid
authentication open
guest-mode
!
dot11 network-map
power inline negotiation prestandard source
!
!
username Cisco password 7 1531021F0725
!
bridge irb
!
!
interface Dot11Radio0
no ip address
no ip route-cache
!
ssid myssid
!
speed basic-1.0 basic-2.0 basic-5.5 basic-11.0
station-role root
rts threshold 2312
bridge-group 1
bridge-group 1 subscriber-loop-control
bridge-group 1 block-unknown-source
no bridge-group 1 unicast-flooding
bridge-group 1 spanning-disabled
!
interface Dot11Radio1
no ip address
no ip route-cache
!
ssid myssid
!
no dfs band block
channel dfs
station-role root
rts threshold 2312
bridge-group 1
bridge-group 1 subscriber-loop-control
bridge-group 1 block-unknown-source
no bridge-group 1 source-learning
no bridge-group 1 unicast-flooding
bridge-group 1 spanning-disabled
!



The aironet has 2 anthenas Dot11Radio1 and Dot11Radio0 for 802.11a/b/g and they are bridged to fastehternet0 therefore the ip given by the DHCP server is also the same for the wireless interfaces.

As you can see that was it.. quite simple but I guess once I get on with my CCNA and start knowing more about Cisco config I will be able to do more interesting stuff... (radius authentification for example).

This was as good thing to play with and I am sure I will be able to use the Aironet wireless in a best example in the future as right now is just to play around.







Links:
http://www.cisco.com/en/US/docs/wireless/access_point/12.3_7_JA/configuration/guide/s37frst.html#wp1036371

Saturday, January 10, 2009

My notes on Virtualbox in Windows xp

I installed Virtualbox 2.1.0 on my Windowz laptop (new office laptop with +3GB the ram) and I will install Debian etch images on it.

The "host" software installation is quite simple and the "guest" installation is straight forward both on Windowz or Debian.

One note, during setup try set the directory where to install the virtualbox images (.vdi files) on a c:\virt_images directory or similar. The reason is that the default is in your %HOMEDRIVE%HOMEPATH%\.VirtualBox\Hardrives directory that works fine but if you try to clone it using the vboxmanage clonehd the name will bring up some errors.

Example:


C:\Program Files\Sun\xVM VirtualBox>vboxmanage clonehd C:\Documents/and/Settings\username\.VirtualBox\HardDisks\debian_1.vdi C:\Documents/and/Settings\username\.VirtualBox\HardDisks\debian_2.vdi
VirtualBox Command Line Management Interface Version 2.1.0
(C) 2005-2008 Sun Microsystems, Inc.
All rights reserved.

[!] FAILED calling virtualBox->OpenHardDisk2(src, srcDisk.asOutParam()) at line
372!
[!] Primary RC = VBOX_E_IPRT_ERROR (0x80BB0005) - Runtime subsystem error
[!] Full error info present: true , basic error info present: true
[!] Result Code = VBOX_E_IPRT_ERROR (0x80BB0005) - Runtime subsystem error
[!] Text = Could not get the storage format of the hard disk 'C:\Documents\and\Settings\username\.VirtualBox\HardDisks\debian_1.vdi' (VERR_PATH_NOT_FOUND)
[!] Component = HardDisk2, Interface: IHardDisk2, {ed6e2525-c2fd-42a4-917a-7a9045ac9e15}
[!] Callee = IVirtualBox, {339abca2-f47a-4302-87f5-7bc324e6bbde}

C:\Program Files\Sun\xVM VirtualBox>



You can solve this by simple adding "" on the file paths



C:\Program Files\Sun\xVM VirtualBox>vboxmanage clonehd "C:\Documents and Settings\username\.VirtualBox\HardDisks\debian_1.vdi" "C:\Documents and Settings\username\.VirtualBox\HardDisks\debian_2.vdi"
VirtualBox Command Line Management Interface Version 2.1.0
(C) 2005-2008 Sun Microsystems, Inc.
All rights reserved.

0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
Clone hard disk created in format 'VDI'. UUID: e78ab4e8-5666-4bea-a592-b277265c5b19

C:\Program Files\Sun\xVM VirtualBox>




Moving forward, once Virtualbox is installed you can install Debian as normal on one of the images. It will ask for a name, type (linux, windows, etc), memory amount and hard disk image. As it is a new installation we create a new one.

Debian installation is as normal and you shouldn't have any problem. Note I change the networking settings from "NAT" to "host interface" so I can have an IP from my dhcp server and be able to ssh to the "virtual disk".

Once you have Debian installed you need to install "Virtualbox Guest Additions" on it. This was the tricky part for me, the host box would have an iso that can be mounted "dinamically" by going to the "Devices/Install Guest Addtions" guest window menu and it should mount the iso automatically on /media/cdrom but it my case it didn't work. To solve this I install ssh - apt-get install ssh - and copy the iso image from my windows host to the debian guest.

Next I did a:


apt-get install gcc
apt-get install build-essential module-assistant



Next step is buidling the kernel modules


m-a prepare



Next mount the iso file sftp before to you disk:


debvirt01:~# mount -o loop -t iso9660 /home/ricardo/VBoxGuestAdditions.iso /media/cdrom



And finally run the Virtualbox setup:


debvirt01:~# cd /media/cdrom
debvirt01:/media/cdrom# ls
32Bit VBoxLinuxAdditions-amd64.run VBoxWindowsAdditions-amd64.exe
64Bit VBoxLinuxAdditions-x86.run VBoxWindowsAdditions.exe
AUTORUN.INF VBoxSolarisAdditions.pkg VBoxWindowsAdditions-x86.exe
debvirt01:/media/cdrom# sh /media/cdrom/VBoxLinuxAdditions-x86.run
Verifying archive integrity... All good.
Uncompressing VirtualBox 2.1.0 Guest Additions for Linux installation.......................................................................................................................................................................................................
VirtualBox 2.1.0 Guest Additions installation
Building the VirtualBox Guest Additions kernel module...
Building the shared folder support kernel module...
Installing the VirtualBox Guest Additions...

Could not find X.org or XFree86 on the guest system. The X Window drivers
will not be installed.
debvirt01:/media/cdrom#




Ok, that's it. It should fully work now (The x window drivers message is due the fact I didn't install anything else on my original debian install)

To check the modules are running you can do the following:


debvirt01:~# dmesg | grep vbox
vboxadd: Successfully loaded version 2.1.0 (interface 0x00010004)
vboxvfs: Successfully loaded version 2.1.0 (interface 0x00010004)
debvirt01:~#

user@debvirt01:~$ lsmod
Module Size Used by
vboxvfs 41504 0
vboxadd 62816 2 vboxvfs
user@debvirt01:~$




Last thing, I couldn't boot the the image cloned from the original. Both grub and lilo fails to boot and I don't know who to restore fix it. I am trying to find out how to boot with a rescue disk on the "virtual" box and try to restore grub but couldn't find out how yet. Any notes let me know..

---- out of topic -----

Debian Lenny has packages that helps on the process above but when addng the repository on source.lists and running an apt-get update we get the following error:


debvirt01:/etc/apt# apt-get update
W: GPG error: http://download.virtualbox.org etch Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY DCF9F87B6DFBCBAE
W: You may want to run apt-get update to correct these problems
debvirt01:/etc/apt#




This error is the following: "Those are just letting you know the GPG keys arent saved to the disk. The mastering process for some reason deletes the additional keys.....The problem being the sites change gpg codes constantly.."

To solve it just run the following command:



debvirt01:/etc/apt#
wget -q http://download.virtualbox.org/virtualbox/debian/sun_vbox.asc \
-O- | sudo apt-key add -



You will be able to run apt-get update normally and therefore retrieve the necessary virtualbox packages.

Other link with details:

http://johnbokma.com/mexit/2008/11/27/virtualbox-puel-ubuntu.html

Sunday, January 04, 2009

Adding a css to my blog

I noticed that I don't find optimal to find what is commands entry from clear text on my blog so surfing around I found this css entry that I am will start applying whenever I enter a command or code to the page.

On Blogger, on the Layout tab I selected "edit html" and added the following:

/* Added by RB
----------------------------------------------- */

.command{ padding:1em;
border:1px
dashed #2f6fab;
color:black;
background-color:#f9f9f9;
line-height:1.1em;
font-family:Courier New,Courier,mono;
font-size:12px;
font-style:italic
}

Example:

tar -xzvf speex-1.2rc1.tar.gz



:)

Sunday, December 28, 2008

Adding Speex codec on Asterisk Installation

During the installation before compiling asterisk (this can be done after dadhi and libpri) download the souce of speex from http://speex.org/downloads/ into /usr/src/

The installation is quite simple:

tar -xzvf speex-1.2rc1.tar.gz
cd speex-1.2rc1
./configure --prefix=/usr
make
make install
ldconfig
cd ..

Friday, December 26, 2008

Dadhi installation

New asterisk install, this time zaptel is replaced by dahdi. The installation is quite simple just download the files from asterisk.org on /usr/src, untar files and run the following:

cd /usr/src/dahdi-linux-2.1.0.3#
make clean
make
make install


cd /usr/src/dahdi-tools-2.1.0.2#
./configure
make
make install
make config


Two files to check /etc/dahdi/system.conf and /etc/dahdi/init.conf. On the fist one change zone to UK.

After this as I am not running any voice hardware you can run:

modprobe dadhi
modprobe dadhi-dummy


And a lsmod | more will show the following output:


Module Size Used by
dahdi_dummy 5224 0
dahdi 186280 1 dahdi_dummy


Dadhi README notes available at:
http://svn.digium.com/view/dahdi/tools/tags/2.0.0-rc2/UPGRADE.txt?view=co

Thursday, December 25, 2008

Error on Cisco 805 boot (boot#..)

I use a small Cisco 805 as dhcp server in my house. After a power failure the system started with the following prompt:

user@user-desktop:~$ minicom


Welcome to minicom 2.3-rc1

OPTIONS: I18n
Compiled on Dec 10 2007, 10:36:19.
Port /dev/ttyS0

Press CTRL-A Z for help on special keys

TinyROM version 1.4(1)
19:37 11/07/00
Copyright (c) 1998-2000 by cisco Systems, Inc.
All rights reserved.

POST .............. OK. 16MB DRAM, 12MB Flash.

boot#
boot#


Honestly don't know what this is and the commands available were:


boot# help
boot Execute image or CLI command script.
delete Deletes file-name from flash (8th delete is permanent).
disable Disable privileged commands.
echo Display arguments (to test CLI behavior).
enable Enable privileged or debug commands.
erase Erase deleted and invalid files from flash.
help Display help for command (* for all).
list List files currently in ram and saved in flash.
load Load saved boot environment from flash.
passwd Set or change the ROM password.
reset Reset console port to current parameters.
set Set boot environment values.
save Save boot environment or loaded file to flash.
show Show current or saved boot environment.
upload Load image or configuration data into RAM.
undelete Undelete file-name (maximum of 8 deletes & undeletes).
boot#


Luckily googling around I found this page from cisco: http://www.cisco.com/en/US/ts/fn/200/fn27475.html that shows what to do to recover the system.

The command "set" will show the device config and which file it will be use to boot. The output of the set command show that I didn't have any boot image.

boot# set
set baud =9600
set data-bits =8
set parity =none
set stop-bits =1
set console-flags =0
set mac-address =000B.BE48.D887
set unit-ip =0.0.0.0
set serv-ip =0.0.0.0
set netmask =0.0.0.0
set gate-ip =0.0.0.0
set pkt-timeout =4
set tftp-timeout =16
set boot-action =none
set file-name =""
set watchdog =off
set prompt ="boot"
set ios-conf =0xA0
boot#


The second command to use is "list" that shows what you have saved on the ROM. I could find the ios image preset to boot from. Using the "set" command you configure the router to boot using the cisco image like follows:

boot# list
Status Size Dev Name
------ 48K flash TinyROM-1.4(1)
---r-- 911 flash full-config
---r-x 7529K flash c805-xxxx-5.bin
4480K free 12288K total
boot#


The list showed the c805-xxxx.bin being present, using set I change the boot-action and file-name settings:

boot# set boot-action=flash
boot# set file-name="c805-xxxx-5.bin
"

Once done just use the "save" command to (guess...) save the configuration and finally "boot" to load the ios into memory.

boot# save
save: succeeded (0 seconds).
boot# boot
Accessing flash:c805-xxxx-5.bin

Booting "c805-xxxx-5.bin" ...,


After the "Booting c805......" message the system starts as normal.

Monday, December 01, 2008

H.323 delay in outbound dialling

Last week users reported a long delay when dialling out from their SIP extensions. My setup is quite simple.

Avaya PBX connected to the outside world - H323 Trunk to Asterisk - Asterisk connected to SIP users using softphones from their macs/linux laptops (all this because Avaya don't have a decent softphone for macs/linux yet).

The logs for a few test calls showed a 60+ seconds delay from the time the call was dialled to the time the call was placed over the H323 ip trunk between Avaya and Asterisk.

After checking that it was not a sip problem, dialling problem, h323 trunk problem by checking logs, tcpdump, avaya trunk side, etc. I concluded the problem was on the h323 setup on Asterisk.

Googling around I found only 1 case of a user asking on the asterisk user list about a similar problem and that he fixed the problem by "disable h323 srv lookups".

I honestly didn't have about srv-enum-etc but helped me find out the problem. My DNS was not resolving any request because it was down. It didn't matter that on /etc/resolve.conf I had 4 dns entries, the first one was down and it was enough to stop this.

It seems h323 does a srv lookup for enum information before dialing out and possible it can be disabled. I couldn't find how unfortunately so to fix this I had to point the box to another dns server on my network. Once this was done all starting working again.

Just in case I am copying some logs of what I was seeing when the problem was present.

[Nov 28 15:34:09] VERBOSE[10584] logger.c: -- Executing [myavayaextension@default:1] Dial("SIP/myasteriskextension-081b5bc8", "H323/myavayaextension@Avaya") in new stack
[Nov 28 15:34:09] VERBOSE[10584] logger.c: -- Requested transfer capability: 0x00 - SPEECH
------------------- 64 seconds delay -----------------
[Nov 28 15:35:13] VERBOSE[10584] logger.c: -- Called myavayaextension@Avaya
[Nov 28 15:35:13] VERBOSE[10584] logger.c: -- H323/Avaya-31 is making progress passing it to SIP/myasteriskextension-081b5bc8
[Nov 28 15:35:13] VERBOSE[10584] logger.c: -- H323/Avaya-31 is ringing
[Nov 28 15:35:17] VERBOSE[10584] logger.c: -- H323/Avaya-31 answered SIP/myasteriskextension-081b5bc8
[Nov 28 15:35:18] VERBOSE[10584] logger.c: == Spawn extension (default, myavayaextension, 1) exited non-zero on 'SIP/myasteriskextension-081b5bc8'


[Nov 28 15:19:52] VERBOSE[10551] logger.c: -- Executing [myavayaextension@default:1] Dial("SIP/myasteriskextension-081b5bc8", "H323/myavayaextension@Avaya") in new stack
[Nov 28 15:19:52] DEBUG[10551] chan_h323.c: type=H323, format=8, data=myavayaextension@Avaya.
[Nov 28 15:19:52] DEBUG[10551] chan_h323.c: Extension: myavayaextensionHost: Avaya
[Nov 28 15:19:52] DEBUG[10551] chan_h323.c: Calling to myavayaextension@Avaya on H323/Avaya-30
[Nov 28 15:19:52] VERBOSE[10551] logger.c: -- Requested transfer capability: 0x00 - SPEECH
[Nov 28 15:19:52] DEBUG[10551] chan_h323.c: Placing outgoing call to myavayaextension@192.168.58.216:1720, 101
[Nov 28 15:19:52] VERBOSE[10551] logger.c: -- Making call to myavayaextension@192.168.58.216:1720 without gatekeeper.
[Nov 28 15:19:52] VERBOSE[10551] logger.c: Using 192.168.58.227 for outbound call
------------------- 64 seconds delay -----------------
[Nov 28 15:20:56] VERBOSE[10551] logger.c: == New H.323 Connection created.
[Nov 28 15:20:56] VERBOSE[10551] logger.c: -- root is calling host myavayaextension@192.168.58.216:1720
[Nov 28 15:20:56] VERBOSE[10551] logger.c: -- Call token is ip$localhost/9446
[Nov 28 15:20:56] VERBOSE[10551] logger.c: -- Call reference is 9446
[Nov 28 15:20:56] VERBOSE[10551] logger.c: -- DTMF Payload is [pt=101]
[Nov 28 15:20:56] VERBOSE[10551] logger.c: -- Called myavayaextension@Avaya

Notes:
myasteriskextension
myavayaextension = my 5 digit extension on the avaya pbx.

Sunday, June 15, 2008

Start asterisk on boot

I always forget how to start asterisk manually. The steps after installation are:

myserver:/etc/init.d# cp /usr/src/asterisk-1.4.21/contrib/init.d/rc.debian.asterisk /etc/init.d/asterisk

myserver:/etc/init.d# cd /etc/init.d/

myserver:/etc/init.d# ls asterisk
asterisk

myserver:/etc/init.d# chmod 755 asterisk


myserver:/etc/init.d# update-rc.d asterisk defaults
Adding system startup for /etc/init.d/asterisk ...
/etc/rc0.d/K20asterisk -> ../init.d/asterisk
/etc/rc1.d/K20asterisk -> ../init.d/asterisk
/etc/rc6.d/K20asterisk -> ../init.d/asterisk
/etc/rc2.d/S20asterisk -> ../init.d/asterisk
/etc/rc3.d/S20asterisk -> ../init.d/asterisk
/etc/rc4.d/S20asterisk -> ../init.d/asterisk
/etc/rc5.d/S20asterisk -> ../init.d/asterisk

myserver:/etc/init.d#

Private network with Ubuntu and Cisco router as dhcp server

I share my internet connection at my house and I wanted to set up my own network to connect my laptops with the desktops. Using the wireless was not the best option to transfer large files between systems therefore I set up a small network.

The "house" network is on the 192.168.0.0/24 and connects to the internet, my private network is on the 192.168.1.0/24. The devices are connected through a 10/100 switch and except one PC the ip are set by a dhcp server (I don't have more than 5 pcs at the time).

My main pc is an Ubuntu desktop with 2 network cards.
wlan0 - connects to the internet through a wireless router. Uses network 192.168.0.0/24
eth0 - ethernet card to use on my private network. Uses network 192.168.1.0/24

First check your iptables.. run the command iptables -L

user@pc:~$ sudo iptables -L
Chain INPUT (policy ACCEPT)
target prot opt source destination

Chain FORWARD (policy ACCEPT)
target prot opt source destination

Chain OUTPUT (policy ACCEPT)
target prot opt source destination
user@pc:~$

This shows the table is empty. Now to enable internet sharing on the Desktop PC I run the following rules:

$sudo iptables -A FORWARD -i wlan0 -o eth0 -s 192.168.1.0/24 -m state --state NEW -j ACCEPT
$sudo iptables -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT
$sudo iptables -A POSTROUTING -t nat -j MASQUERADE

rule1 allows forwarded packets (initial ones)
rule2 allows forwarding of established connection packets (and those related to ones that started)
rule3 does the NAT

Running iptables -L now shows the following:

user@pc:/home$ sudo iptables -L
Chain INPUT (policy ACCEPT)
target prot opt source destination

Chain FORWARD (policy ACCEPT)
target prot opt source destination
ACCEPT all -- 192.168.1.0/24 anywhere state NEW
ACCEPT all -- anywhere anywhere state RELATED,ESTABLISHED

Chain OUTPUT (policy ACCEPT)
target prot opt source destination
user@pc:/home$

This change is only valid until next reboot, therefore we need to make it permanent. Read the links at the of this post but what I did was the following.

a. First save the current configuration on a local file by running:

sudo sh -c "iptables-save > /home//iptables.rules" 


Many post I read suggest saving the file on /etc/iptables.rules but in my case the file was not being saved at all. Checking logs I found messages of "permission denied" when the system was trying to save the file therefore I used my own directory that I guess is not the best option regarding security.

Another note found was that this process was done on every shutdown. I my case I did it once and will use the same file for every reboot. If I need to change something I will do it live and save the file again.

b. Second set a small script to load the file save with the iptables configuration on boot. This can be done by creating a little shell on the /etc/network/if-pre-up.d directory named iptaload.

user@pc:/etc/network/if-pre-up.d$ ls -l
-rwxr-xr-x 1 root root 65 2009-01-06 20:46 iptaload
user@pc:/etc/network/if-pre-up.d$

The file iptload reads as follows:

user@pc:/etc/network/if-pre-up.d$ more iptaload
#!/bin/sh
iptables-restore < /home//iptables.rules
exit 0
user@pc:/etc/network/if-pre-up.d$

Now at this stage you changed your iptables and should work on every reboot.

Next configure the gateway for routing between two interfaces by enabling IP forwarding. First check the current state using:

cat /proc/sys/net/ipv4/ip_forward

It will show either a 0 or a 1 where:

0=disabled
1=enabled

If the value is 0 to enable it run the following command:

sudo sh -c "echo 1 > /proc/sys/net/ipv4/ip_forward"

Many webpages mention that to make the above change permanent you need to edit /etc/sysctl.conf and add these lines:

net.ipv4.conf.default.forwarding=1
net.ipv4.conf.all.forwarding=1

And run the command:

sudo sysctl -p

That gives the following output:

user@pc:~$ sudo sysctl -p
kernel.printk = 4 4 1 7
kernel.maps_protect = 1
fs.inotify.max_user_watches = 524288
vm.mmap_min_addr = 65536
net.ipv4.conf.default.rp_filter = 1
net.ipv4.conf.all.rp_filter = 1
user@pc:~$

You should now see new forward state using cat /proc/sys/net/ipv4/ip_forward and the change should persist after reboot but the sysctl -p didn't work on my case.

Again another trick, I edited the /etc/rc.local file to execute the change of the ip_forward value on boot. Some people run this with cron every x minutes.. don't know why so often. The rc.local file looks as follows:

user@pc:/etc$ more rc.local
#!/bin/sh -e

sh -c "echo 1 > /proc/sys/net/ipv4/ip_forward"
exit 0
user@pc:/etc$


At this stage you should have a pc that can forward packets from your eth0 that is the private network to your wlan0 that is the "public" network, but remember that your pc does not do DHCP or DNS (at least mine, you can set that up too) so I also set up a DHCP server on an old Cisco 805 router, set the IP of the router to 192.168.1.2 and added a dhcp server config as follows:

ip dhcp excluded-address 192.168.1.1
ip dhcp excluded-address 192.168.1.2
!
ip dhcp pool mynetwork
network 192.168.1.0 255.255.255.0
default-router 192.168.1.1
dns-server 192.168.0.1
!

Where 192.168.1.1 is the ip of my Ubuntu PC and 192.168.1.2 is the ip assigned to the Cisco router.

Why use the Cisco switch? Is it really necessary? No it is not. I know that the ubuntu desktop could also be the dhcp server, and dns server or forward the dns setup of my isp but this gives me a reason to start playing with cisco routers. Next plan is to connect it to a 1700, a pc on that end access the internet from it.

The following link - where I copied this from - shows the step mentioned above and gives more examples and a better explanation about it:
https://help.ubuntu.com/community/Internet/ConnectionSharing?action=show&redirect=InternetConnectionSharing

and

https://help.ubuntu.com/community/IptablesHowTo

Tuesday, May 06, 2008

Cisco Switch 3500XL: password recovery

I found one Cisco Catalyst 3500 XL on the storage room, haven't been used for a while therefore we will play with it. After reboot I noticed it has a password (as it should) on it so the first step is to change it (I am sure the networking guys would not mind :) )

The process is as follows:
Cisco official information:
http://www.cisco.com/warp/public/474/pswdrec_2900xl.html


My notes:
Turn on the power of the Catalyst 3500XL while pressing the "MODE" button. Wait until the light on port 1 is off (and the rest still on). You should see the following information:

C3500XL Boot Loader (C3500-HBOOT-M) Version 12.0(5.2)XU, MAINTENANCE INTERIM SOF
TWARE
Compiled Mon 17-Jul-00 18:42 by ayounes
starting...
Base ethernet MAC Address: 00:04:c1:c4:ed:10
Xmodem file system is available.

The system has been interrupted prior to initializing the
flash filesystem. The following commands will initialize
the flash filesystem, and finish loading the operating
system software:

flash_init
load_helper
boot

switch: flash_init --------------> run the "flash_init" command
Initializing Flash...
flashfs[0]: 112 files, 3 directories
flashfs[0]: 0 orphaned files, 0 orphaned directories
flashfs[0]: Total bytes: 3612672
flashfs[0]: Bytes used: 2776576
flashfs[0]: Bytes available: 836096
flashfs[0]: flashfs fsck took 3 seconds.
...done Initializing Flash.
Boot Sector Filesystem (bs:) installed, fsid: 3
Parameter Block Filesystem (pb:) installed, fsid: 4
switch: load_helper --------------> run the "load_helper" command
switch: dir flash: --------------> run the "dir flash:" command (colon included)
Directory of flash:/

2 -rwx 1645807 c3500XL-c3h2s-mz-120.5.2-XU.bin ----> current image loaded
3 -rwx 94680 c3500XL-diag-mz-120.5.2-XU
4 drwx 6784 html
111 -rwx 272 env_vars
112 -rwx 1020 vlan.dat
114 -rwx 25 snmpengineid
115 -rwx 5606 config.txt
116 -rwx 3436 config.text ----> configuration file loaded

836096 bytes available (2776576 bytes used)
switch:
switch: rename flash:config.text flash:config.old -----------> backup the current configuration file
switch: dir flash:
Directory of flash:/

2 -rwx 1645807 c3500XL-c3h2s-mz-120.5.2-XU.bin
3 -rwx 94680 c3500XL-diag-mz-120.5.2-XU
4 drwx 6784 html
111 -rwx 272 env_vars
112 -rwx 1020 vlan.dat
114 -rwx 25 snmpengineid
115 -rwx 5606 config.txt
116 -rwx 3436 config.old

836096 bytes available (2776576 bytes used)
switch:

switch: boot -----------> run the "boot" to initialize the system. The image will be loaded but no configuration file will be found forcing the system to enter into setup mode.

Loading "flash:c3500XL-c3h2s-mz-120.5.2-XU.bin"...##############################
################################################################################
#############################################

File "flash:c3500XL-c3h2s-mz-120.5.2-XU.bin" uncompressed and installed, entry p
oint: 0x3000
executing...

Restricted Rights Legend

Use, duplication, or disclosure by the Government is
subject to restrictions as set forth in subparagraph
(c) of the Commercial Computer Software - Restricted
Rights clause at FAR sec. 52.227-19 and subparagraph
(c) (1) (ii) of the Rights in Technical Data and Computer
Software clause at DFARS sec. 252.227-7013.

cisco Systems, Inc.
170 West Tasman Drive
San Jose, California 95134-1706



Cisco Internetwork Operating System Software
IOS (tm) C3500XL Software (C3500XL-C3H2S-M), Vers
TERIM SOFTWARE
Copyright (c) 1986-2000 by cisco Systems, Inc.
Compiled Mon 17-Jul-00 18:29 by ayounes
Image text-base: 0x00003000, data-base: 0x00301F3C


Initializing C3500XL flash...
flashfs[1]: 112 files, 3 directories
flashfs[1]: 0 orphaned files, 0 orphaned directories
flashfs[1]: Total bytes: 3612672
flashfs[1]: Bytes used: 2776576
flashfs[1]: Bytes available: 836096
flashfs[1]: flashfs fsck took 3 seconds.
flashfs[1]: Initialization complete.
...done Initializing C3500XL flash.
C3500XL POST: System Board Tes
C3500XL POST: Daughter Card Test: Passed
C3500XL POST: CPU Buffer Test: Passed
C3500XL POST: CPU Notify RAM Test: Passed
C3500XL POST: CPU Interface Test: Passed
C3500XL POST: Testing Switch Core: Passed
C3500XL POST: Testing Buffer Table: Passed
C3500XL POST: Data Buffer Test: Passed
C3500XL POST: Configuring Switch Parameters: Passed
C3500XL POST: Ethernet Controller Test: Passed
C3500XL POST: MII Test: Passed
cisco WS-C3548-XL (PowerPC403) processor (revision 0x01) with 16384K/1024K bytes
of memory.
Processor board ID XXXHNNHHXXX, with hardware revision 0x00
Last reset from power-on

Processor is running Enterprise Edition Software
Cluster command switch capable
Cluster member switch capable
48 FastEthernet/IEEE 802.3 interface(s)
2 Gigabit Ethernet/IEEE 802.3 interface(s)

32K bytes of flash-simulated non-volatile configuration memory.
Base ethernet MAC Address: 00:04:c1:c4:ed:10
Motherboard assembly number: 73-3903-07
Power supply part number: 34-0971-01
Motherboard serial number: XXXNNNNNXXX
Motherboard serial number: XXXNNNNNXXX
Model revision number: A0
Motherboard revision number: B0
Model number: WS-C3548-XL-EN
System serial number: XXXHNNHHXXX
C3500XL INIT: Complete

00:00:34: %SYS-5-RESTART: System restarted --
Cisco Internetwork Operating System Software
IOS (tm) C3500XL Software (C3500XL-C3H2S-M), Version 12.0(5.2)XU, MAINTENANCE IN
TERIM SOFTWARE
Copyright (c) 1986-2000 by cisco Systems, Inc.
Compiled Mon 17-Jul-00 18:29 by ayounes

--- System Configuration Dialog ---

At any point you may enter a question mark '?' for help.
Use ctrl-c to abort configuration dialog at any prompt.
Default settings are in square brackets '[]'.

Continue with configuration dialog? [yes/no]: n -----------> Enter "n" to not use the configuration dialog
Press RETURN to get started. -----------> PRESS ENTER


Switch>
Switch>enable -----------> Run the "enable" command to go into Privileged mode.
Switch#dir flash: -----------> Check the flash to see the "config.old" file is there.
Directory of flash:/

2 -rwx 1645807 Jul 18 2000 01:47:40 c3500XL-c3h2s-mz-120.5.2-XU.bin
3 -rwx 94680 Jul 18 2000 01:47:40 c3500XL-diag-mz-120.5.2-XU
4 drwx 6784 Jul 18 2000 01:47:41 html
111 -rwx 272 Jan 01 1970 00:00:21 env_vars
112 -rwx 1020 Mar 08 1993 04:11:03 vlan.dat
114 -rwx 25 Mar 17 2005 13:29:07 snmpengineid
115 -rwx 5606 Mar 01 1993 00:39:03 config.txt
116 -rwx 3436 Mar 08 1993 02:48:59 config.old

3612672 bytes total (836096 bytes free)
Switch#rename flash:config.old flash:config.text -----------> Restore the config.old to config.text
Destination filename [config.text]? -----------> PRESS ENTER
Switch#

Switch#rename flash:config.old flash:config.text
Destination filename [config.text]?
Switch#copy flash:config.text system:running-config -----------> Copy the configuration file into memory
Destination filename [running-config]? -----------> PRESS ENTER

Switch#
Switch# -----------> At this point you can run a "show running" command to check the configuration of the switch

witch#config t -----------> Enter the "config t" command to enter the configuration global mode.
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#enable secret secret -----------> change the enable password
Switch(config)#enable password password -----------> change the password password
Switch(config)#line vty 0 15 -----------> change the telnet password
Switch(config-line)#password telnet
Switch(config-line)#login
Switch(config-line)#^Z
Switch#
Switch#config t
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#line con 0
Switch(config-line)#password console -----------> change the console password
Switch(config-line)#^Z
Switch#
Switch#write memory -----------> Save configuration into memory
Building configuration...
Switch#


Done, reboot the switch and now you have full access.

Cisco Routers - Basic notes

I am playing with Cisco routers now, this are be my notes:

Internal Components:
  • RAM. Random access memory. This is the working buffer memory.
  • ROM. Read only memory. contains bootstrap process and basic (most of times) IOS for basic functionality (as recover password)
  • FLASH MEMORY. Stores full image of IOS.--
  • NVRAN. non valitle RAM. Does not loose power when turn off.
  • - start up configuration file

Boot process:
  • a. Power on
  • b. Power on Self Test (POST) (check memory, and cards).
  • c. bootstrap from ROM
  • d. looks in FLASH for IOS
  • e. loads the IOS into RAM from FLASH
  • f. IOS looks for configuration in NVRAM
  • f.1 If found it load the IOS into FLASH Memory
  • f.2 If not found executes teh auto setup mode (menu driven system).

Contexts:
router> ----> user mode (show config, telnet, basic)
router# ----> priviliged mode (show commands, pings, save config, backup)
router(config)# ----> global configuraiton mode (configuration interfaces, security, hostname)
Control - Z is to move from global configuration mode to priviliged mode.

Conectivity:
console port password -----> line con 0
auxiliary port password ---> line aux 0
telnet password -----------> line vty 0 4


Set up a passwords:
On the glboal configuration mode run the following commands to set up a password for the enable command:

router(config)# enable password xxxxxxxxxxx (sets the password but it is shown on screen)
router(config)# enable secret xxxxxxxxxxxxx (sets an encrypted enable password, once secret is enabled password by itself don't work anymore)

To set up password for different access:

router#
router(config)#line console 0 | line auxiliary 0 | line vty 0 4
router(config-line)# login (to ask for prompt)
router(config-line)# password xxxxxxxxxxxxx (to set up the passwod)
control-Z

To encrypt all passwords runt the following command:
router(config)service password-encryption

To set up a banner:
router(config)#banner motd $ message message message $
(Note $ is the delimeter and can be anything, just check to have spaces at the end and beginning)

Setting up an IP on an ehternet port:
A show running-config shows that I have one fastethernet port not configured, set as:
interface FastEthernet0
no ip address
shutdown
speed auto

I will change it to:

interface FastEthernet0
no ip address
shutdown
speed auto

To do this run:

1721-router#config t ---------> to enter global configuraiton mode
Enter configuration commands, one per line. End with CNTL/Z.
1721-router(config)#interface f0 ----> to enter configuration of fastethernet 0
1721-router(config-if)#ip address 192.168.1.3 255.255.255.0
1721-router(config-if)#no shutdown ----> to activate
1721-router(config-if)#
*Mar 1 07:56:30.838: %LINK-3-UPDOWN: Interface FastEthernet0, changed state top ----> that means I have physical connectivity
*Mar 1 07:56:31.838: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEther,change to up ------> shows I have encapsulation. Connections to another host.
1721-router#ping 192.168.1.1 ----> to test that is working I ping a pc on the network
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.1.1, timeout is 2 seconds:
.!!!!
Success rate is 80 percent (4/5), round-trip min/avg/max = 1/1/1 ms
1721-router#

To save the configuration:
router#copy running-config start-config ----> for IOS version 12 and above
router#write memmory ---------> before IOS version 12

Example:
1721-router#copy run star
Destination filename [startup-config]?
Building configuration...
[OK]
1721-router#

To backup config:
router#copy run tftp --> this copy the running configuration TO the tftp server (will ask for details)
router#copy tftp run/start --> this copy the running configuration FROM the tftp server (will ask for details)
(NOT TESTED YET)



my passwords:
enable password/secret
console console
aux aux
telnet1-4 telnet
telnet0 telnet0

Sunday, May 04, 2008

Notes on my D-Link DWL-G520+ with Ubuntu 8.04

Don't recall how I install the board, I think that I just plug it in and Ubuntu did it's magic (long gone the days of having to install modules, recompile kernels, etc).

So the board was recognized but when I tried to log into my wireless network my pc froze, halted, stop working, didn't answer, etc. . The process was quite simple, turn on the pc and on the nm-applet select the essid of my home network. Enter the key or passphrase and done.

The problem starts at this moment, the pc is complete frozen. No mouse, ctrl-alt-backspace, ast-f1/f9, ssh to it, nothing.. no response at all. Therefore the next step was to unplug it and start again but after the 3rd attempt it was obvious that there was a problem somewhere.

My guess is that the nm-applet is trying to execute itself without sudo therefore a pop up asking for the password should appear but that never happened and the pc goes into frozen mode waiting for somebody/something to enter the sudo password to continue. (at least that is my theory). To go around this what I did was to add the details manually on the configuration file. The steps are below:

The D-Link DWL-G520+ is recoganized as follows:
richard:/etc/network$ lspci
05:09.0 Network controller: Texas Instruments ACX 111 54Mbps Wireless Interface
40:00.0 Ethernet controller: Broadcom Corporation NetXtreme BCM5751 Gigabit Ethernet PCI Express (rev 01)
richard$

on /etc/network/interfaces you enter the following settings for your wlan0.

richard:/etc/network$ more interfaces
auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static
address 192.168.1.1
netmask 255.255.255.0
gateway 192.168.1.1

auto wlan0
iface wlan0 inet dhcp
wireless-key
wireless-essid
richard:/etc/network$

Finally you restart you network devices:

sudo /etc/init.d/networking restart

and done.. that connects you to your home wireless network. (forget about the eht0, that is for something else).

If somebody reads this, follow it as last resource. Google quite a lot first and when you find the correct solution let me know.

good luck.

Tips to register to freenode irc (ubuntu and asterisk)

Notes from http://www.wikihow.com/Register-a-User-Name-on-Freenode

1. Join the Freenode network. Open your favorite IRC client and type:
/server irc.freenode.net

2. Idintfiy your nick.
/msg NickServ IDENTIFY

3. Change your user name to the user name you have chosen. Suppose you chose the nick "rocketship". Type the following in the window titled Freenode:
/nick rocketship

4. Register your nick or user name. Type the following command and replace "your_password" with a password that will be easy to remember.
/msg nickserv register your_password

5. Associate a valid email address with your user name. This step is important because it will allow you to assign a new password in case you forget the current one. Type the following:
/msg nickserv set email your-email

If you want your email address to remain private, use the following command:
/msg nickserv set hide email on

6. Register an alternate nickname using the same password. If you would like to register an alternate nickname, repeat the same procedure, using steps 2 to 4.

7. Link your two user names. This will make your two nicknames function as one in various ways. For example, you will not have to sign in each time you wish to change your nickname. Many people change their nicknames to a variant that indicates that they are absent. The linked nicknames will also share memos (messages sent through MemoServ), access to channels, etc. Type the following, when you are using your secondary nickname:
/msg nickserv link your_primary_nick your_password

8. Identify with Nickserv. Each time you connect, you should sign in, or "identify" yourself, using the following command:
/msg nickserv identify your_password

ragblogin+unitedkingdon+argentina

Sunday, April 27, 2008

How to Play Encrypted DVDs in Hardy

In order to play DVDs you need to install the Medibuntu Repository and a couple of packages.


This will add the Medibuntu repository to your repository lists
In a terminal type:
sudo wget http://www.medibuntu.org/sources.list.d/hardy.list -O /etc/apt/sources.list.d/medibuntu.list

Then you have to add the GPG Key to authentic the packages
In a terminal type:
wget -q http://packages.medibuntu.org/medibuntu-key.gpg -O- | sudo apt-key add -

Now update your system to load the Medibuntu repository into your apt-get sources
sudo apt-get update

Download the DVDs playback packages
In a terminal type:
sudo apt-get install libdvdcss2 libdvdread3

Friday, April 25, 2008

Read usb pen drive on ubuntu server

Insert pen drive and cehck the file below to see how the USB stick is being recognized:

sudo vi /var/log/messages

Apr 25 17:46:29 lmnuknet03 kernel: [19465.773928] usb 4-5: new high speed USB device using ehci_hcd and address 2
Apr 25 17:46:29 lmnuknet03 kernel: [19465.927909] usb 4-5: configuration #1 chosen from 1 choice
Apr 25 17:46:29 lmnuknet03 kernel: [19465.993713] usbcore: registered new interface driver libusual
Apr 25 17:46:29 lmnuknet03 kernel: [19466.008173] Initializing USB Mass Storage driver...
Apr 25 17:46:29 lmnuknet03 kernel: [19466.010379] scsi4 : SCSI emulation for USB Mass Storage devices
Apr 25 17:46:29 lmnuknet03 kernel: [19466.011834] usbcore: registered new interface driver usb-storage
Apr 25 17:46:29 lmnuknet03 kernel: [19466.011843] USB Mass Storage support registered.
Apr 25 17:46:34 lmnuknet03 kernel: [19470.992039] scsi 4:0:0:0: Direct-Access Kingston DataTraveler 2.0 PMAP PQ: 0 ANSI: 0 CCS
Apr 25 17:46:35 lmnuknet03 kernel: [19471.530326] sd 4:0:0:0: [sdb] 977664 512-byte hardware sectors (501 MB)
Apr 25 17:46:35 lmnuknet03 kernel: [19471.531203] sd 4:0:0:0: [sdb] Write Protect is off
Apr 25 17:46:35 lmnuknet03 kernel: [19471.533813] sd 4:0:0:0: [sdb] 977664 512-byte hardware sectors (501 MB)
Apr 25 17:46:35 lmnuknet03 kernel: [19471.534442] sd 4:0:0:0: [sdb] Write Protect is off
Apr 25 17:46:35 lmnuknet03 kernel: [19471.534473] sdb: sdb1
Apr 25 17:46:35 lmnuknet03 kernel: [19471.535263] sd 4:0:0:0: [sdb] Attached SCSI removable disk
Apr 25 17:46:35 lmnuknet03 kernel: [19471.535315] sd 4:0:0:0: Attached scsi generic sg2 type 0



Create a directory where to mount the drive. Example is:
$mkdir /tmp/pen

Mount the pen drive on the new directory:
$sudo mount /dev/sdb1 -t auto /tmp/pen

Access the files:
$cd /tmp/pen

Tftp server ubuntu

Install TFTT application:

apt-get install tftpd-hpa

Edit the following file as follows:

$sudo vi /etc/default/tftpd-hpa
# /etc/default/tftpd-hpa
RUN_DAEMON="yes" -----> CHANGED FROM "NO"
OPTIONS="-l -s /home/pxetero/"

Start the process:

$sudo /etc/init.d/tftpd-hpa start

Check the application is set up:

$sudo /etc/inted.conf
#:BOOT: TFTP Service is provided primarly for booting. Most sites
# run this only on machines as "boot servers".
tftp dgram udp wait root /usr/sbin/in.tftpd /usr/sbin/in.tftpd -s /var/lib/tftpboot

Thursday, April 17, 2008

ntpadate/nagios

Just a couple of notes..

Nagios --> after changes run:

582 /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
583 /etc/init.d/nagios restart

Ntpdate --> run

595 ntpdate xxx.xxx.xxx.xxx

Nagios --> Configure Nagios to automatically start when the system boots.

#ln -s /etc/init.d/nagios /etc/rcS.d/S99nagios


Nagios --> add users
a) create the user
htpasswd /usr/local/nagios/etc/htpasswd.users username
b) give rights to see hosts/services/etc.
vi /usr/local/nagios/etc/cfig.cfg

Thursday, February 14, 2008

Asterisk TTS example on 1.4

Following previous posts the following examples can be use to test the usage of TTS from the dialplan in Asterisk.

Example 1:
We set up small script that will be executed from the Asterisk dialplan. This script will take as parameter the text that will be transform to a wav file to later be played.

On extensions.conf configure the following extensions:

exten => 1222,1,Answer()
exten => 1222,n,Set(TEST="Welcome to TTS example")
exten => 1222,n,System(/tmp/test2.sh ${TEST})
exten => 1222,n,Playback(/tmp/test)
exten => 1222,n,Hangup()


On /tmp/test2.sh (add necessary rights to the file) configure the following shell script:

#!/bin/bash
#delete any previous file
/bin/rm -rf /tmp/test.wav

#Convert the text to a wav file
/opt/swift/bin/swift -o /tmp/test.wav -p audio/sampling-rate=8000,audio/channels=1 " $@"

#Don't run sox until swift is done
wait
/usr/bin/sox /tmp/test.wav /tmp/newtest.wav trim 7.5

#copy the old file with the trimmed file
/bin/cp /tmp/newtest.wav /tmp/test.wav


Sox is an application that allows you manipulate/convert audio files from the command line. The page with information about it is http://sox.sourceforge.net/. The installation is quite simple on Debian "apt-get install sox".

The content of the asterisk variable ${TEST} is send as parameters of the shell script. The script uses $1...$n as parameters but you can use $@ to use all the parameters sent. (there must be a better way!! to do this). The following line convert the text into a wav file and save it as /tmp/test.wav.

/opt/swift/bin/swift -o /tmp/test.wav -p audio/sampling-rate=8000,audio/channels=1 " $@"

Once we run it we use sox to trim the first 7.5 seconds of the file that we don't need for this test. This creates a new file named newtest.wav (original no?)

Finally we rename the file to the original name and is later played by asterisk dialplan with the command "exten => 1222,n,Playback(/tmp/test)"

Note this is just a demo/test/proof of concept. For production you should buy some licenses and evaluate the usage of the app_swift from Asterisk to improve this.

Example2:
Using the example below we create a demo "time of the day" service.

The configuration of the extensions.conf file is pretty much the same but we remove the commands to send a text to it.

exten => 1222,1,Answer()
exten => 1222,n,System(/tmp/test2.sh)
exten => 1222,n,Playback(/tmp/test)
exten => 1222,n,Hangup()


The script only has the details to get the different elements of the date from the unix system and concatenate them on a single string to be converted to wav file later by swift. The shell looks like this:

#!/bin/bash
hour=`date +'%l'`
am=`date +'%p'`
minute=`date +'%M'`
day=`date +'%d'`
month=`date +'%B'`
year=`date '+20%y'`

texto="The current time is $hour:$minute $am . Today is the $month-$day-$year "


#delete any previous file
/bin/rm -rf /tmp/test.wav

#Convert the text to a wav file
/opt/swift/bin/swift -o /tmp/test.wav -p audio/sampling-rate=8000,audio/channels=1 " $texto"

#Don't run sox until swift is done
wait
/usr/bin/sox /tmp/test.wav /tmp/newtest.wav trim 7.5

#copy the old file with the trimmed file
/bin/cp /tmp/newtest.wav /tmp/test.wav
#!/bin/bash


The played TTS can be improved to make it more user friendly.

Other date options:
man strftime
%A is replaced by the locale's full weekday name.
%a is replaced by the locale's abbreviated weekday name.
%B is replaced by the locale's full month name.
%b or %h is replaced by the locale's abbreviated month name.
%C is replaced by the century (a year divided by 100 and truncated to an integer) as a decimal number (00-99).
%c is replaced by the locale's appropriate date and time representation.
%D is replaced by the date in the format ``%m/%d/%y''.
%d is replaced by the day of the month as a decimal number (01-31).
%e is replaced by the day of month as a decimal number (1-31); single digits are preceded by a blank.
%H is replaced by the hour (24-hour clock) as a decimal number (00-23).
%I is replaced by the hour (12-hour clock) as a decimal number (01-12).
%j is replaced by the day of the year as a decimal number (001-366).
%k is replaced by the hour (24-hour clock) as a decimal number (0-23); single digits are preceded by a blank.
%l is replaced by the hour (12-hour clock) as a decimal number (1-12); single digits are preceded by a blank.
%M is replaced by the minute as a decimal number (00-59).
%m is replaced by the month as a decimal number (01-12).
%n is replaced by a newline.
%p is replaced by the locale's equivalent of either ``AM'' or ``PM''.
%R is replaced by the time in the format ``%H:%M''.
%r is replaced by the locale's representation of 12-hour clock time using AM/PM notation.
%T is replaced by the time in the format ``%H:%M:%S''.
%t is replaced by a tab.
%S is replaced by the second as a decimal number (00-60).
%s is replaced by the number of seconds since the Epoch, UCT (seemktime(3)).
%U is replaced by the week number of the year (Sunday as the first day of the week) as a decimal number (00-53).
%u is replaced by the weekday (Monday as the first day of the week) as a decimal number (1-7).
%V is replaced by the week number of the year (Monday as the first day of the week) as a decimal number (01-53). If the week containing January 1 has four or more days in the new year, then it is week 1; otherwise it is week 53 of the previous year, and the next week is week 1.
%W is replaced by the week number of the year (Monday as the first day of the week) as a decimal number (00-53).
%w is replaced by the weekday (Sunday as the first day of the week) as a decimal number (0-6).
%X is replaced by the locale's appropriate time representation.
%x is replaced by the locale's appropriate date representation.
%Y is replaced by the year with century as a decimal number.
%y is replaced by the year without century as a decimal number (00-99).
%Z is replaced by the time zone name.
%% is replaced by `%'.

Cepstral Allison on Asterisk 1.4 Test

Download the Ceptrals voice of your preference and system. I like Allison particularly better than the UK one.

Do the download on /usr/src.

lmntel01:/usr/src# wget http://downloads.cepstral.com/cepstral/i386-linux/Cepstral_Allison_i386-linux_4.2.1.tar.gz
--22:01:46-- http://downloads.cepstral.com/cepstral/i386-linux/Cepstral_Allison_i386-linux_4.2.1.tar.gz
=> `Cepstral_Allison_i386-linux_4.2.1.tar.gz'
Resolving downloads.cepstral.com... 216.92.127.89
Connecting to downloads.cepstral.com|216.92.127.89|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 107,474,833 (102M) [application/x-tar]

100%[========================================>] 107,474,833 1.15M/s ETA 00:00

22:03:26 (1.03 MB/s) - `Cepstral_Allison_i386-linux_4.2.1.tar.gz' saved [107474833/107474833]

lmntel01:/usr/src#


Untar the file and enter the directory:

lmntel01:/usr/src#tar -xzvf Cepstral_Allison_i386-linux_4.2.1.tar.gz
lmntel01:/usr/src#cd Cepstral_Allison_i386-linux_4.2.1

Execute the installation script:

lmntel01:/usr/src/Cepstral_Allison_i386-linux_4.2.1/#./install.sh


The installation process goes like this:

Do you agree to these terms? Enter -yes- to continue: yes

Install into what directory? [/opt/swift]

Swift will be installed in the following directories:

Voices in /opt/swift/voices
Shared libraries in /opt/swift/lib
Binaries in /opt/swift/bin
Configuration file in /opt/swift/etc
Header files in /opt/swift/include
Examples in /opt/swift/examples
Sound effects filters in /opt/swift/sfx
Documentation in /opt/swift/doc

Is this acceptable? Enter 'yes' to continue: yes


Installing libraries...

***************************************************************************
If you are installing Swift system-wide, you may need to add the following
line to /etc/ld.so.conf and run ldconfig as root:

/opt/swift/lib

(Otherwise, you will need to add it to the LD_LIBRARY_PATH environment
variable in order to run programs linked against the Swift libraries.)
***************************************************************************

Installing voice Allison...

Creating configuration...

Installing binaries...
Installing symbolic link to swift...
Installing man page...

Setting permissions...

Testing the installed swift binary...
/opt/swift/bin/swift -o /dev/null 'hello world'

***************************************************************************
****************** Installation Completed Successfully! *******************
***************************************************************************

lmntel01:/usr/src/Cepstral_Allison_i386-linux_4.2.1/#


After this you must restart Asterisk and after the reboot to confirm the installation run the command below and check the outpu.

lmntel01:/usr/src/Cepstral_Allison_i386-linux_4.2.1/#asterisk -rx "core show application swift"

-= Info about application 'Swift' =-

[Synopsis]
Speak text through Swift text-to-speech engine.

[Description]
Swift(text) Speaks the given text through the Swift TTS engine.
Returns -1 on hangup or 0 otherwise. User can exit by pressing any key.

-- Remote UNIX connection
rbast:~/Cepstral_Allison_i386-linux_4.2.1#


Also you can generate a TTS wav file on the command line by running:

To test the installation you can:
/opt/swift/bin/swift -o /tmp/test.wav -p audio/sampling-rate=8000,audio/channels=1 "This is a test."

And finally just create an extension on the context of your choice to play it:

exten => 1234,1,Answer()
exten => 1234,2,Playback(/tmp/test)
exten => 1234,3,Hangup()

You will notice that as there is not a license for this package you will hear an introduction message asking you to buy a license on Cepstral web site.