Installing your own timezone database on devices with Junos

Published on November 09, 2011

Installing your own timezone database on devices with Junos

In connection with the event awaiting us in the near future: day, or rather night, "not switching to winter time," I want to talk about updating the time zone database on equipment from Juniper Networks, Inc. running the Junos operating system.

The procedure itself is beautifully described in the documentation presented on the company's website, in the document: " Setting a Custom Time Zone on Routers Running JUNOS Software ". I will only talk about it in my native language and clarify certain details.

The developers of the operating system were farsighted to note that updating the time zone database can occur more often than updating the operating system itself. And they provided the opportunity to use the base, personally changed by administrators operating their equipment.

How to do it?
  • First, we need to get and download the latest base of time zones on the device. Junos developers use the completely standard " Time Zone Database " used by many other operating systems. Its current version is available on the IANA website.

    I dare to assume that you, as an administrator, have access to equipment using the SSH protocol. And, accordingly, you can use SCP to transfer the base received from IANA to the device.

    Run from the administrator station:

    > scp tzdata2011m.tar.gz admin-name@junos-host.domain.tld:

    In this case we put the archive we need into the user’s home directory “admin-name” located on the device with the DNS name “junos- host.domain.tld ". This is just one of the possible ways. Another, I will describe later.

  • Second, we need to log into the updated device with Junos using the SSH protocol. And get a shell on it using the command “start shell”

    - JUNOS 10.2R3.10 built 2010-10-16 20:36:59 UTC
    admin-name @ junos-host>
    start shell
    %

    You will find yourself in the user's home directory, under which registered. If you used the same username when copying the archive file of the timezone database, then you can see this file by running the command “ls -lh”. You can find out the current location inside the file system using the pwd command.

  • Let's go back to the first point and I will talk about another way to get a file with an archive of time zones on the device. This method may work if you have Internet access from your device. You can use the fetch command and download the file directly from the IANA site while in shell mode on the device.

    % fetch www.iana.org/time-zones/repository/releases/tzdata2011m.tar.gz

  • Third, unpack the contents of the time zone database archive file into the directory recommended in the documentation.

    % mkdir -p / var / tmp / tz && cd / var / tmp / tz && rm *
    % tar xzvf /var/home/admin-name/tzdata*.gz

    Note that we have made the current directory "/ var / tmp / tz ". And it unpacked the contents of the archive file located in the home directory of the user under whose name you registered on the device. If you ran the “pwd” command described in step two, you noticed that the path to the home directory shown at that moment and the path used in the “tar” command are different. You can use any of the options. Junos simply creates symbolic links for the respective directories.

    If necessary, at the moment, you can modify the database files, which are ordinary text files, using, for example, the text editor "vi" available in the system.

    % vi europe

  • Fourth. To execute the following items, you need to obtain root privileges on the device. You can do this using the su program.

    % su
    Password:
    root @ junos-host%


    A legitimate question arises: "Where can I get the password for the root user"? Well, of course, if you do not know him. The password is stored in the device configuration, system section.

    system {
        root-authentication {
            encrypted-password "$ 1 $ z.GrqhbO $ aveIsL2fd4sUbADBrE8Y9 /"; ## SECRET-DATA
        }
    }

    If necessary, you can change it:

    admin-name @ junos-host> edit
    Entering configuration mode

    [edit]
    admin-name @ junos-host #
    set system root-authentication plain-text-password
    New password:
    Retype new password:

    [edit]
    admin-name @ junos-host #
    commit
    commit complete

  • Fifth. To compile a user database of time zones, we use the “compile-tz” script. In it, in fact, there is only a call to the zic application with predefined parameters.

    % / usr / libexec / ui / compile-tz europe

    As the script parameters we pass the name of the source file or several files, or any parameters valid for the zic command.

    The resulting compiled time zone database files will be placed in the directory: "/ var / db / zoneinfo /".

  • Sixth. How to apply the resulting base? You just need to indicate the use of the imported time zone database (use-imported-time-zones) and set the time zone (time-zone) correctly.

    [edit]
    admin-name @ junos-host #
    set system use-imported-time-zones

    [edit]
    admin-name @ junos-host #
    set system time-zone Europe / Moscow

    [edit]
    admin-name @ junos-host #
    commit
    commit complete

  • Seventh. You can verify the result with the command:

    admin-name @ junos-host> show system uptime