Category Archives: Junos tips

Junos tips and/or rants of how juniper gear is different from cisco

MTU, Junos & Cisco, OSPF

Here’s a frustrating thing for people working with multiple hardware vendors: MTU sizing commands don’t match up.

A coworker was having a hard time getting OSPF to come up between a cisco and juniper router, I was going to do a full post on it, but this guy has done it much better than I was going to: http://thenetworksherpa.com/ospf-master-the-mtu-madness/

Basically, it comes down to this: when you change the hardware mtu on cisco stuff IOS automagically configures the IP mtu to the hardware mtu + 24 bytes (18bytes for the ethernet header plus some pad for layer 2 or other goodies).  Juniper doesn’t make that change for you.  So if you change the hardware mtu, you need to set the IP mtu up as well.

 

Why scripting will save you Pt2

continued from Pt1

2) Scripts in Excel, Access, whatever other program you like to use

Looking back I should have done this next task in Access where I get to use sql commands, but everybody has Excel, so this seemed like a better choice should I get hit by a bus or something.

I’m not a professional programmer.  I know I do things that are not necessarily correct or pretty.  I have a tendency to use functions instead of subs because I like to use the return value of the function during debug.   I’m sure I have other bad programming habits that would drive some people crazy, but at the end of the day I can get the job done and make my life easier when the day of a change comes.

Here’s some code that takes a log file, dumps it into a new sheet with a timestamp and then pulls the vlan info I need, Vlan ID, Root Bridge, and any blocking ports into an existing sheet.  It will do this for Cisco IOS switches, CatOS switches, and JunOS switches.

What we’re expecting in the log files is pretty specific here: CatOS “show spantree x” output, IOS “show spanning-tree” output, and Junos “show spanning-tree bridge” and “show spanning-tree interface x” output.   You can tweak this code pretty easily to look for other things…I know I’m holding onto it for future tasks.

 
 ‘this imports a file which must be named with the exact hostname of the device
‘and parses the file displaying the vlans: root bridge and bridge ID
‘and the interfaces: forwarding or blocking per vlan

Sub Main()

Dim RouterId As String
Dim PromptTxt As String
Dim throwaway As Integer
Dim filePath As String
Dim devicetype As String
Dim whileBreaker As Integer
Dim sheetname As String
Dim SheetList(10, 10) As String

‘WS is current worksheet and opens a new sheet at the beginning of the run
‘I might need to move this to the functions that import the files….
Dim WS As Worksheet
Set WS = Sheets.Add
‘get the log file to parse
filePath = Application.GetOpenFilename

‘chop out the routerid from the filepath
‘this assumes that the filename is the router-id
RouterId = GetFilenameFromPath(filePath)
RouterId = Left(RouterId, Len(RouterId) – 4)

‘so the output of a couple of switches changes with the version.  some didn’t have a > others did…quick fix below
If RouterId = “switch3” Or RouterId = “switch4” Then
    RouterId = RouterId & “>”
End If

‘asks for the type of file to parse
whileBreaker = 0
While whileBreaker = 0
     PromptTxt = “Enter device type.  Only CatOS, iOS, and Junos are accepted”
    devicetype = InputBox(PromptTxt)
    If devicetype = “CatOS” Or devicetype = “iOS” Or devicetype = “Junos” Then
        whileBreaker = 1
    End If
Wend
‘Changes current sheet name to reflect the file about to be read in
sheetname = Time()
sheetname = Replace(sheetname, “:”, “-“)
sheetname = RouterId & ” ” & Replace(sheetname, “/”, “-“)
ActiveSheet.Name = sheetname
‘import the file into the new sheet
ImportFile (filePath)

‘Parse the output sheet based on device type
    throwaway = Parselog(sheetname, RouterId, devicetype)

End Sub
 ________________________________________________________________________
Function GetFilenameFromPath(ByVal strPath As String) As String
‘ Returns the rightmost characters of a string upto but not including the rightmost ‘\’
‘ e.g. ‘c:\winnt\win.ini’ returns ‘win.ini’

    If Right$(strPath, 1) <> “\” And Len(strPath) > 0 Then
        GetFilenameFromPath = GetFilenameFromPath(Left$(strPath, Len(strPath) – 1)) + Right$(strPath, 1)
    End If

End Function
________________________________________________________________________________________________

Sub ImportFile(Logfilepath As String)
‘takes the file name, reads it into a string, then uses WriteToExcel to line import it into a new sheet

Dim Streng As String
Dim StrFileArray() As String
Dim hFile As Long

hFile = FreeFile

Open Logfilepath For Input As #hFile
    Streng = Input$(LOF(hFile), hFile)
Close #hFile
 StrFileArray = Split(Streng, vbCrLf)
 WriteToExcel (StrFileArray)
 End Sub

____________________________________________________________________________________________________
Function WriteToExcel(StrArray)
‘takes the array output from ImportFile and writes it into the current sheet starting at A1
Dim counter As Integer
Dim cellname As String

For counter = LBound(StrArray) To UBound(StrArray)
    cellname = “A” & (counter + 1)
    Range(cellname).Value = StrArray(counter)
Next counter
End Function
________________________________________________________________________________________________________
Function Parselog(ByVal workingSheetname As String, switchname As String, devicetype As String) As Integer

Dim showVlancells() As String
Dim DRCells() As String
Dim ARTemp(4) As String
Dim BlockingCells() As String
Dim searchString As String
Dim bFound As Boolean ‘Flag
Dim sRange As Range
Dim rowCounter As String
Dim Lastcell As String
Dim throwaway As Integer
Dim sheetname As Worksheet
Dim counter As Integer
Dim rFnd As Range
Dim iArr As Integer ‘ Counter for Array
Dim rFirstAddress ‘ Address of the First Find
Dim x As Integer

‘count how much to search and set sheetname to activesheet
Lastcell = Range(“A65536”).End(xlUp).Row
rowCounter = “A2:A” & Lastcell
Set sheetname = ActiveSheet

‘start parsing based on CatOS
‘__________________________________________________CATOS_________________________________________________
If devicetype = “CatOS” Then
    searchString = ” show spantree”
    searchString = switchname & searchString
    ‘look for all instances of “routerid show spantree ” and record those cells
    bFound = FindAll(searchString, sheetname, rowCounter, showVlancells())
    ‘look between values in showVlancells()for designated root cells
    ‘set the counter properly to not error at the end of the sheet
    Erase DRCells()
    For counter = 1 To UBound(showVlancells)
        searchString = “Designated Root    ”
        If counter = UBound(showVlancells) Then
            rowCounter = showVlancells(counter) & “:A” & Lastcell
        Else
            rowCounter = showVlancells(counter) & “:” & showVlancells(counter + 1)
        End If
        ‘start the search for DR
            Set rFnd = Nothing
            Set rFnd = sheetname.Range(rowCounter).Find(What:=searchString, LookIn:=xlValues, LookAt:=xlPart)

            ReDim Preserve DRCells(counter)
            If Not rFnd Is Nothing Then
                DRCells(counter) = rFnd.Address
            Else
                DRCells(counter) = ” ”
            End If

    Next counter
    ‘now I have 1:1 arrays with the vlan number and DR…at least I should
    throwaway = MsgBox(“These should match and be one more than the count from the SecureCRT script” & vbCrLf & UBound(showVlancells) & vbCrLf & UBound(DRCells), vbOKOnly)
    ‘now I need to get all the blocking ports
    ReDim BlockingCells(UBound(showVlancells), 4)
    For counter = 1 To UBound(showVlancells)
        searchString = “blocking”
        If counter = UBound(showVlancells) Then
            rowCounter = showVlancells(counter) & “:A” & Lastcell
        Else
            rowCounter = showVlancells(counter) & “:” & showVlancells(counter + 1)
        End If

        bFound = FindBlocking(searchString, sheetname, rowCounter, ARTemp())
        ‘only copy elements that matter
        If ARTemp(1) <> “” Then
        ‘throwaway = MsgBox(ARTemp(1), vbOKOnly)
            For x = 1 To UBound(ARTemp)
                BlockingCells(counter, x) = ARTemp(x)
            Next x
        End If

    Next counter

throwaway = DumpToOutputCat(showVlancells(), DRCells(), BlockingCells(), workingSheetname, switchname)
End If

‘_______________________________________________________IOS _____________________________________________________

If devicetype = “iOS” Then

    searchString = “VLAN0”
    ‘look for all instances of “routerid show spantree ” and record those cells
    bFound = FindAll(searchString, sheetname, rowCounter, showVlancells())
    ‘look between values in showVlancells()for designated root cells
    ‘set the counter properly to not error at the end of the sheet
    Erase DRCells()
    For counter = 1 To UBound(showVlancells)
        searchString = “Root ID ”
        If counter = UBound(showVlancells) Then
            rowCounter = showVlancells(counter) & “:A” & Lastcell
        Else
            rowCounter = showVlancells(counter) & “:” & showVlancells(counter + 1)
        End If
        ‘start the search for DR
            Set rFnd = Nothing
            Set rFnd = sheetname.Range(rowCounter).Find(What:=searchString, LookIn:=xlValues, LookAt:=xlPart)

            ReDim Preserve DRCells(counter)
            ‘ios output isn’t formatted friendly for this kind of search so I need to increment the drcells up one
            If Not rFnd Is Nothing Then
                Set rFnd = rFnd.Offset(1, 0)
                DRCells(counter) = rFnd.Address
            Else
                DRCells(counter) = ” ”
            End If

    Next counter
    ‘now I have 1:1 arrays with the vlan number and DR…at least I should
    throwaway = MsgBox(“These should match and be one more than the count from the SecureCRT script” & vbCrLf & UBound(showVlancells) & vbCrLf & UBound(DRCells), vbOKOnly)

    ‘now I need to get all the blocking ports
    ReDim BlockingCells(UBound(showVlancells), 4)
    For counter = 1 To UBound(showVlancells)
        searchString = “BLK”
        If counter = UBound(showVlancells) Then
            rowCounter = showVlancells(counter) & “:A” & Lastcell
        Else
            rowCounter = showVlancells(counter) & “:” & showVlancells(counter + 1)
        End If

        bFound = FindBlocking(searchString, sheetname, rowCounter, ARTemp())
        ‘only copy elements that matter
        If ARTemp(1) <> “” Then
        ‘throwaway = MsgBox(ARTemp(1), vbOKOnly)
            For x = 1 To UBound(ARTemp)
               BlockingCells(counter, x) = ARTemp(x)
            Next x
        End If

    Next counter
throwaway = DumpToOutputiOS(showVlancells(), DRCells(), BlockingCells(), workingSheetname, switchname)

End If
‘______________________________________________________Junos Section__________________________________________
If devicetype = “Junos” Then
    searchString = “STP bridge parameters for VLAN ”
    ‘look for all instances of “STP bridge parameters for VLAN ” and record those cells
    bFound = FindAll(searchString, sheetname, rowCounter, showVlancells())
    ‘look between values in showVlancells()for designated root cells
    ‘set the counter properly to not error at the end of the sheet
    Erase DRCells()
    For counter = 1 To UBound(showVlancells)
        searchString = ”  Root ID”
        If counter = UBound(showVlancells) Then
            rowCounter = showVlancells(counter) & “:A” & Lastcell
        Else
            rowCounter = showVlancells(counter) & “:” & showVlancells(counter + 1)
        End If
       ‘start the search for DR
            Set rFnd = Nothing
            Set rFnd = sheetname.Range(rowCounter).Find(What:=searchString, LookIn:=xlValues, LookAt:=xlPart)

            ReDim Preserve DRCells(counter)
            If Not rFnd Is Nothing Then
                DRCells(counter) = rFnd.Address
            Else
                DRCells(counter) = ” ”
            End If

    Next counter
throwaway = MsgBox(“These should match and be one more than the count from the SecureCRT script” & vbCrLf & UBound(showVlancells) & vbCrLf & UBound(DRCells), vbOKOnly)

‘    ‘now I have 1:1 arrays with the vlan number and DR…at least I should

‘instead of returning the cells that contain the string I just want a pop-up to tell me that something is blocking
‘because I’ll have to manually figure out why it’s blocking anyway

searchString = “BLK”
Set rFnd = Nothing
Set rFnd = sheetname.Range(rowCounter).Find(What:=searchString, LookIn:=xlValues, LookAt:=xlPart)
If Not rFnd Is Nothing Then
    throwaway = MsgBox(“Something is blocking in cell: ” & rFnd.Address, vbOKOnly)
End If

throwaway = DumpToOutputJunos(showVlancells(), DRCells(), BlockingCells(), workingSheetname, switchname)

End If

End Function
______________________________________________________________________________________________________________
Function FindAll(ByVal searchString As String, ByRef sheetname As Worksheet, ByRef rowCounter As String, ByRef showVlancells() As String) As Boolean

‘ ————————————————————————————————————–
‘ FindAll – To find all instances of the1 given string and return the row numbers.
‘ If there are not any matches the function will return false
‘ ————————————————————————————————————–

‘On Error GoTo Err_Trap

Dim rFnd As Range ‘ Range Object
Dim iArr As Integer ‘ Counter for Array
Dim rFirstAddress ‘ Address of the First Find
Dim throwaway As Integer
Dim tossstring As String

‘ —————–
‘ Clear the Array
‘ —————–
Erase showVlancells

Set rFnd = sheetname.Range(rowCounter).Find(What:=searchString, LookIn:=xlValues, LookAt:=xlPart)
If Not rFnd Is Nothing Then
    rFirstAddress = rFnd.Address
    Do Until rFnd Is Nothing
        iArr = iArr + 1
        ReDim Preserve showVlancells(iArr)
        showVlancells(iArr) = rFnd.Address ‘ rFnd.Row ‘ Store the Row where the text is found
        Set rFnd = sheetname.Range(rowCounter).FindNext(rFnd)
        If rFnd.Address = rFirstAddress Then Exit Do ‘ Do not allow wrapped search
    Loop

FindAll = True
Else
‘ ———————-
‘ No Value is Found
‘ ———————-
FindAll = False
End If

‘ ———————–
‘ Error Handling
‘ ———————–
Err_Trap:
If Err <> 0 Then
MsgBox Err.Number & ” ” & Err.Description, vbInformation, “Find All”

Err.Clear
FindAll = False
Exit Function
End If
End Function
____________________________________________________________________________________________________________
Function FindBlocking(ByVal searchString As String, ByRef sheetname As Worksheet, ByRef rowCounter As String, ByRef ARTemp() As String) As Boolean

‘ ————————————————————————————————————–
‘ FindAll – To find all instances of the1 given string and return the row numbers.
‘ If there are not any matches the function will return false
‘ ————————————————————————————————————–

‘On Error GoTo Err_Trap

Dim rFnd As Range ‘ Range Object
Dim iArr As Integer ‘ Counter for Array
Dim rFirstAddress ‘ Address of the First Find
Dim throwaway As Integer
Dim tossstring As String

‘ —————–
‘ Clear the Array
‘ —————–
Erase ARTemp

Set rFnd = sheetname.Range(rowCounter).Find(What:=searchString, LookIn:=xlValues, LookAt:=xlPart)
If Not rFnd Is Nothing Then
    rFirstAddress = rFnd.Address
    Do Until rFnd Is Nothing
        iArr = iArr + 1
‘        ReDim Preserve ARTemp(iArr)  ‘this may need to come back later
        ARTemp(iArr) = rFnd.Address ‘ rFnd.Row ‘ Store the Row where the text is found
        Set rFnd = sheetname.Range(rowCounter).FindNext(rFnd)
        If rFnd.Address = rFirstAddress Then Exit Do ‘ Do not allow wrapped search
    Loop

FindBlocking = True
Else
‘ ———————-
‘ No Value is Found
‘ ———————-
FindBlocking = False
End If

‘ ———————–
‘ Error Handling
‘ ———————–
Err_Trap:
If Err <> 0 Then
MsgBox Err.Number & ” ” & Err.Description, vbInformation, “Find All”

Err.Clear
FindBlocking = False
Exit Function
End If
End Function

Function DumpToOutputCat(vlan() As String, DR() As String, Blocking() As String, sheetname As String, switchname As String)

‘Dim workingRow As Integer
‘Dim wokingCol As String
Dim workcounter As Integer
Dim Lastcell As Integer
Dim cRange As String
Dim throwaway As Integer
Dim vlanNumber() As String
Dim vlanid As String
Dim drID As String
Dim drNumber() As String
Dim blockint() As String
Dim x
Dim blockcellId() As String
Dim blockId As String

‘need to make Output the working sheet
Sheets(“Output”).Select

‘find the end of the sheet
Lastcell = Range(“A65536”).End(xlUp).Row

‘dump the output of vlans

For workcounter = 1 To UBound(vlan)
    ‘write the vlan ID’s
    cRange = “B” & Lastcell + workcounter
    vlanNumber() = Split(Sheets(sheetname).Range(vlan(workcounter)).Value, ” “)
    vlanid = vlanNumber(UBound(vlanNumber))
    Range(cRange).Value = vlanid
    ‘write the switch name
    cRange = “A” & Lastcell + workcounter
    Range(cRange).Value = switchname
    ‘write the DR
    cRange = “C” & Lastcell + workcounter
    Erase drNumber
    drID = ” ”

        If DR(workcounter) <> ” ” Then
            drNumber() = Split(Sheets(sheetname).Range(DR(workcounter)).Value, ” “)
            drID = drNumber(UBound(drNumber))
        End If

    Range(cRange).Value = drID
    ‘now you need to write the blocking ports….
    cRange = “D” & Lastcell + workcounter
    Erase blockcellId
    For x = 1 To UBound(Blocking, 2)
        ReDim Preserve blockcellId(x)
        If Blocking(workcounter, x) <> “” Then
            blockcellId(x) = Sheets(sheetname).Range(Blocking(workcounter, x)).Value
            blockint = Split(blockcellId(x), ” “)
            blockcellId(x) = blockint(1)
        End If
    Next x
    blockId = Join(blockcellId, ” “)
    Range(cRange).Value = blockId

Next workcounter

End Function
_______________________________________________________________________________________________________________
Function DumpToOutputJunos(vlan() As String, DR() As String, Blocking() As String, sheetname As String, switchname As String)

‘Dim workingRow As Integer
‘Dim wokingCol As String
Dim workcounter As Integer
Dim Lastcell As Integer
Dim cRange As String
Dim throwaway As Integer
Dim vlanNumber() As String
Dim vlanid As String
Dim drID As String
Dim drNumber() As String
Dim blockint() As String
Dim x
Dim blockcellId() As String
Dim blockId As String

‘need to make Output the working sheet
Sheets(“Output”).Select

‘find the end of the sheet
Lastcell = Range(“A65536”).End(xlUp).Row

‘dump the output of vlans

For workcounter = 1 To UBound(vlan)
    ‘write the vlan ID’s
    cRange = “B” & Lastcell + workcounter
    vlanNumber() = Split(Sheets(sheetname).Range(vlan(workcounter)).Value, ” “)
    vlanid = vlanNumber(UBound(vlanNumber))
    Range(cRange).Value = vlanid
    ‘write the switch name
    cRange = “A” & Lastcell + workcounter
    Range(cRange).Value = switchname
    ‘write the DR
    cRange = “C” & Lastcell + workcounter
    Erase drNumber
    drID = ” ”

        If DR(workcounter) <> ” ” Then
            drNumber() = Split(Sheets(sheetname).Range(DR(workcounter)).Value, ” “)
            drID = drNumber(UBound(drNumber))
        End If

    Range(cRange).Value = drID
    ‘now you need to write the blocking ports….
    cRange = “D” & Lastcell + workcounter
    Erase blockcellId

Next workcounter

End Function
___________________________________________________________________________________________________________
Function DumpToOutputiOS(vlan() As String, DR() As String, Blocking() As String, sheetname As String, switchname As String)

‘Dim workingRow As Integer
‘Dim wokingCol As String
Dim workcounter As Integer
Dim Lastcell As Integer
Dim cRange As String
Dim throwaway As Integer
Dim vlanNumber() As String
Dim vlanid As String
Dim drID As String
Dim drNumber() As String
Dim blockint() As String
Dim x
Dim blockcellId() As String
Dim blockId As String

‘need to make Output the working sheet
Sheets(“Output”).Select

‘find the end of the sheet
Lastcell = Range(“A65536”).End(xlUp).Row

‘dump the output of vlans

For workcounter = 1 To UBound(vlan)
    ‘write the vlan ID’s
    cRange = “B” & Lastcell + workcounter
    vlanNumber() = Split(Sheets(sheetname).Range(vlan(workcounter)).Value, ” “)
    vlanid = vlanNumber(UBound(vlanNumber))
    Range(cRange).Value = vlanid
    ‘write the switch name
    cRange = “A” & Lastcell + workcounter
    Range(cRange).Value = switchname
    ‘write the DR
    cRange = “C” & Lastcell + workcounter
    Erase drNumber
    drID = ” ”

        If DR(workcounter) <> ” ” Then
            drNumber() = Split(Sheets(sheetname).Range(DR(workcounter)).Value, ” “)
            drID = drNumber(UBound(drNumber))
        End If

    Range(cRange).Value = drID
    ‘now you need to write the blocking ports….
    cRange = “D” & Lastcell + workcounter
    Erase blockcellId
    For x = 1 To UBound(Blocking, 2)
        ReDim Preserve blockcellId(x)
        If Blocking(workcounter, x) <> “” Then
            blockcellId(x) = Sheets(sheetname).Range(Blocking(workcounter, x)).Value
            blockint = Split(blockcellId(x), ” “)
            blockcellId(x) = blockint(0)

        End If
    Next x
    blockId = Join(blockcellId, ” “)
    Range(cRange).Value = blockId

Next workcounter

End Function

Why scripting will save you PT1

In a previous post I talked about documentation and planning for a change, but what can we do to really shorten the time it takes to implement and verify a change?

Scripting.

If we script things out ahead of time we don’t have to use our valuable time during a change window to type things out.  Plus we get to check, double-check, test, and debug all ahead of time to make sure things go how we want them to.

Here are a couple of scripts I’ve used lately to help me get info that I need quickly and format it so that it’s easier to look at.

1) Scripts in SecureCRT.

If you don’t own SecureCRT go buy it.  You can try to get everything done in putty, but a good terminal program will take you to a new level.

You can use several different scripting languages to help you out here.  You can do simple things like have it type commands for you, or complex things like read outputs and make decisions based on what comes out on the terminal.  It’s great for data entry type tasks that are horribly repetitive  but sill need to get done.

This is an example of a script I put together to go through and enter a show command for a list of vlans on a CatOS switch.  It’s sloppy from a code perspective, but it was fast and gets the job done.  (I’m working in VBScript in this case)
#$Language=”VBScript”
#$Interface=”1.0″
Sub Main
Dim counter
‘generic counter variable
Dim Arraysize
Dim RouterID
arr_VlanSet = Array(“1”, “2”, …keep listing your vlans here)
‘sloppy way to populate the vlanset…you can pull this from another file or whatever, but that’s more effort
‘than I wanted to put into this simple script
‘Creates a linear array for holding list of vlans
Arraysize = UBound(arr_VlanSet)
counter = MsgBox(Arraysize, vbOKOnly)
RouterID = “hostname of device goes here”
crt.Screen.Synchronous = True
For counter = 0 To Arraysize

crt.Screen.Send “show spantree ” & arr_vlanset(counter) & vbCr
if crt.screen.WaitForString(“–More”, 1) then
crt.Screen.Send ” ”
end if
if crt.screen.WaitForString(“–More”, 1) then
crt.Screen.Send ” ”
end if
if crt.screen.WaitForString(“–More”, 1) then
crt.Screen.Send ” ”
end if

crt.Screen.Send ” ” & vbCr

crt.screen.WaitForString(RouterID)

Next
End Sub
Remember, these are supposed to save you time on the day, so you don’t need to be elegant in the code.  This goes through my list of vlans, put in the command, waits to see if a space needs to be entered (it does this 3 times) and then goes on to the next command.  If you have longer output than 3 screens it’ll wait for you to put in a keystroke manually instead of just going and missing a command.

 

More in PT2

 

Junos, olive, GNS3…should be easy, right? Pt5

Now, you remember that ISO image we made all the way at the beginning?  Well, now we actually use it.

From the command prompt “qemu -L . -m 256 -boot c -hda j.img -cdrom ..\jinstall.iso”

 

That’ll launch qemu again and mount the image for installation.  Login when prompted

olive38

Let’s clear some room to work with:

olive39

Mount the cdrom “mount /cdrom”

Create a temp directory for Junos “mkdir /var/tmp/j/”

Change to the new directory “cd /var/tmp/j/”

And make sure you’re actually there “pwd”

Extract the Junos files “tar zxvf /cdrom/jinstall-10.1r1.8-domestic-olive.tgz”

olive40olive41

 

Make pkgtools directory “mkdir pkgtools”

Go into pkgtools directory “cd pkgtools”

Verify that you’re in the right spot “pwd”

Extract pkgtools “tar zxfv ../pkgtools.tgz”

olive42

Go to Bin directory “cd bin”

Copy true file “cp /usr/bin/true ./checkpic”

Back up one level “cd ..” (there’s a space in there)

Zip the file again “tar zcvf ../pkgtools.tgz *”

olive43

Back up one level “cd ..”

Remove pkgtools directory “rm –rf pkgtools”

Rezip to Junos “tar zcvf ../junos.tgz *

olive44

Install Junos “pkg_add –f /var/tmp/junos.tgz”

olive45

Here’s where you end up:

olive46

“init 6” then ctrl + alt + 2 “q” to kill it

Now we’ve got a working image.  Time for the GNS3 part.  Open up GNS3 and go to Edit > Preferences > Qemu.  Change the working directory, path, and img path.

olive47

Go the Junos tab and add your image…make sure to save it

olive48

You should now be able to drag Juniper routers into your topologies.

 

A few things I’ve found:

1)  Connect your links before starting the router, they don’t like changing things once they’re running

2)  They take a long time to boot.  Yeah, it sucks, but at least they work

3)  These images don’t do everything.  You may be able to put in a command and it seems to take, but the feature doesn’t work.  Kind of a pain…

4)  Make sure to save the nvrams and harddisks of your devices in your projects.  With Junos stuff make sure to save while the device is running.

5)  Important: hit crtl+alt to free your mouse from a qemu window should you accidently click in there.

 

Have fun!

Junos, olive, GNS3…should be easy, right? Pt4

It’ll dump you back to the previous screen with the line selected with an X on it.  Hit the tab key and then enter.

olive29

Select 1 to install via CD or DVD and hit yes on the next screen

olive30

It’s going to do some stuff now…be patient here, don’t freak out if it doesn’t look like it’s moving for a while.  You’ll see multiple progress bars and finally you’ll get to this…select yes when you get here.

olive31

Go down to set root password and hit enter…then type in a password for this image, please remember it

olive32olive33

Go ahead and exit when you get to the next screen

olive34

Now exit the install…yes, you’re sure you want to exit.

olive35olive36

This will restart the qemu application…hit Ctrl+Alt+2 to kill it…that’ll take you to this

olive37

Type Q and hit enter to exit. That’ll close the qemu window and take you back to your command prompt.

 

still not done yet PT5

Junos, olive, GNS3…should be easy, right? Pt3

It’ll do some more stuff and get you here.  Use the down arrow key to get to “Express” and press enter to select.

olive10

olive11

Press A for use entire disk

olive12

Press Q to quit

olive13

Select Standard

olive14

Press C to create

olive15

Type in “2048M” (caps here matters)

olive16

Select FS and type in /

olive17olive18

Press C to create and 1024M (caps here matters) and select Swap

olive19olive20olive21

Press C to create and 100M (caps here matters) and select FS, type in /config

olive22olive23olive24

Press C to create, press enter to select whatever is left, select FS, and call the partition /var

olive25olive26

Press Q to quit, use the arrow keys to scroll to 8 Users and use the space bar to select the line before you hit enter

olive27

Select No on the next screen

olive28

 

 

not done yet…PT4

Junos, olive, GNS3…should be easy, right? Pt2

Now let’s extract qemu.

olive05

 

olive06

Open a command prompt and go to your olive\qemu directory.  Here’s your first command:

qemu-img.exe create j.img -f qcow2 6G

You should see the output below

olive07

Next command, this starts qemu:

qemu.exe -L . -m 256 -hda j.img -boot d -localtime -cdrom ..\4.11-RELEASE-i386-miniinst.iso

You’ll get a new window at this point

olive08

This window will do some stuff, if you don’t press anything you’ll get to this point.  Select the first option by pressing enter.

olive09

 

Onward to PT3

Junos, olive, GNS3…should be easy, right? Pt1

GNS3 is just about the best thing ever.  If you’ve never used it, you should.  Talk about the amazing things that people will build and publish for free.

For those who are unfamiliar with GNS3 it is a graphic network simulator (g…n…s…get it?).   Basically you get to run virtual routers and switches that actually run IOS (it was primarily designed for Cisco gear).  It’s not a crappy emulator where commands aren’t available and you don’t actually get to see traffic flow, it’s the real deal (well…virtually).  Virtual packets get passed from device to device that you can use wireshark to sniff, you can bind physical interfaces on your computer to virtual interfaces to create even larger networks.  In short, it’s awesome.

If you need to study for a CCNA or CCNP this is the most valuable tool you can have.  I have a friend who has been using it to study for his CCIE, where he has run into some issues, but not many.  Think about how great that is: You can download a program, for free, instead of paying thousands of dollars to build a network rack, plus saving your electricity bill and keeping your friends from thinking that you’re the ultimate geek every time they walk into your place.

That’s enough about how amazing this application is (and the kind and generous souls who have put their time into developing it).  I’ll probably do some posts later about little helpful tricks I’ve found, but on to the main point of this post: Junos and GNS3.

I had a bit of trouble locating a good step by step guide to integrating a Junos Olive with GNS3.  They have posts on their forums and several other people have posted guides to do this, so am I just re-posting?  Kind of.  My problem with a lot of the guides out there is that they were done by people who run some build of Linux or Mac (which I guess would be a Linux build now…right?).

I don’t run Linux  I use Windows.  I know, I know.  “You call yourself a tech and use Windows?”  Yes.  Yes I do.  I’ve tried Linux and it’s great for what it is, but it’s not what I need in a daily OS.  That’s a different rant.

The best thing I was able to find when I was searching was this video on youtube (credit where credit is due).  It’s pretty good and got me to where I needed to be.  There are a couple of parts I modified, but for the most part it follows this video.

 

Time for the juicy part, the actual setup:

First thing you need to do, download all the stuff.  You can use different versions, but I know these work.  Please feel free to tinker and let me know others work better or not at all.

 

Save files wherever you like.  For me I found it easiest to create an Olive directory right off the root of the C drive.  As you move forward through this make sure to modify any commands with different file locations that you use.

 

1)  If you don’t already have it go to GNS3.org and pull the full install package and install it.  I’m using 0.8.3 for this guide.

2)  Grab a copy of Virtual Clone Drive (http://www.slysoft.com/en/virtual-clonedrive.html) and install that.

3)  Grab a copy of Free ISO Creator (http://www.freeisocreator.com/ )

4)  …install that

5)  You’ll need qemu.  The file you’re looking for is qemu-0.11.0.patched.win32.zip.  If only there was a way to find that. http://www.google.com/search?q=qemu-0.11.0.patched.win32.zip

6)  You need a juniper install package.  I used jinstall-10.1r1.8-domestic-olive.tgz  If only there was a way to find that. http://www.google.com/search?q=jinstall-10.1r1.8-domestic-olive.tgz

7)  And you’ll need a Free BSD mini package (4.11 in this case) 4.11-RELEASE-i386-miniinst.iso  If only there was a way to find that. http://www.google.com/search?q=4.11-RELEASE-i386-miniinst.iso

 

Next we need to make an ISO file containing that junos install file.  Stick the olive.tgz file into a separate sub directory (in my case I called it jinstall).

olive01

 

Now create an ISO

olive02

If you’re paranoid you can mount it to make sure that it worked…

olive03

olive04

 

This is going to be long so I’m breaking it into multiple posts: PT2 PT3 PT4 PT5

listing vlans

I’ve recently had to verify vlans on some switches.   Normally in a Cisco switch I look at the config for this, just do a show “run | section vlan” or maybe some “show vlans” command variations.  Now being new to Junos I tried a basic “show configuration | display set” and got to the vlan section…what a mess.

The output in the config is sorted by the name of the vlan.  Not very helpful when you have a list of numbers you want to check off quickly. “show vlans sort-by tag brief ” got me as close as I was going to get to a list of numerical vlans on the switch.  It’s at least sorted by the right field, but still displays the vlan name first.

show vlans

Serial numbers

Kind of a simple one here that you could totally figure out on your own, but I had forgotten to write down the serial numbers on some gear that I put in a remote office.

“show version” will get you:

Hostname

Model

Junos release

“show version detail” will get you the above and a bunch of other release and build numbers for software.

 

“show chassis hardware” is what I was looking for.  For each piece of hardware in there:

Item

Version

Part Number (helpful for putting in orders for replacement parts)

Serial Number (hooray!!!)

Description

Simple, I know.  But some people may not look under chassis commands for serial numbers.  I know it wasn’t my first instinct.

 

Oh, and on Foundry FCX-24GS (at least) it’s “show version” to get the serial number.  Hope that helps a bit too.