Showing posts with label junos. Show all posts
Showing posts with label junos. Show all posts

Tuesday, March 4, 2014

JUNOS automation, NETCONF

Introduction

JUNOS supports NETCONF protocol which is XML-RPC based mechanism to communicate
with router/firewalls (any thing that runs JUNOS). Get information to and from the JUNOS,
Upgrade devices remotely. Make applications either web based or right on the JUNOS device.

I am rather interested in some thing new, as I like SNMP protocol and have built many web based applications for monitoring and configuring devices, gathering statistics for network planning and other useful stuff. I am interested in a web based NETCONF application because if you want to transport a VLAN over a network from point A to point B, it does not make sense of making scripts on individual JUNOS device but make a script on a central server which then deploys it to each and every device in-path.

Juniper's CLI is a itself client to NETCONF protocol.


NETCONF
Mgd daemon is responsible for the NETCONF procotol. JUNOS runs NETCONF over ssh,

lets enable the ssh procotol.

[edit]
root# set system services ssh    
[edit]
root# set system services netconf ssh

now access a linux machine and execute the following command

root@nms:~# ssh root@192.168.3.4 -s netconf
root@192.168.3.4's password: 

JUNOS will reply like the following,

<!-- No zombies were killed during the creation of this user interface -->
<!-- user root, class super-user -->
<hello>
  <capabilities>
    <capability>urn:ietf:params:xml:ns:netconf:base:1.0</capability>
    <capability>urn:ietf:params:xml:ns:netconf:capability:candidate:1.0</capability>
    <capability>urn:ietf:params:xml:ns:netconf:capability:confirmed-commit:1.0</capability>
    <capability>urn:ietf:params:xml:ns:netconf:capability:validate:1.0</capability>
    <capability>urn:ietf:params:xml:ns:netconf:capability:url:1.0?protocol=http,ftp,file</capability>
    <capability>http://xml.juniper.net/netconf/junos/1.0</capability>
    <capability>http://xml.juniper.net/dmi/system/1.0</capability>
  </capabilities>
  <session-id>4509</session-id>
</hello>
]]>]]>

XML output shows the connection is established and JUNOS has just welcomed you to it's NETCONF interface.

execute a command and see what JUNOS replies, paste the following into same sshd session

<rpc message-id="1" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
<get-system-uptime-information/>
</rpc>

The above command retrieves information from the device about the uptime of the JUNOS access via ssh.

<rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" xmlns:junos="http://xml.juniper.net/junos/9.1R2/junos" message-id="1" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
]]>]]><system-uptime-information xmlns="http://xml.juniper.net/junos/9.1R2/junos">
<current-time>
<date-time junos:seconds="1366935506">2013-04-26 00:18:26 UTC</date-time>
</current-time>
<system-booted-time>
<date-time junos:seconds="1366933535">2013-04-25 23:45:35 UTC</date-time>
<time-length junos:seconds="1971">00:32:51</time-length>
</system-booted-time>
<protocols-started-time>
<date-time junos:seconds="1366933734">2013-04-25 23:48:54 UTC</date-time>
<time-length junos:seconds="1772">00:29:32</time-length>
</protocols-started-time>
<last-configured-time>
<date-time junos:seconds="1366933868">2013-04-25 23:51:08 UTC</date-time>
<time-length junos:seconds="1638">00:27:18</time-length>
<user>root</user>
</last-configured-time>
<uptime-information>
<date-time junos:seconds="1366935506">
12:18AM
</date-time>
<up-time junos:seconds="2001">
33 mins
</up-time>
<active-user-count junos:format="1 user">
1
</active-user-count>
<load-average-1>
0.16
</load-average-1>
<load-average-5>
0.03
</load-average-5>
<load-average-15>
0.03
</load-average-15>
</uptime-information>
</system-uptime-information>
</rpc-reply>
]]>]]>

]]>]]> is used to represent the end of XML-RPC message, this will normally always be used in request/response messages.

The above XML reply can be formatted to display it in more readable format, which can be done using any XML parser.

Thank You,

Sunday, April 21, 2013

How to access JUNOS Olive Serial on VirtualBox and vmware

I went through many how-tos this week regarding making a new Olive on VirtualBox, all were great only one thing which almost every one has missed was how to get the JUNOS CLI for the first time because for the first time the VirtualBox or any other Virtualization software that you are using will never show a prompt after the OS starts to boot, If you are running VirtualBox on windows.


Here is the process,


The First Part, Creating Virtual  Machines and installing JunOS is already very well explained and documented, so i dont want to re invent the wheel.

Follow the following URLs and get yourself able to install JunOS version of your choice,

NOTE:

If you want to avoid the unpacking junos, replacing it's checkpic binary and repacking, calculating the SHA1 and md5 checksums again use the following script, it will automatically unpack change the checkpic binary and pack the installer back again.

http://forum.gns3.net/download/file.php?id=520&sid=a010b8d818fa415e7c54a1850568e090



http://daemonkeeper.net/563/deploy-junos-on-a-virtualbox-virtual-machine/
http://blog.gns3.net/2009/10/olive-juniper/3/


The only way for this is to divert serial data (a named pipe) to a gateway, redirecting the named pipe to a tcp port and vice versa and then access that TCP port using any telnet client.

The first time you boot the JunOS the prompt will disappear as soon the OS is booted. Here you need a method to access the JunOS CLI and assign it an IP address which you can access use to telnet/ssh the router.

In VirtualBox locate to 'Serial Ports' Do the settings same as in the following image,


In Vmware



download, vmwaregateway.exe from here (for more details, http://www.l4ka.org/91.php).
download any telnet client, e.g, Putty.

open command prompt on your host OS, locate the PATH to vmwaregateway.exe, run the software as following,
c:\>vmwaregateway.exe /t

This software creates a named PIPE named called \\.\pipe\vmwaredebug and creates TCP socket to port 567. Open Putty telnet your localhost to port 567.

That's it you have access to JunOS run CLI and assign an IP address to the interface required.