søndag 27. juli 2014

Upgrading JunOS and the CompactFlash card on a Juniper J4350

I recently bought a second-hand Juniper J4350 router to play around with and start learning JunOS. The router arrived with a 256MB CompactFlash card and JunOS version 8.2R1.7. That’s a pretty old JunOS version (from 2007 or so), so I wanted to upgrade it before I did anything else with the router. Turned out to be a little tricker than I had expected.

First of all, Juniper won’t let you download any software for a device unless you have a valid service contract for it. This is in no way an unusual policy, Cisco does it too and HP seems to be moving in the same direction. The companies need their money to keep tinkering with the software, that is understandable, but it’s pretty annoying when you’re just using a device for testing and learning purposes. Those service contracts tend to be somewhat expensive, so unless you have a lot of disposable income you either have to know someone with a valid service contract or get the software from a filesharing site. (I'm not sure about the legality of things if you go with the latter option, so make sure to comply with all applicable laws in your area!)

After a little research I found that Juniper does not officially support upgrading to a software version that is more than three point releases ahead of the current one. That means quite a lot of interim versions if you want to upgrade from 8.2 to 12.1 the officially supported way. Another option would be to put a JunOS software recovery image on a USB drive, boot the router from that and perform a clean install to the CompactFlash. I decided to try that route first, replacing the original 256MB CompactFlash with a generic 2GB SanDisk SDCFX-2048 HDX 3.12 that I got from a friend (you need at least 1GB CompactFlash to install JunOS from the 12.1 branch).

The software recovery images must be written to a USB drive or CompactFlash card using dd or some other block write tool. Macs and Linux computers should be good to go, but Windows users need to grab dd for Windows or some other program that can write to raw devices. You can also use dd from the FreeBSD prompt on a Juniper router.

I used a software image named “install-media-12.1R7.7-domestic” to create the recovery drive, but I could never make it work properly. The router would boot from the USB drive, prompt me whether I’d like to start the install process and then crash immediately after it began repartitioning the CompactFlash. I tried several different USB drives and wrote the image to the drives both from my Windows desktop (with dd for Windows) and directly from the J4350, but the installer just kept crashing. Could be that I wasn’t using the right image for the J4350 platform, or the image could have been corrupt, or maybe it had something to do with the CompactFlash card. I honestly don’t know.

The solution for me turned out to be the JunOS snapshot command, which you can use to create a bootable snapshot of the running JunOS on a secondary drive. I put the original 256MB CompactFlash back in the router, created a factory default snapshot on a 4GB USB drive, swapped in the 2GB CompactFlash, booted from the USB and made a new factory snapshot on the CompactFlash.

Once I had JunOS running from the 2GB card I began slowly upgrading my way to 12.1X44, copying the upgraded software images to the router via SCP. I didn’t have every third point release from 8.2 up, so I occasionally had to use the “no-validate” parameter to make the upgrade go through. It’s possible that I could have gone directly to from 8.2 to 12.1 with “no-validate”, but I found it best not to risk it. After every successful upgrade I made sure to create a new snapshot to the USB drive so I wouldn’t have to start from scratch if anything went wrong. Several reboots later the router was running 12.1X44. Sweet! Now I just need to learn how to actually use this thing...

fredag 25. juli 2014

Cisco RJ45 Console Port to Moxa NPort RJ45

So what exactly is this adapter for?

Cisco, and plenty of other network equipment manufacturers, tend to use the RJ45 form factor instead of DE-9 for their RS232 console ports. RJ45 is the standard used in most computer networks while DE-9 is usually known as a “serial” or “COM” port. DE-9 ports used to come standard on most PCs, but nowadays they are more of a legacy connector and are rare on desktop computers and pretty much non-existent on laptops. USB adapters with one or more DE-9 ports are cheap and easily available, though.

Equipment that has an RJ45 console port will usually come with an RJ45-to-DE-9 cable so that the equipment can be managed from a PC or laptop with a DE-9 port. The cable simply maps the active pins in the RJ45 port to the correct pins in the DE-9 plug (transmit to receive, receive to transmit, ground to ground and so on).

Moxa’s NPort product range allows you to transport RS232 signals over an IP network. You simply plug RS232-enabled equipment into to an NPort device, install the NPort software on a computer and communicate with the RS232-enabled equipment through virtual serial ports.

Moxa refers to their NPort devices as serial-to-ethernet device servers, but other terms are also used, including serial-to-IP or just device servers. While the NPort range is Moxa proprietary, other vendors offer their own product ranges with similar functionality.

Some time ago I got hold of a decommissioned NPort 5610, an 8-port serial device server with RJ45-type RS232 ports. I wanted to use this device to access the console ports of the equipment in my home lab, but I didn’t have any cables that properly mapped the RJ45 pinout on my network equipment to the RJ45 pinout of the NPort device. I could order some, but that would take a while and I wanted to get started with the NPort as soon as possible. Also, I had some time to kill.

I knew that Cisco and HP RJ45-to-DE-9 cables were cross compatible and worked with all the other equipment I had, so all the RJ45 console ports had to have the same pinout. Cisco has a great description of their console port pinouts here, and the NPort 5610 pinout is detailed in the Quick Installation Guide. Other RJ45 NPort devices use the same pinout.
Now I could make a TP cable with the correct pin mapping and male RJ45 plugs in both ends, but then I’d have to make new cables or use female-to-female adapters if I wanted different lengths. I move stuff in my home lab around a lot, so that would be kinda inconvenient.

Instead, I decided to make a short adapter cable with a male RJ45 plug on the NPort end and a female RJ45 plug on the console port end. That way I could plug the adapter cable into the NPort and run a straight-through TP cable to the console port that I wanted to hook up to.

The basic procedure outlined in this post would also apply to serial-to-IP devices from other manufactures than Moxa, but if the pinout is different you’d need to change the pin mapping in the cable reflect this.

As for the console port end, I have never come across equipment with a different RJ45 console port pinout than the one described in the Cisco article. All Cisco, HP, MikroTik, Huawei and Juniper gear I’ve tried used the same pinout. Your mileage may vary though, so try Googling the pinout for your equipment if you run into problems.

Tools and parts

  • Crimping tool
  • Some TP cable (I used about 10” or 25cm for each adapter cable)
  • Male RJ45 crimp plug
  • Female RJ45 connector(the kind that plugs into empty patch panels are nicely suited for this)

Pinout and pin mapping

Note: The DSR and DTR pins are not actually used, at least not by any of the equipment I’ve tested with. You can snip them and only terminate the send, receive and ground pins. Also, keep in mind that the adapter is not unidirectional. The male end must connect to the NPort device, otherwise the pin mapping will be incorrect and you won't get a connection.
Shown below are the console port and NPort pinouts mapped to the colors of a T568B terminated TP cable. The last table shows which color wires from the NPort map to which wires going to the console port.

Cisco console pinout

Pin Color Signal
1 W-ORG Not used
2 ORG DTR
3 W-GRN TxD
4 BLU GND
5 W-BLU GND
6 GRN RxD
7 W-BRW DSR
8 BRW Not used

Moxa NPort RJ45 pinout

Pin Color Signal
1 W-ORG DSR
2 ORG RTS
3 W-GRN GND
4 BLU TxD
5 W-BLU RxD
6 GRN DCD
7 W-BRW CTS
8 BRW DTR

NPort-to-console pin mapping

NPort Console
W-ORG ORG
W-BLU W-GRN
W-GRN BLU
BLU GRN
BRW W-BRW

Making the adapter

  1. Crimp the RJ45 plug onto one end of the TP cable. Use T568B termination.
  2. On the other end of the cable, strip back as much of the jacket as is needed to terminate the cable in the female plug.
  3. Cut off the orange, green and white-brown wires so they're about level with the jacket.
  4. Map the remaining wires coming from the male (NPort) end of the cable to the correct slits in the female (console end) connector. Use the mapping shown in the table above and make sure that you're looking at the T568B color coding in the female connector.
  5. Assemble/push together the female connector as you would with a normal cable.
NPort wires mapped to the correct slits in the female connector

A completed adapter
Adapters in use with my NPort