• 09 Jul 2010 /  ESXi4, VMware

    I wrote this article because I wanted to install an ESXi4 on a System with unsupported Network card, thus I had to modify the oem.tgz. As it is so much easier nowadays to use USB Sticks to install a new system I wanted to use one of those for the task. Unfortunately it took me a really long time to figure out how to modify the oem.tgz and, far more important, include it onto the USB Stick that it would be loaded properly during the installation process. I put it on the root of the USB Stick, but you also have to adjust the bootloaders config files to read the oem.tgz during the boot process if there was no oem.tgz on the root of the original source .iso. So here is a step-by-step guide to put the ESXi install .iso on a USB Stick and put the oem.tgz on it properly:


    • ESXi4 Install ISO (I used VMware-VMvisor-Installer-4.0.0.Update01-208167.x86_64.iso)
    • A Computer running Linux (This can also be a Live Linux…)
    • USB Stick with at least 512MB

    All process except  the creation of the oem.tgz can also be done from a Windows. Actually everything could be done from a Windows but I didn’t wanted to install the necessary programs as it’s quite comfortable over a shell.

    Building the oem.tgz

    First of all you need to know what you want to do with the oem.tgz. In my case, I wanted to include a driver for a RTL8101e (R8169) as well as the driver for an Atheros L1E (atl1e). I found a suitable driver for both the cards an now wanted to put it back on (you can get a modified oem.tgz working for this two and some other devices here; if you use this, you can skip this step creating the oem.tgz). First I created a folder “oem” in which I put all the necessary files:


    Withing the simple.map, I had to add the corresponding PCI ID’s with the driver. You can find the PCI ID’s with lspci (on linux) or on “Hardware Properties” / Details / Hardware IDs (on Windows).  In my case, I had to add the following lines in simple.map:

    10ec:8136 0000:0000 network r8169.o
    1969:1026 0000:0000 network atl1e.o

    As the .o files are already in place, the next step is just to put everything into the oem.tgz archive. Check to be in the oem folder and then run:

    tar czvf ../oem.tgz *
    cd ..

    This was the easy part, now we want to create a new .iso with the proper oem.tgz in it. This files is located on the original iso: There is a file image.tgz, within this archive is a bz2 compressed file  VMware-VMvisor-big-208167-x86_64.dd. On this Image, there is it, the oem.tgz. So first we create a folder structure to fit the needs:

    mkdir ddimg img iso iso-mnt

    Next, we mount the original .iso and copy the content to the iso-mnt folder:

    mount -o loop -t iso9660 /path/to/original/.iso iso-mount
    cp -r iso-mnt/* iso/
    umount iso-mnt

    Now we extract the image.tgz from the iso into the img folder and uncompress it:

    tar zxvf iso/image.tgz -C img/
    cd image/usr/lib/vmware/installer/
    bunzip2 VMware-VMvisor-big-208167-x86_64.dd.bz2 (or the name of the file you find in this folder)

    Now we mount the .dd image:

    mount -o loop,offset=$((512*8224)) VMware-VMvisor-big-208167-x86_64.dd ../../../../../dd-img/

    Next, we copy the oem.tgz file into the mounted .dd image and unmount it again:

    cd ../../../../../
    cp oem.tgz dd-img/
    umount dd-img/

    Now we have to compress the .dd image file again, and create the whole archive of image.tgz:

    cd img/
    bzip2 usr/lib/vmware/installer/VMware-VMvisor-big-208167-x86_64.dd
    tar zvcf ../iso/image.tgz usr/

    Finally, we want to create the final .iso with the modifications:

    cd ../iso
    mkisofs -o ../ESXi4-install-modified.iso -b isolinux.bin -c boot.cat -no-emul-boot -boot-load-size 4 \
    -boot-info-table .

    When you are sure that you have the right files on your iso, you can clean up…

    cd ../
    rm -rf iso/
    rm -rf iso-mnt/
    rm -rf img/
    rm -rf dd-img/
    rm -rf oem/

    Now we have our .iso and we want to put it on the USB Stick. For this I used a tool called “unetbootin”, you can get it here. Get the version for you OS and start it (alternatively if you don’t have an X you could also use Syslinux. Select the .iso and select your USB Stick device and start the process.

    After this is done, we also need to put the oem.tgz onto the root of the USB Stick and modify the bootloaders config to load the file during the boot process:

    cp oem.tgz /path/to/USB-Stick-root/
    nano ubnfilel.txt

    Here, you add “OEM.TGZ” in a new line between README.TXT and SYS.VGZ

    Now we also have to adjust the bootloaders config: You have to add a ” — oem.tgz” to the ESXi Installer append string. Before it looks like this:

    append initrd=/ubninit vmkboot.gz --- vmkernel.gz --- sys.vgz --- cim.vgz --- ienviron.tgz \
    --- image.tgz --- install.tgz

    Change to:

    append initrd=/ubninit vmkboot.gz --- vmkernel.gz --- sys.vgz --- cim.vgz --- ienviron.tgz \
    --- image.tgz --- install.tgz --- oem.tgz

    Do the same to ISOLINUX.CFG and now you are done! Eject the USB Stick, put it into the desired computer and boot from usb – done :)

    I hope this might help some guys to save some time ;) Any comments are appreciated.

    Here are the pages I used to create this Guide:


    Tags: , , , , , , , , , , , , , , , ,

  • 17 Aug 2009 /  Cacti, Network, SNMP

    Recently after setting up a Cacti to monitor the traffic of our company’s backbone connections I was very surprised to see  that not a single link would carry much more than 100Mbps. Actually, the nightly backups could not have been finished by the time with the displayed bandwith. The first impression was like the traffic statistics are just wrong but after some research, I figured out that the probelm was just with the traffic exceeding 114Mbps.

    Solution: The SNMP values Cacti receives with almost all traffic templates from the (in this case) Cisco Switches are “Counter32″ values, however, a “Counter32″ value can represent 114Mbps at most so it is obvious that you will not see any graphic showing more throughput. The solution is to use 64Bit-Counter bit Counters. There is a Counter64Bit template there as well, but as I started to use Cacti I did not know what was meant by 64Bit-Counter.

    By default there is just a 64Bit-Counter Template for In/Out Bit’s. If you want the “In/Out Bit’s with Total Traffic” template to use 64Bit Counters you have to change the Data Sources for these Templates. Go to Data Queries –> SNMP – Interface Statistics and choose the Associated Graph Template you want to change. Here you have to change the data sources from IfInOctets to IfHCInOctets and IfOutOctets to IfHCOutOctets. Be sure you are using SNMP V2c (or even V3 if you are out of your mind ;) ) as SNMP V1 does not support the Counter64 OID’s.


    [Original Solution: http://www.ducea.com/2009/02/25/cactisnmp-64-bit-counters-for-a-cisco-gigabit-switch/ ]

    Tags: , , , , , , ,

  • 10 Jul 2009 /  Asterisk, Uncategorized, VoIP

    Finally my exams are over and I had some time to work on my asterisk PBX again. As I have mentioned before, I wanted to improve the CID Resolution script to be able to check a calling number against an internal Database first. If there is no match on this database, it should proceed as before, check the tel.search.ch directory.

    After some research and tests of different ideas fond on the net I decided to implement this myself. As the the existing cidres script itself is a php script it is almost obvious to add this improvement here istead of trying to get it done within asterisk itself.

    To check against an internal Database you need to have such one first :) I have chosen to make an own very small Phonebook with just the name and the number each time. Of course it would be easy to add fields for street, city etc. but since I just wannt it to be used as directory and CID resolution this is sufficient for me.

    First of all I have searched for a valid user and password to use the trixbox Mysql server. One such pair can be found here:

    • cat /etc/asterisk/cdr_mysql.conf

    In my case the username is asteriskuser with password amp109, I think these are always the same on trixbox.

    After a login I have figured out that this user has no permissions to create a new database. Sinc I don’t wanted to add a table into the main asterisk databases, I have used the test database which is already present. So no I have just added an new table there:

    • mysql asteriskuser -p test
    • CREATE TABLE `phonebook` (
       `id` int(4) NOT NULL auto_increment,
       `name` varchar(32) NOT NULL,
       `number` varchar(16) NOT NULL,
       PRIMARY KEY  (`id`)

    Now you can add some test entrys here. By now I have not made a GUI for managing the database as my numbers do not change very frequently, so I have done it all from the console. You can add entrys with the following:

    • INSERT INTO `phonebook` VALUES (1,'TheName','0123456789')

    Next step was to adjust the cidres scrip. Now it should look in the local database first and just check tel.search.ch if there is no local match. The script now looks like this:

    /*** tel.search.ch Lookup Tool ***/
    /*** for use with Asterisk as  ***/
    /*** CID Lookup                ***/
    /*** By Gregor Jeker           ***/
    /*** Distribution under terms  ***/
    /*** of the GPL                ***/
    $tel = $_GET['tel'];
    @mysql_select_db($database) or die( "Unable to select database");
     $query  = "SELECT name FROM phonebook WHERE number=$tel";
     $result = mysql_query($query);
     if (!mysql_num_rows($result) == 0) {
     print $name;
     else {
     $snoopy = new Snoopy;
     $snoopy->fetch("http://tel.search.ch/api/" . "?tel=$tel");
     $xmlobj = simplexml_load_string($snoopy->results);
     if ($xmlobj->entry->title == "")
     { print "No Entry Found"; }
     { print $xmlobj->entry->title; }

    As you can see there is no special handling if a number is added multiple times with different names.

    Now as this script has replaced the old one (for people who haven not used this before: take a look how to install it here). You don’t have to change anything on asterisk / trixbox if you have used the cidres before, so let’s give it a try. You can still check it with you browser by pointing it to

    • http://WebserverWithCIDRES/cidres/?tel=0123456789

    and it should return you the entered name. Now if you want to use this directory as external directory for your Cisco 7960, you can use the folowing script as well. The 7960 requires a xml page as it is descriped here. Here is the php script that creates you this site:

    /*** XML Directory script      ***/
    /*** for use with Cisco 7960   ***/
    /*** IP Phones                 ***/
    /*** By Gregor Jeker           ***/
    /*** Distribution under terms  ***/
    /*** of the GPL                ***/

    header("Content-type: text/xml");header("Connection: close");
    header("Expires: -1");

    mysql_connect(localhost,$username,$password);@mysql_select_db($database) or die( "Unable to select database");

    $query="SELECT name, number FROM phonebook order by name";$result=mysql_query($query);

    echo "<CiscoIPPhoneDirectory>\n";
    echo "<Title>Jeker Telefonbuch</Title>\n";
    echo "<Prompt>Prompt text</Prompt>\n";

    while ($i < $num)
    echo "<DirectoryEntry>\n";
    echo "<Name>$name</Name>\n";
    echo "<Telephone>$number</Telephone>\n";
    echo "</DirectoryEntry>";

    echo "</CiscoIPPhoneDirectory>";?>

    I have also putten this script into the cidres folder and thus it can be accessed through

    • http://WebserverWithCIDRES/cidres/dir.php

    To use it with you Cisco 7960, you have to configure the directories URL. This can be done manually in the SIPDefault.cnf configuration script (if it is not overwritten bi the specific SIP’MACADDRESS’.cnf files) or on Trixbox on PBX –> Endpoint Manager. There you can add this Value on Cisco Phones –> Cisco Phone Default Config.  Just enter http://WebserverWithCIDRES/cidres/dir.php as Directory URL and save everything. If you want to do this entry per hand, you will find the SIPDefault.cnf on a Trixbox installation at /tftpboot/SIPDefault.cnf.

    You can download the required files here: cidres-1.01.tar.gz

    Feel free to leave leave a comment or further suggestions.

  • 11 Feb 2009 /  Asterisk, VoIP

    One of PBX most useful features in my eyes is to dynamically modify the Caller ID Name on incoming calls. Usually asterisk can check against an internal database which has the disadvantage that you need to enter all the number / name pairs into the database. But what about unknown numbers?

    Actually the best solution is to check the national electronic telephone directory. In Switzerland, this would usually be directories.ch but there does not seem to be an API which could be used. Another local directory is tel.search.ch, which might not be as complete as directories.ch (no cellphone numbers) but there are still a LOT of numbers stored.

    There is a module called “CallerID Lookup Sources” in FreePBX (Installed by default on Trixbox 2.6) which allows you to check numbers via HTTP.
    From the tel.search.ch API, you get a XML response by querying http://tel.search.ch/api/?tel=0123456789. In the XML response, there are two interesting attributes:

    • Entry -> Title; Returns the Name
    • Entry -> Content; Returns the Name, Title and Address

    As Asterisk just seems to accept one line as the CallerID Name, I use the Entry -> Title attribute.

    With this information, I wrote a PHP script which just returns the name by passing the calling number. The script accesses the tel.search.ch page using Snoopie which is a PHP class. Then it just gets the name from the XML response and returns it – that’s it. It is not very pretty but it works well. You can download a copy of the script including the Snoopie Class here.

    In my case (Trixbox), I copied the cidres directory to /var/www/html. Then, you can of course test whether http://<IP-of-Server>/cidres/?tel=1811 returns “Auskunft Swisscom”. As you can see, you have to give the parameter tel to index.php, where you will pass the number to the script.

    If this works, you can configure FreePBX. Therefore, you have to enter following values in the “CallerID Lookup Sources” configuration page:

    • Source Type: “HTTP”
    • Host: “IP of Server”
    • Path: Path to the sript, in my case: “/cidres/”
    • Query: “tel=’[NUMBER]‘”

    Now you just have to set the Lookup Source in the Inbound Route to activate it – that’s it.

    Some notes about this solution:

    The best solution would be if Asterisk would first check the internal directory and just use the electronic telephone directory if there is no local directory entry. However, I have not found a way to accomplish that yet. Maybe a modified agi script could be a solution? Of course you can use different Lookup Sources for different Inbound Routes (and through this, different DID / Trunks). However, it seems not possible to use pattern match on Caller ID Number for Inbound Routes.

    Of course, it is only possible to get a Caller ID Name if the Number is in the electronic telephone directory.

    Here is the code of the script:

    /*** tel.search.ch Lookup Tool ***/
    /*** for use with Asterisk as  ***/
    /*** CID Lookup                ***/
    /*** By Gregor Jeker           ***/
    /*** Distribution under terms  ***/
    /*** of the GPL                ***/

    $tel = $_GET['tel'];

    $snoopy = new Snoopy;
    $snoopy->fetch(“http://tel.search.ch/api/” . “?tel=$tel”);

    $xmlobj = simplexml_load_string($snoopy->results);
    if ($xmlobj->entry->title == “”)
    { print “No Entry Found”; }
    { print $xmlobj->entry->title; }

    Tags: , , , , , , , ,

  • 10 Feb 2009 /  Asterisk, VoIP

    I have been playing around a lot with Asterisk PBX recently. It is an amazing part of Open Soure Software which enables you to use advanced features of a PBX easy and for free.

    It is quite simple to configure it by hand for small or test environments but it becomes quite confusing with increasing number of users and options so it is obvious to use a GUI to configure Asterisk. There are a lot of free GUI available like freePBX, voiceone and so on.

    After some tests with different GUI’s I have decided to use Trixbox which is based on CentOS and freepbx.

    So let’s come to the point: Everything was quite intuitively to configure, there was just a problem with the incoming calls over SIP Trunks. It was not a problem of the “Inbound Routes” as there has been a rule for all DID/CID. When I tried to call inside, I always got the message “The Number You Have Dialed Is Not In Service”. After a lot of Google research I finally got the (in my eyes not obvious) solution: You have to set “Allow Anonymous Inbound SIP Calls” to “Yes”. I am not very sure if there is another possibility to fix this as according to the help it seems that this could cause e Security problem because everyone then can call into the Asterisk server. On the other side, everyone should be allowed to call to the Asterisk Server unless the number is blacklisted. Maybe this setting is also Provider dependent (I am using sipcall.ch accounts). I don’t really know why incoming calls are classified as Anonymous.

  • Welcome….

    Comments Off
    21 Aug 2008 /  Generic

    So this is the new gregs.ch page! More stuff is comming soon!