Initial revision
diff --git a/tools/mrlg.cgi b/tools/mrlg.cgi
new file mode 100755
index 0000000..ac468ee
--- /dev/null
+++ b/tools/mrlg.cgi
@@ -0,0 +1,395 @@
+#!/usr/bin/perl
+##
+## Zebra Looking Glass version 1.0
+## 01 FEB 2000
+## Copyright (C) 2000 John W. Fraizer III <john.fraizer@enterzone.net>
+## *All* copyright notices must remain in place to use this code.
+##
+## The latest version of this code is available at:
+## ftp://ftp.enterzone.net/looking-glass/
+##
+##
+## This file is part of GNU Zebra.
+##
+## GNU Zebra is free software; you can redistribute it and/or modify it
+## under the terms of the GNU General Public License as published by the
+## Free Software Foundation; either version 2, or (at your option) any
+## later version.
+##
+## GNU Zebra is distributed in the hope that it will be useful, but
+## WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+## General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with GNU Zebra; see the file COPYING.  If not, write to the
+## Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+## Boston, MA 02111-1307, USA.
+
+require 5.002;
+use POSIX;
+use Net::Telnet ();
+
+
+
+## Set the URL for your site.
+$url="http://www.sample.com/mrlg.cgi";
+
+## Set your router variables in sub set_router and modify the selections in Main to match.
+
+
+############################################################
+#Main
+############################################################
+{
+
+## Set the router default
+@Form{'router'} = "router1";
+
+## Get the form results now so we can override the default router 
+get_form();
+
+print "Content-type: text/html\n\n";
+
+print '
+<html>
+<head>
+<title>Multi-Router Looking Glass for Zebra</title>
+</head>
+<body bgcolor=white>
+	
+<font face=arial size=3 color=blue>
+<h1>Multi-Router Looking Glass for Zebra</h1>
+Copyright 2000 - John Fraizer, EnterZone Inc.
+<br>
+';
+
+print '
+<font color=black>
+';
+print "<form METHOD=\"POST\" action=\"$url\">\n";
+print "<B>Router:</B>  <SELECT Name=\"router\" Size=1>\n";
+print "<OPTION Value=\"$Form{'router'}\">$Form{'router'}\n";
+print '
+<OPTION Value="router1">router1
+<OPTION Value="router2">router2
+<OPTION Value="router3">router3
+<OPTION Value="router4">router4
+</select>
+<br><br>
+<B>Query</B>:
+<br>
+<input type=radio name=query value=1>show ip bgp<br>
+<input type=radio name=query value=2>show ip bgp summary<br>
+<input type=radio name=query value=3>show ip route<br>
+<input type=radio name=query value=4>show interface<br>
+<input type=radio name=query value=5>show ipv6 bgp<br>
+<input type=radio name=query value=6>show ipv6 bgp summary<br>
+<input type=radio name=query value=7>show ipv6 route<br>
+<br>
+<B>Argument:</B> <input type=text name=arg length=20 maxlength=60>
+<input type="submit" value="Execute"></form>	
+';
+
+## Set up the address, pw and ports, etc for the selected router.
+set_router();
+
+## Set up which command is to be executed (and then execute it!)
+set_command();
+
+
+print '
+<br><br>
+</font>
+<font color=blue face=arial size=2>
+Multi-Router Looking Glass for Zebra version 1.0<br>
+Written by: John Fraizer -
+<a href="http://www.ez-hosting.net/">EnterZone, Inc</a><br>
+Source code: <a href="ftp://ftp.enterzone.net/looking-glass/">ftp://ftp.enterzone.net/looking-glass/</a>
+</body>
+</html>
+';
+
+## All done!
+
+exit (0); 
+}
+
+
+############################################################
+sub get_form
+############################################################
+{
+        
+        #read STDIN
+        read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
+
+        # Split the name-value pairs
+        @pairs = split(/&/, $buffer);
+  
+        # For each name-value pair:
+        foreach $pair (@pairs)
+                {
+                
+                # Split the pair up into individual variables.
+                local($name, $value) = split(/=/, $pair);
+
+                # Decode the form encoding on the name and value variables.
+                $name =~ tr/+/ /;
+                $name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
+ 
+                $value =~ tr/+/ /;
+                $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
+
+                # If they try to include server side includes, erase them, so they
+                # aren't a security risk if the html gets returned.  Another
+                # security hole plugged up.
+                $value =~ s/<!--(.|\n)*-->//g;
+        
+                @Form{$name} = $value ;
+                 
+                }
+        
+}       
+
+############################################################
+sub set_router
+############################################################
+
+## $server is the IP address of the router running zebra
+## $login_pass is the password of the router
+## $bgpd is the port that bgpd will answer on
+## $zebra is the port that zebra will answer on
+## if $zebra is "", it will disable sh ip route and sh int for that router.
+## if $full_tables is set to "1" for a router, full BGP and IP ROUTE table dumps will be allowed via the looking glass.
+## This is a BAD thing to do if you have multiple full views on a router.  That's why the option is there.
+
+{
+if ($Form{'router'} eq 'router1')
+        {
+$server = '10.1.1.1';
+$login_pass = 'zebra';
+$bgpd = "2605";
+$zebra = "";
+$full_tables=1;
+
+        }
+
+elsif ($Form{'router'} eq 'router2')
+        {
+$server = '10.1.1.2';
+$login_pass = 'zebra';
+$bgpd = "2605";
+$zebra = "2601";
+        }
+
+elsif ($Form{'router'} eq 'router3')
+        {
+$server = '10.1.1.3';
+$login_pass = 'zebra';
+$bgpd = "2605";
+$zebra = "2601";
+$full_tables=1;
+        }
+
+elsif ($Form{'router'} eq 'router4')
+        {
+$server = '10.1.1.4';
+$login_pass = 'zebra';
+$bgpd = "2605";
+$zebra = "2601";
+        }
+
+
+}
+
+
+############################################################
+sub set_command
+############################################################
+{
+if ($Form{'query'} eq '1')
+	{
+	sh_ip_bgp('ip');
+	}
+
+elsif ($Form{'query'} eq '2')
+	{
+	sh_ip_bgp_sum('ip');
+	}
+
+if ($Form{'query'} eq '3')
+	{
+	sh_ip_route('ip');
+	}
+
+if ($Form{'query'} eq '4')
+	{
+	sh_int();
+	}
+if ($Form{'query'} eq '5')
+	{
+	sh_ip_bgp('ipv6');
+	}
+if ($Form{'query'} eq '6')
+	{
+	sh_ip_bgp_sum('ipv6');
+	}
+if ($Form{'query'} eq '7')
+	{
+	sh_ip_route('ipv6');
+	}
+}
+############################################################
+sub sh_ip_bgp
+############################################################
+{
+my $protocol = shift(@_);
+$port = $bgpd;
+if ($protocol ne 'ip' && $protocol ne 'ipv6')
+	{
+	print "Invalid protocol: $protocol\n";
+	print "protocol must be 'ip' or 'ipv6'\n\n";
+	return;
+	}
+$command = "show $protocol bgp $Form{'arg'}";
+if ($Form{'arg'} eq '')
+	{
+	if ($full_tables eq '1')
+		{
+		execute_command();
+		}
+	else
+		{
+		print "Sorry.  Displaying the FULL routing table would put too much load on the router!\n\n";
+		}
+	}
+else
+	{
+	execute_command();
+	}
+}
+
+############################################################
+sub sh_ip_bgp_sum
+############################################################
+{
+	my $protocol = shift(@_);
+	$port = $bgpd;
+	if ($protocol ne 'ip' && $protocol ne 'ipv6')
+		{
+		print "Invalid protocol: $protocol\n";
+		print "protocol must be 'ip' or 'ipv6'\n\n";
+		return;
+		}
+	$command = "show $protocol bgp summary";
+	execute_command();
+}
+
+############################################################
+sub sh_ip_route
+############################################################
+{
+
+if ($zebra eq '')
+	{
+	print "Sorry. The <b>show ip route</b> command is disabled for this router."
+	}
+else
+	{
+
+	$port = $zebra;
+	my $protocol = shift(@_);
+	if ($protocol ne 'ip' && $protocol ne 'ipv6')
+		{
+		print "Invalid protocol: $protocol\n";
+		print "protocol must be 'ip' or 'ipv6'\n\n";
+		return;
+		}
+	$command = "show $protocol route $Form{'arg'}";
+	if ($Form{'arg'} eq '')
+		{
+		if ($full_tables eq '1')
+			{
+			execute_command();
+			}
+		else
+			{
+			print "Sorry.  Displaying the FULL routing table would put too much load on the router!\n\n";
+			}
+		}
+	else
+		{
+		execute_command();
+		}
+	}
+}
+
+############################################################
+sub sh_int
+############################################################
+{
+if ($zebra eq '')
+	{
+	print "Sorry. The <b>show interface</b> command is disabled for this router."
+	}
+else
+	{
+	$port = $zebra;
+	$command = "show interface $Form{'arg'}";
+	execute_command();
+	}
+}
+
+
+
+############################################################
+sub execute_command
+############################################################
+## This code is based on:
+##
+## Zebra interactive console
+## Copyright (C) 2000 Vladimir B. Grebenschikov <vova@express.ru>
+##
+
+
+{
+
+print "Executing command = $command";
+
+#  my $port = ($opt_z ? 'zebra' : 0) ||
+#             ($opt_b ? 'bgpd' : 0) ||
+#             ($opt_o ? 'ospfd' : 0) ||
+#	     ($opt_r ? 'ripd' : 0) || 'bgpd';
+
+my $cmd = $command;
+
+
+  my $t = new Net::Telnet (Timeout => 10,
+			   Prompt  => '/[\>\#] $/',
+			   Port    => $port);
+
+  $t->open ($server);
+
+  $t->cmd ($login_pass);
+
+  if ($cmd)
+    {
+      docmd ($t, $cmd);
+    }
+
+}
+
+############################################################
+sub docmd
+############################################################
+{
+  my ($t, $cmd) = @_;
+  my @lines = $t->cmd ($cmd);
+  print "<pre>\n";
+  print join ('', grep (!/[\>\#] $/, @lines)), "\n";
+  print "</pre>";
+}
+
+
+
diff --git a/tools/rrcheck.pl b/tools/rrcheck.pl
new file mode 100644
index 0000000..5e5a983
--- /dev/null
+++ b/tools/rrcheck.pl
@@ -0,0 +1,135 @@
+#! /bin/perl
+##
+## Read BGPd logfile and lookup RR's whois database.
+##
+##   Copyright (c) 1997 Kunihiro Ishiguro
+##
+use Socket;
+
+## Configuration variables
+$whois_host = "whois.jpix.ad.jp";
+
+#$logfile = "/usr/local/sbin/logfile"
+$logfile = shift || die "Please specify filename";
+
+## mail routine
+{
+    local ($prefix, $origin);
+
+    open (LOG, $logfile) || die "can't open $logfile";
+    
+    $index = '';
+    while ($index) {
+	$index = <LOG>;
+	if ($index =~ /[bgpd]/) {
+	    break;
+	}
+    }
+
+    while (<LOG>) {
+	if (/([\d\.\/]+)\s+([\d\.]+)\s+(\d+)\s+(\d+)\s+([\d ]+)\s+[ie\?]/) {
+	    $prefix = $1;
+	    $nexthop = $2;
+	    $med = $3;
+	    $dummy = $4;
+	    $aspath = $5;
+	    ($origin) = ($aspath =~ /([\d]+)$/);
+
+	    print "$nexthop [$origin] $prefix $aspath ";
+
+	    $ret = &whois_check ($prefix, $origin);
+	    if ($ret == 0) {
+		print "Check OK\n";
+	    } elsif ($ret == 1){
+		print "AS orgin mismatch\n";
+	    } else {
+		print "prefix doesn't exist \n";
+	    }
+	}
+    }
+}
+
+sub whois_check
+{
+    local ($prefix, $origin) = @_;
+    local ($rr_prefix, $rr_origin) = ();
+    local (@result);
+
+    $origin = "AS" . $origin;
+
+    @result = &whois ($prefix);
+
+    $prefix_match = 0;
+    foreach (@result) {
+        if (/^route:.*\s([\d\.\/]+)$/) {
+            $rr_prefix = $1;
+        }
+        if (/^origin:.*\s(AS[\d]+)$/) {
+            $rr_origin = $1;
+
+            if ($prefix eq $rr_prefix and $origin eq $rr_origin) {
+                return 0;
+            } elsif ($prefix eq $rr_prefix) {
+		$prefix_match = 1;
+	    }
+        }
+    }
+#    alarm_mail ($prefix, $origin, @result);
+    if ($prefix_match) {
+	return 1;
+    } else {
+	return 2;
+    }
+}
+
+## get port of whois
+sub get_whois_port 
+{
+    local ($name, $aliases, $port, $proto) = getservbyname ("whois", "tcp");
+    return ($port, $proto);
+}
+
+## whois lookup
+sub whois 
+{
+    local ($query) = @_;
+    local ($port, $proto) = &get_whois_port;
+    local (@result);
+
+    if ($whois_host=~ /^\s*\d+\.\d+\.\d+\.\d+\s*$/) {
+       $address = pack ("C4",split(/\./,$host));
+    } else {
+       $address = (gethostbyname ($whois_host))[4];
+    }
+
+    socket (SOCKET, PF_INET, SOCK_STREAM, $proto);
+
+    if (connect (SOCKET, sockaddr_in ($port, $address))) {
+        local ($oldhandle) = select (SOCKET);
+        $| = 1;
+        select($oldhandle);
+
+        print SOCKET "$query\r\n";
+
+        @result = <SOCKET>;
+        return @result;
+    }
+}
+
+##
+sub alarm_mail 
+{
+    local ($prefix, $origin, @result) = @_;
+
+    open (MAIL, "|$mailer -t $mail_address") || die "can't open $mailer";
+    
+    print MAIL "From: root\@rr1.jpix.ad.jp\n";
+    print MAIL "Subject: RR $origin $prefix\n";
+    print MAIL "MIME-Version: 1.0\n";
+    print MAIL "Content-Type: text/plain; charset=us-ascii \n\n";
+    print MAIL "RR Lookup Error Report\n";
+    print MAIL "======================\n";
+    print MAIL "Announced route : $prefix from $origin\n\n";
+    print MAIL "@result";
+    close MAIL;
+}
diff --git a/tools/rrlookup.pl b/tools/rrlookup.pl
new file mode 100644
index 0000000..2c14e73
--- /dev/null
+++ b/tools/rrlookup.pl
@@ -0,0 +1,123 @@
+#! /usr/local/bin/perl
+##
+## Read BGPd logfile and lookup RR's whois database.
+##
+##   Copyright (c) 1997 Kunihiro Ishiguro
+##
+use Socket;
+
+## Configuration variables
+$whois_host = "whois.jpix.ad.jp";
+
+#$mail_address = "toshio\@iri.co.jp";
+$mail_address = "kunihiro\@zebra.org";
+$mailer = "/usr/sbin/sendmail -oi";
+
+#$logfile = "/usr/local/sbin/logfile"
+$logfile = "logfile";
+$lookuplog = "lookuplog";
+
+## mail routine
+{
+    local ($prefix, $origin);
+
+    open (LOG, $logfile) || die "can't open $logfile";
+    open (LOOKUP, ">$lookuplog") || die "can't open $lookuplog";
+    
+    for (;;) {
+    while (<LOG>) {
+        if (/Update\S+ ([\d\.\/]+) .* (\d+) [ie\?]/) {
+            $prefix = $1;
+            $origin = $2;
+            $ret = &whois_check ($prefix, $origin);
+            if ($ret) {
+                print LOOKUP "$prefix AS$origin : Check OK\n";
+            } else {
+                print LOOKUP "$prefix AS$origin : Error\n";
+            }
+#        fflush (LOOKUP);
+        }
+    }
+    sleep (3);
+    }
+}
+
+sub whois_check
+{
+    local ($prefix, $origin) = @_;
+    local ($rr_prefix, $rr_origin) = ();
+    local (@result);
+
+    $origin = "AS" . $origin;
+
+#    print "$prefix $origin\n";
+
+    @result = &whois ($prefix);
+
+    foreach (@result) {
+        if (/^route:.*\s([\d\.\/]+)$/) {
+            $rr_prefix = $1;
+        }
+        if (/^origin:.*\s(AS[\d]+)$/) {
+            $rr_origin = $1;
+
+            if ($prefix eq $rr_prefix and $origin eq $rr_origin) {
+                return 1;
+            }
+        }
+    }
+    alarm_mail ($prefix, $origin, @result);
+    return 0;
+}
+
+## get port of whois
+sub get_whois_port 
+{
+    local ($name, $aliases, $port, $proto) = getservbyname ("whois", "tcp");
+    return ($port, $proto);
+}
+
+## whois lookup
+sub whois 
+{
+    local ($query) = @_;
+    local ($port, $proto) = &get_whois_port;
+    local (@result);
+
+    if ($whois_host=~ /^\s*\d+\.\d+\.\d+\.\d+\s*$/) {
+       $address = pack ("C4",split(/\./,$host));
+    } else {
+       $address = (gethostbyname ($whois_host))[4];
+    }
+
+    socket (SOCKET, PF_INET, SOCK_STREAM, $proto);
+
+    if (connect (SOCKET, sockaddr_in ($port, $address))) {
+        local ($oldhandle) = select (SOCKET);
+        $| = 1;
+        select($oldhandle);
+
+        print SOCKET "$query\r\n";
+
+        @result = <SOCKET>;
+        return @result;
+    }
+}
+
+##
+sub alarm_mail 
+{
+    local ($prefix, $origin, @result) = @_;
+
+    open (MAIL, "|$mailer -t $mail_address") || die "can't open $mailer";
+    
+    print MAIL "From: root\@rr1.jpix.ad.jp\n";
+    print MAIL "Subject: RR $origin $prefix\n";
+    print MAIL "MIME-Version: 1.0\n";
+    print MAIL "Content-Type: text/plain; charset=us-ascii \n\n";
+    print MAIL "RR Lookup Error Report\n";
+    print MAIL "======================\n";
+    print MAIL "Announced route : $prefix from $origin\n\n";
+    print MAIL "@result";
+    close MAIL;
+}
diff --git a/tools/zc.pl b/tools/zc.pl
new file mode 100755
index 0000000..026e8fe
--- /dev/null
+++ b/tools/zc.pl
@@ -0,0 +1,111 @@
+#! /usr/bin/perl
+##
+## Zebra interactive console
+## Copyright (C) 2000 Vladimir B. Grebenschikov <vova@express.ru>
+##
+## This file is part of GNU Zebra.
+##
+## GNU Zebra is free software; you can redistribute it and/or modify it
+## under the terms of the GNU General Public License as published by the
+## Free Software Foundation; either version 2, or (at your option) any
+## later version.
+##
+## GNU Zebra is distributed in the hope that it will be useful, but
+## WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+## General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with GNU Zebra; see the file COPYING.  If not, write to the
+## Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+## Boston, MA 02111-1307, USA.
+
+use Net::Telnet ();
+use Getopt::Std;
+
+#use strict;
+
+my $host = `hostname -s`; $host =~ s/\s//g;
+my $port = 'zebra';
+my $server = 'localhost';
+
+# Check arguments
+&getopts ('l:e:czborh');
+
+&usage () if $opt_h;
+
+# main 
+{
+  my $login_pass = $opt_l || $ENV{ZEBRA_PASSWORD} || 'zebra';
+  my $enable_pass = $opt_e || $ENV{ZEBRA_ENABLE} || '';
+
+  my $port = ($opt_z ? 'zebra' : 0) ||
+	     ($opt_b ? 'bgpd' : 0) ||
+             ($opt_o ? 'ospfd' : 0) ||
+	     ($opt_r ? 'ripd' : 0) || 'zebra';
+
+  my $cmd = join (' ', @ARGV);
+
+  my $t = new Net::Telnet (Timeout => 10,
+			   Prompt  => '/[\>\#] $/',
+			   Port    => $port);
+
+  $t->open ($server);
+
+  $t->cmd ($login_pass);
+  if ($enable_pass) {
+      $t->cmd (String => 'en',
+	       Prompt => '/Password: /');
+      $t->cmd ($enable_pass);
+  }
+  $t->cmd ('conf t') if "$opt_c";
+
+  if ($cmd)
+    {
+      docmd ($t, $cmd);
+      exit (0); 
+    }
+
+  my $prompt = sprintf ("%s%s# ", $host,
+			($port eq 'zebra') ? '' : "/$port");
+
+  print "\nZEBRA interactive console ($port)\n\n" if -t STDIN;
+
+  while (1)
+    {
+      $| = 1;
+      print $prompt if -t STDIN;
+      chomp ($cmd = <>);
+      if (!defined ($cmd))
+        {
+	  print "\n" if -t STDIN;
+	  exit(0);
+        }
+      exit (0) if ($cmd eq 'q' || $cmd eq 'quit');
+ 
+      docmd ($t, $cmd) if $cmd !~ /^\s*$/;
+    }
+
+  exit(0);
+}
+
+sub docmd
+{
+  my ($t, $cmd) = @_;
+  my @lines = $t->cmd ($cmd);
+  print join ('', grep (!/[\>\#] $/, @lines)), "\n";
+}
+
+sub usage
+{
+  print "USAGE: $0 [-l LOGIN_PASSWORD] [-e ENABLE_PASSWORD] [-z|-b|-o|-r|-h] [<cmd>]\n",
+        "\t-l - specify login password\n",
+        "\t-e - specify enable password\n",
+        "\t-c - execute command in configure mode\n",
+        "\t-z - connect to zebra daemon\n",
+        "\t-b - connect to bgpd  daemon\n",
+        "\t-o - connect to ospfd daemon\n",
+        "\t-r - connect to ripd  daemon\n",
+        "\t-h - help\n";
+  exit (1);
+}
diff --git a/tools/zebra.el b/tools/zebra.el
new file mode 100644
index 0000000..01ff09f
--- /dev/null
+++ b/tools/zebra.el
@@ -0,0 +1,108 @@
+;; -*- lisp -*-
+;;; zebra-mode.el -- major mode for editing zebra configuration file.
+
+;; Copyright (C) 1998 Kunihiro Ishiguro
+
+;; Author:     1998 Kunihiro Ishiguro
+;;                  SeonMeyong HEO
+;; Maintainer: kunihiro@zebra.org
+;;             seirios@Matrix.IRI.Co.JP
+;; Created:    Jan 28 1998
+;; Version:    Alpha 0.2
+;; Keywords:   zebra bgpd ripd ripngd languages
+
+;; You can get the latest version of zebra from
+;;
+;;    http://www.zebra.org/
+;;
+;; Install this Emacs Lisp code
+;;
+;; Compile zebra.el
+;;   % $(EMACS) -batch -f batch-byte-compile zebra.el
+;; Install zebra.el,zebra.elc to Emacs-load-path
+;;   % cp zebra.el zebra.elc $(emacs-load-path)
+;; Add .emacs or (site-load.el | site-start.el)
+;;   (auto-load 'zebra-mode "zebra" nil t)
+;;   (auto-load 'bgp-mode "zebra" nil t)
+;;   (auto-load 'rip-mode "zebra" nil t)
+;;
+
+;;; Code:
+
+;; Set keywords
+
+(defvar zebra-font-lock-keywords
+  (list
+   '("#.*$" . font-lock-comment-face)
+   '("!.*$" . font-lock-comment-face)
+   '("no\\|interface" . font-lock-type-face)
+   '("ip6\\|ip\\|route\\|address" . font-lock-function-name-face)
+   '("ipforward\\|ipv6forward" . font-lock-keyword-face)
+   '("hostname\\|password\\|enable\\|logfile\\|no" . font-lock-keyword-face))
+  "Default value to highlight in zebra mode.")
+
+(defvar bgp-font-lock-keywords
+  (list
+   '("#.*$" . font-lock-comment-face)
+   '("!.*$" . font-lock-comment-face)
+   '("no\\|router" . font-lock-type-face)
+   '("bgp\\|router-id\\|neighbor\\|network" . font-lock-function-name-face)
+   '("ebgp\\|multihop\\|next\\|zebra\\|remote-as" . font-lock-keyword-face)
+   '("hostname\\|password\\|enable\\|logfile\\|no" . font-lock-keyword-face))
+  "Default value to highlight in bgp mode.")
+
+(defvar rip-font-lock-keywords
+  (list
+   '("#.*$" . font-lock-comment-face)
+   '("!.*$" . font-lock-comment-face)
+   '("no\\|router\\|interface\\|ipv6\\|ip6\\|ip" . font-lock-type-face)
+   '("ripng\\|rip\\|recive\\|advertize\\|accept" . font-lock-function-name-face)
+   '("version\\|network" . font-lock-function-name-face)
+   '("default\\|none\\|zebra" . font-lock-keyword-face)
+   '("hostname\\|password\\|enable\\|logfile\\|no" . font-lock-keyword-face))
+  "Default value to highlight in bgp mode.")
+
+;; set font-lock-mode
+
+(defun zebra-font-lock ()
+  (make-local-variable 'font-lock-defaults)
+  (setq font-lock-defaults '(zebra-font-lock-keywords nil t)))
+
+(defun bgp-font-lock ()
+  (make-local-variable 'font-lock-defaults)
+  (setq font-lock-defaults '(bgp-font-lock-keywords nil t)))
+
+(defun rip-font-lock ()
+  (make-local-variable 'font-lock-defaults)
+  (setq font-lock-defaults '(rip-font-lock-keywords nil t)))
+
+;; define Major mode
+
+(defun major-mode-define ()
+  (interactive)
+  (progn
+    (setq comment-start "[#!]"
+	  comment-end ""
+	  comment-start-skip "!+ ")
+    (run-hooks 'zebra-mode-hook)
+    (cond
+     ((string< "20" emacs-version)
+      (font-lock-mode)))))
+
+(defun zebra-mode ()
+  (progn
+    (setq mode-name "zebra")
+    (zebra-font-lock))
+  (major-mode-define))
+
+(defun bgp-mode ()
+  (progn
+    (setq mode-name "bgp") 
+    (bgp-font-lock))
+  (major-mode-define))
+
+(defun rip-mode ()
+  (progn
+    (setq mode-name "rip")
+    (rip-font-lock))
+  (major-mode-define))