Showing posts with label telnet. Show all posts
Showing posts with label telnet. Show all posts

Friday, August 29, 2014

Juniper olive console port issue

So I decided to try out the Juniper olive I've been hearing about. I looked online and noticed how people were able to create a virtual Junos device on a virtualization platform like VMWare ESXi. The one problem that all the users were having was that the images were meant to be installed onto an actual router and configuring the device meant connecting to it via a console port. The problem there is that in a virtual platform, there is no physical access to the console port.

What you end up seeing on the video console is this message:

If only you could modify the image so that the /boot/loader.conf file so instead of reading:

console="comconsole"

it could be modify to project on the video console.

console="comconsole, vidconsole"

I found out that VMWare has the ability to allow remote serial connectivity through telnet. First you add a serial port.

Then in the pull down menu, you choose network.

Next you select Direction and choose Server. In the port URL you'll need to map the port number to a new value that is not a well know port number. I chose 10026. You add the url

telnet://:<your_port_number>

Then after you spin up the VM. You access the new VM by telneting to the Host Server's IP and the custom port number you created. It may take a while, but eventually you'll get a prompt.

My_Mac% telnet 10.11.39.145 10026
Trying 10.11.39.145...
Connected to 10.11.39.145.
Escape character is '^]'.


Amnesiac (ttyd0)

login:root



Next you can edit the /boot/loader.conf file or add an IP address and turn on telnet/ssh service on the Virtual Junos so you can directly access the device through a management port.


Thursday, April 24, 2014

Python on the Juniper QFX 5100

I noticed that the Juniper QFX5100 has a python interpreter included in Junos. This is new to the Juniper platforms. From the data sheet this is for management support. I know that Arista allows python scripting on their switches, so my guess is this is supported to keep up with the competition. This is a good first step for Juniper. While slax scripting is powerful, the learning curve for most networking engineers is steep and almost proprietary as you really have to know Junos. Slax is not transferrable to other vendor platforms, while python is.

Juniper's Python is accessible from the shell.

user@QFX5100> start shell

root@QFX5100% python
Python 2.7.1 (r271:86832, Jan 21 2014, 12:38:40)
[GCC 4.2.1 (for JUNOS)] on junos
Type "help", "copyright", "credits" or "license" for more information.

However I don't know what modules bundled in the OS are used to actually access Junos API.

>>> help ('modules juniper')

Here is a list of matching modules.  Enter any module name to get more help.


>>> help ('modules junos')

Here is a list of matching modules.  Enter any module name to get more help.


>>> help ('modules jnpr')

Here is a list of matching modules.  Enter any module name to get more help.

I did find that it does support telnetlib.


>>> help ('modules telnet')

Here is a list of matching modules.  Enter any module name to get more help.

telnetlib

>>> exit()

Which means you can actually access the QFX via telnet. In the below script I telnet to the switch and send a broadcast message

root@QFX5100% python hello.py
                                                                             
Broadcast Message from jnpr@SW3a                                            
        (/dev/ttyp2) at 22:32 PDT...                                        
                                                                             
hello world                                                                  

----------

I'm not when the Junos API will be available or how to access it. I'm guessing there may be some restrictions for this as you wouldn't want have a hacker creating mischief with python scripts.


source code:
root@QFX5100% more hello.py
---------------------                                                                            

import sys
import telnetlib

HOST = "192.168.1.1"
tn = telnetlib.Telnet(HOST)

user = "user"
password = "password"

tn.read_until("login:")
tn.write(user + "\n")

tn.read_until("Password:")
tn.write(password + "\n")

tn.read_until(">")
tn.write('request message all message "hello world" \n')
tn.read_until(">")
tn.write("exit\n")

tn.close