cisco router configuration

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
diyasafra
Forum Newbie
Posts: 7
Joined: Mon Aug 13, 2007 9:46 am

cisco router configuration

Post by diyasafra »

hye..i would like to make a website for router configuration. this system is web based user interface, where user can used this system wherenever they are. i have a big confusion to make this sytem. my senior have develop a system for router configuration using vb 6.0. so i purpose to do in PHP.does anyone can give me opinion or guideline to review the source code for router configuration..your help is very important to me...
User avatar
nykoelle
Forum Newbie
Posts: 22
Joined: Fri Aug 10, 2007 9:05 am
Location: New York

Post by nykoelle »

newer Cisco IOS includes their own web gui. Upgrade your router to a newer version if at all possible and just make sure to include the version with a .tar file extension. It depends what kind of router you're using.

To be honest, this kind of task is going to be almost impossible to keep current as the second the router version is upgraded command syntax can be depreciated and new commands can be added and Cisco does a poor job of letting you know exactly what they changed. If you want to make a web gui to generate a cisco configuration, you would need very little php, it would be all form based, and it could get a basic config going.

For example,

Code: Select all

<form action="format.php" method="POST">
<p>IP Address of eth0/0: <input type="text" size="16" name="ip" /></p>
<p>Hostname: <input type="text" size="25" name="hostname" /></p>
<p><input type="submit" /></p>
</form>
then on format.php

Code: Select all

<p><strong>Please copy paste this config into your router.</strong></p>
<textarea rows="4">
interface ethernet0/0
 ip address <?=$_POST['ip'];?>
 no shut

hostname <?=$_POST['hostname'];?>
</textarea>
I'd suggest having a place where they enter the code version and model of the router as the interface types can vary and command syntax as well.
diyasafra
Forum Newbie
Posts: 7
Joined: Mon Aug 13, 2007 9:46 am

Post by diyasafra »

I have make a review about the CiscoWorks.,one of gui that cisco be used...and the scripting
is in Java..so i want to make in PHP script.
is there script that can i be used for connection to the router, by serial port connection and telnet connection?
diyasafra
Forum Newbie
Posts: 7
Joined: Mon Aug 13, 2007 9:46 am

Post by diyasafra »

nykoelle wrote:newer Cisco IOS includes their own web gui. Upgrade your router to a newer version if at all possible and just make sure to include the version with a .tar file extension. It depends what kind of router you're using.

To be honest, this kind of task is going to be almost impossible to keep current as the second the router version is upgraded command syntax can be depreciated and new commands can be added and Cisco does a poor job of letting you know exactly what they changed. If you want to make a web gui to generate a cisco configuration, you would need very little php, it would be all form based, and it could get a basic config going.

For example,

Code: Select all

<form action="format.php" method="POST">
<p>IP Address of eth0/0: <input type="text" size="16" name="ip" /></p>
<p>Hostname: <input type="text" size="25" name="hostname" /></p>
<p><input type="submit" /></p>
</form>
then on format.php

Code: Select all

<p><strong>Please copy paste this config into your router.</strong></p>
<textarea rows="4">
interface ethernet0/0
 ip address <?=$_POST['ip'];?>
 no shut

hostname <?=$_POST['hostname'];?>
</textarea>
I'd suggest having a place where they enter the code version and model of the router as the interface types can vary and command syntax as well.

sorry,. i cant understand what u suggesting to having a place where they enter the code version and model of the router as the interface types can vary and command syntax as well...can u explain more please..thanks.
User avatar
nykoelle
Forum Newbie
Posts: 22
Joined: Fri Aug 10, 2007 9:05 am
Location: New York

Post by nykoelle »

either you're writing your php script for one particular cisco router, in which case you don't need the user to specify what model or code level, but if this script is for multiple routers then you need a place in the form for the user to select what router and what code version. Cisco routers vary according to model and code significantly as far as configuration goes.

also number of ports etc.

as far as the script opening a telnet session, I don't know how secure that is, that's begging to be hacked as telnet isn't encrypted. You'd have to open an SSH tunnel if you're outside the network but I don't know if php is capable of doing that, I would suggest searching around google and this forum for that answer. Either case you're going to have to have the form base do what I showed you, then instead of outputting the information to the screen, if you can figure out how to open an ssh tunnel, have it print the output to the ssh window instead.

then of course wr mem and close the session.
diyasafra
Forum Newbie
Posts: 7
Joined: Mon Aug 13, 2007 9:46 am

Post by diyasafra »

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


for this project, the user will select the router by using telnet session.i have found one script hope it will be used.for this system, the important is telnet connection between the router.
found this script in http://my2.php.net/manual/en/function.fsockopen.php

Code: Select all

To make a telnet connection with a Cisco router:

$cfgServer = "192.168.0.10";  //IP of your router
$cfgPort    = 23;                //port, 22 if SSH
$cfgTimeOut = 10;

$usenet = fsockopen($cfgServer, $cfgPort, &$errno, &$errstr, $cfgTimeOut);

if(!$usenet)
        {
        echo "Connexion failed\n";
        exit();
        }
else
        {
        echo "Connected\n<BR>";
        fputs ($usenet, "toto\r\n");
        fputs ($usenet, "en\r\n");
        fputs ($usenet, "tutu\r\n");
        fputs ($usenet, "exit\r\n");
        while (!feof($usenet))
                {
                echo ". ".fgets($usenet, 128)."<BR>\n";
                }
        }

Then you will have:
Connected
. ???br /> .
. User Access Verification
.
. Password:
. testXB>en
. Password:
. testXB#exit

did this code can be usefull for my project where using telnet connection for router?
[/quote]


feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Post Reply