Tuesday, June 4, 2013

Setting Up BGP Looking Glass - CentOS 6

Setting Up Looking Glass 


A looking glass is a server that allows someone from outside the network to get information about the how traffic is routed through the network backbone of an organization. For example, suppose Alpha Corp. has one router in the US and another in Australia. An outside user wants to know how traffic towards Japan is routed from both of these Routers. As the user does not have credentials to the Routers, he cannot run traceroutes. The solution: a Looking Glass. If Alpha Corp. has a looking glass, the user can query about ping, trace, BGP and other information through the web-based looking glass without needing to authenticate to the actual router.

Setting Up 

Before we start please make sure SELinux is disabled. Also, iptables should allow the required ports, from the top of my head – 23, 2601, 2605, 80. 

Phase 1: Working YUM Server 

Make sure that your server has access to a good yum server, preferably repoforge. Information about how to add the repository of repoforge can be found at http://repoforge.org/use/

Phase 2: Downloading Necessary Prerequisites 

Fortunately, the LG looking glass does not have many prerequisites. The following should suffice-

yum install wget  perl-Net-Telnet perl-Net-Telnet-Cisco perl-XML-Parser httpd

Phase 3: Installing Looking Glass 

Looking glass is freely available and can be downloaded and extracted using the following commands-

cd /root
wget http://www.version6.net/lg/lg-1.9.tar.gz
tar zxvf lg-1.9.tar.gz
mkdir /var/www/html/lg

Necessary files have to copied to /var/www/html/lg and permissions need to be corrected as well

cd /var/www/html/lg
cp /root/lg-1.9/lg.cgi . 
cp /root/lg-1.9/favicon.ico .
cp /root/lg-1.9/lg.conf  .
chmod 644 *
chmod 755 lg.cgi

Phase 4: Tuning the Web Server

vim /etc/httpd/conf/httpd.conf

    Alias /lg/favicon.ico "/var/www/html/lg/favicon.ico"
    ScriptAlias /lg "/var/www/html/lg/lg.cgi"

service httpd restart
chkconfig httpd on

Part 5: Adding Routers 

All routers are added in the file /var/www/html/lg/lg.conf. Luckily, the file is self explanatory-
vim /var/www/html/lg/lg.conf

<!-- Test CISCO Router Section  -->

                <Separator>Sample Routers </Separator>

                <Router Name="Router-1">
        <!--EXAMPLE   <URL>telnet://login:123456@</URL> -->

                <Router Name="Router-2">

                <Router Name="Router-3">

Now, we should be able to access the Looking Glass via the URL: IP/lg e.g.

Phase 6: Tuning (Optional)

 Log File 

touch /var/log/lg.log
chown apache:apache /var/log/lg.log

vim /var/www/html/lg/lg.conf


Copy the logo file to /var/www/html/images

mkdir /var/www/html/images

vim /var/www/html/lg/lg.conf
    <LogoImage Align="center" Link="http://www.companyweb.com/">/images/logo.png</LogoImage>


vim /var/www/html/lg/lg.conf
<HTMLTitle>ASXXXX-Looking Glass</HTMLTitle>

vim /var/www/html/lg/lg.cgi
#### In the closing section of the HTML tag i.e. </HTML>, the following line can be added-####
  Please email questions or comments to
 <A HREF="mailto:$email">$email</A>.
Powered By: <a href="http://wiki.version6.net/LG">Looking Glass 1.9</a></P>


TATA: AS6453

NovoCom: AS132267
  Hope this helps :)


  1. hi
    I follow your guide but i can't setup LG on centos 6.5
    Please help me.

  2. Could you please specify the errors you are getting. Also, please confirm that SELinux is turned off.

  3. Do you try with SSH2 Protocol and Juniper devices ?

    1. Didn't have the provision, sorry mate. I tested using telnet and Cisco. We have secured isolated connections to all our routers, so clear text was not an issue in our backbone. And my boss seemed quite reluctant to enable ssh on the devices. ;)

  4. Sarmed Rahman@ if cisco password is Special character then it is not working.
    link: (!!mijhel$mUB**).
    it shows server error.

    what's the soluation.

    1. I have tested using your password, and it seems to be working. I have replaced the HTML "<>"tags, but I believe you will get the idea.

      (Router Name="TEST-RTR" EnableIPv6="Yes")
      (Title) TEST-RTR (/Title)
      (URL)telnet://login: (!!mijhel$mUB**)@

      For a password mismatch, the web server should give a similar output-

      ERROR:pattern match timed-out
      % Bad passwords

  5. This comment has been removed by the author.

  6. First of all, please note that '&' cannot be a valid character in the password. The script is a perl script and & has special meaning within perl.

    Also, your apache error log (/var/log/httpd/error.log) should contain more information on what is causing the error. Looking at it may yield some results.

  7. i got the problem on this king of text please help

    ERROR:problem connecting to "", port 23: Permission denied
    ERROR:write error: filehandle isn't open
    ERROR:write error: filehandle isn't open
    ERROR:write error: filehandle isn't open
    ERROR:write error: filehandle isn't open