HON’s Wiki # Juniper Junos OS

Home / Networking

Contents

TODO Clean up, reorganize and add remaining stuff.

Resources

Initial Setup

Common setup for MX, SRX, QFX, EX.

  1. Connect to the switch using serial:
    • RS-232 w/ RJ45, baud 9600, 8 data bits, no parity, 1 stop bits, no flow control.
  2. Log in:
    1. It should say “Amnesiac” above the login prompt as the name of the switch, to show that it’s factory reset.
    2. Login as root with no password to enter the shell.
    3. Enter the Junos operational CLI by typing cli.
  3. (EX) (Optional) Free virtual chassis ports (VCPs) for normal use:
    1. Enter op mode.
    2. Show VCPs: show virtual-chassis vc-port
    3. Remove VCPs: request virtual-chassis vc-port delete pic-slot <pic-slot> port <port-number>
    4. Show again to make sure they disappear. This may take a few seconds.
  4. (Note) Enter configuration mode:
    • Enter: configure
    • Commit: commit
    • Exit: exit
  5. Set host name:
    1. set system host-name <host-name>
    2. set system domain-name <domain-name>
  6. (Not MX) Enable auto snapshotting and restoration on corruption:
    1. set system auto-snapshot
  7. Disable DHCP auto image upgrade:
    1. delete chassis auto-image-upgrade
  8. Set new root password:
    1. set system root-authentication plain-text-password (prompts for password)
  9. Set idle timeout:
    1. set system login idle-timeout 60 (60 minutes)
  10. (Optional) Commit new config:
    1. commit
  11. Setup a non-root user:
    1. set system login user <user> [full-name <full-name>] class super-user authentication plain-text-password (prompts for password)
  12. (SRX) Enable IPv6 forwarding (SRX):
    1. Enable: set security forwarding-options family inet6 mode flow-based
    2. (Info) Verify (after commit): show security flow status
  13. Setup SSH:
    1. Enable server: set system services ssh
    2. Disable root login from SSH: set system services ssh root-login deny-password
    3. (Note) Do not use ssh root-login deny, it may cause FPCs to go unresponsive and offline for Junos v21 and later (link).
  14. (Maybe) Disable licensing and phone-home (for grey-market devices):
    1. delete system license
    2. delete system phone-home
  15. Set DNS servers:
    1. Delete default: delete system name-server
    2. Set new (for each one): set system name-server <addr>
  16. Set time:
    1. Set time zone: set system time-zone Europe/Oslo (example)
    2. (Optional) Set time manually (UTC): run set date <YYYYMMDDhhmm.ss>
    3. (Deprecated) Set server to use while booting (forces initial time): set system ntp boot-server <address>
    4. Set server to use periodically (for tiny, incremental changes): set system ntp server <address>
    5. (Info) After committing, use show ntp associations to verify NTP.
    6. (Info) After committing, use set date ntp to force it to update. This may be required if the delta is too large and the NTP client refuses to update.
  17. Set misc system options:
    1. Setup loopback as default address: set system default-address-selection
    2. Enable PMTUD: set system internet-options path-mtu-discovery
  18. Configure LLDP:
    1. (Optional) Enable for all interfaces: set protocols lldp interface all
    2. (Optional) Enable for specific interfaces: set protocols lldp interface xe-0/1/0
    3. (Optional) Disable for specific interfaces: set protocols lldp interface xe-0/1/0 disable
  19. Configure SNMP:
    1. (Info) SNMP is extremely slow on the Juniper devices I’ve tested it on.
    2. Enable public RO access (or generate a secret community string): set snmp community public authorization read-only
  20. (Optional) Set loopback addresses (if using routing):
    1. set interfaces lo0.0 family inet address <address>/32
    2. set interfaces lo0.0 family inet6 address <address>/32
  21. (Optional) Setup static IP routes (if not using dynamic routing):
    1. IPv4 default gateway: set routing-options rib inet.0 static route 0.0.0.0/0 next-hop <next-hop>
    2. IPv6 default gateway: set routing-options rib inet6.0 static route ::/0 next-hop <next-hop>
    3. (Optional) Setup null routes for site prefixes.
  22. Disable management port link-down alarm:
    1. Disable alarm: set chassis alarm management-ethernet link-down ignore
  23. Disable management port:
    1. (Note) This port goes by many names: fxp0, me0, em0, em1, vme, …
    2. Delete interface: delete int <port>
    3. Disable interface: set int <port> disable
    4. (If exists) Disable RA: delete protocols router-advertisement interface <port>.0
  24. (Optional) Set PIC interface speed/mode (if applicable):
    1. (Info) E.g. the device has 40G/100G ports and you need to configure the ports for them to show up in sh int terse.
    2. (Info) Some devices have a maximum capacity that can’t be oversubscribes, e.g. 400G for the MX204.
    3. Show FPCs and PICs: run show chassis fpc pic-status
    4. Set speed (example): set chassis fpc 0 pic 0 port 0 40g
  25. (EX/QFX/SRX) Create VLANs:
    1. Create: set vlans <name> vlan-id <VID>
    2. (Optional) Set RVI: set vlans <name> l3-interface irb.<VID>
  26. Setup interfaces: See section below.
  27. (EX/QFX/SRX) Configure RSTP:
    • (Note) RSTP is enabled for all interfaces by default.
    • Enter config section: edit protocols rstp
    • Set interfaces: set interfaces all (example)
    • Set priority: set bridge-priority <priority> (default 32768/32k, should be a multiple of 4k, use e.g. 32k for access, 8k for distro and 4k for core)
    • (Optional) Set hello time: set hello-time <seconds> (default 2s)
    • (Optional) Set maximum age: set max-age <seconds> (default 20s)
    • (Optional) Set forward delay: set forward-delay <seconds> (default 15s)
    • Set edge ports: wildcard range set protocols rstp interface ge-0/0/[2-5] edge (example)
    • Enable BPDU guard on all edge ports: set protocols rstp bpdu-block-on-edge
  28. (SRX) Setup security stuff (zones, policies, NAT, screens).
    1. delete security
    2. Setup as desired.
  29. Commit configuration: commit [confirmed]
  30. Exit config CLI: exit
  31. Save the rescue config: request system configuration rescue save
  32. (SRX) Save the autorecovery info: request system autorecovery state save
  33. (SRX) Reboot the device to change forwarding mode and stuff (if changed): request system reboot

Interfaces

  1. (Optional) Delete default interfaces configs (example):
    1. wildcard range delete interface ge-0/0/[0-7]
  2. (EX/QFX/SRX) (Optional) Disable default VLAN RVI:
    1. (Note) The interface is called vlan for older devices and irb for newer ones.
    2. Delete config: delete int irb.0
    3. Disable: set int irb.0 disable
  3. (Optional) Disable unused interfaces (example):
    1. wildcard range set interface ge-0/0/[0-7] disable
    2. set interface cl-1/0/0 disable
    3. set interface dl0 disable
  4. (Optional) Setup interface-ranges (apply config to multiple configured interfaces):
    • Declare range: edit interfaces interface-range <name>
    • Add member ports: member-range <begin-if> to <end-if>
    • Configure it as a normal interface, which will be applied to all members.
  5. (Optional) Setup LACP toward upstream/downstream switch:
    1. (Info) Make sure you allocate enough LAG interfaces and that the interface numbers are below some arbitrary power-of-2-limit for the device model. Maybe the CLI auto-complete shows a hint toward the max.
    2. Set number of available LAG interfaces: set chassis aggregated-devices ethernet device-count <0-64>
    3. Delete old configs for member interface: wildcard range delete interfaces ge-0/0/[0-1] (example)
    4. Add member interfaces: wildcard range set interfaces ge-0/0/[0-1] ether-options 802.3ad ae<n>
    5. Add some description to member interfaces: wildcard range set interfaces ge-0/0/[0-1] description link:switch
    6. Enter LAG interface: edit interface ae<n>
    7. Set description: set desc link:switch
    8. Set LACP active: set aggregated-ether-options lacp active
    9. Set LACP fast: set aggregated-ether-options lacp periodic fast
    10. (Optional) Set minimum links: aggregated-ether-options minimum-links 1
  6. (EX/QFX/SRX) Setup switch trunk ports:
    1. (Note) vlan members supports both numbers and names. Use the [VLAN1 VLAN2 <...>] syntax to specify multiple VLANs.
    2. (Note) Instead of specifying which VLANs to add, specify vlan members all and vlan except <excluded-VLANs>.
    3. (Note) vlan members should not include the native VLAN (if any).
    4. Enter unit 0 and family ethernet-switching of the physical/LACP interface.
    5. Set mode: set port-mode trunk
    6. Set VLANs: set vlan members <VLANs>
    7. (Optional) Set native VLAN: set native-vlan-id <VID>
  7. (EX/QFX/SRX) Setup access ports:
    1. Enter unit 0 and family ethernet-switching of the physical/LACP interface.
    2. Set access VLAN: set vlan members <VLAN-name>
  8. (EX/QFX/SRX) Setup VLAN L3 interfaces:
    1. (VLAN) Set L3-interface: set vlans <name> l3-interface irb.<VID>
    2. Enter unit 0 of physical/LACP interface or irb.<VID> for VLAN interfaces.
    3. Set IPv4 address: set family inet address <address>/<prefix-length>
    4. Set IPv6 address: set family inet6 address <address>/<prefix-length>
  9. (Optional) Disable/enable Ethernet flow control:
    • (Note) Junos uses the symmetric/bidirectional PAUSE variant of flow control.
    • (Note) This simple PAUSE variant does not take traffic classes (for QoS) into account and will pause all traffic for a short period (no random early detection (RED)) if the receiver detects that it’s running out of buffer space, but it will prevent dropping packets within the flow control-enabled section of the L2 network. Enabling it or disabling it boils down to if you prefer to pause (all) traffic or drop (some) traffic during congestion. As a guideline, keep it disabled generally (and use QoS or more sophisticated variants instead), but use it e.g. for dedicated iSCSI networks (which handle delays better than drops). Note that Ethernet and IP don’t require guaranteed packet delivery.
    • (Note) It may be enabled by default, so you should probably enable/disable it explicitly (the docs aren’t consistent with my observations).
    • (Note) Simple/PAUSE flow control (flow-control) is mutually exclusive with priority-based flow control (PFC) and asymmetric flow control (configured-flow-control).
    • Disable on Ethernet interface (explicit): set interface <if> [aggregated-]ether-options no-flow-control
    • Enable (explicit): ... flow-control
  10. (Optional) Enable EEE (Energy-Efficient Ethernet, IEEE 802.3az):
    • (Note) For reducing power consumption during idle periods. Supported on RJ45 copper ports.
    • (Note) There generally is no reason to not enable this on all ports, however, there may be certain devices or protocols which don’t play nice with EEE (due to poor implementations).
    • Enable on RJ45 Ethernet interface: set interface <if> ether-options ieee-802-3az-eee

Commands

TODO Cleanup. Combine with SRX- and QFX-setup?

Usage

Port Mirroring (SPAN)

Booting

The devices have two partitions; the primary and the backup. One of them will be designated as active and that choice will be remembered across reboots. When the active partition is damaged, the device will boot into the other partition. When the backup partition is the active partition, an alarm will be set and a banner shown.

Change active partition and reboot: request system reboot slice alternate media internal

Shutting It Down

The devices should be shut down gracefully instead of just pulling the power. This will prevent corrupting the file system.

Wait for the “The operating system has halted.” text before pulling the power, so that system processess are stopped and disks are synchronized. The system LED turning off and the LCD saying “HALTING…” does not mean that the halting process is finished yet.

Basics

TODO Move this.

Move Config

Interfaces

IPv6 Neighbor Discovery (ND)

DHCPv4 Server

Events

Rescue Configuration

Autorecovery

Miscellanea

Tasks

Reset Config or Root Password

  1. Power on the device and prepare for the next step.
  2. Wait for the “Hit [Enter] to boot immediately, or space bar for command prompt.” message to be shown and then press space. You should immediately enter a prompt (typically loader>).
  3. Run boot -s to boot into single-user mode.
  4. When prompted for a shell, enter recovery.
  5. Wait for the device to fully boot.
  6. (Alternative 1) Zeroize the system by running request system zeroize (this will delete all configuration).
  7. (Alternative 2) Set a new root password and commit (there should be instructions before the prompt). Reboot the device afterwards.

Mount a USB Drive

Note: USB3 drives may not work properly. Use USB2 drives.

  1. Make sure the drive is MBR-partitioned and that the partition is formatted as FAT32 (mkfs.fat -F32).
  2. To make it easier to find the device path in Junos, don’t insert the USB drive just yet.
  3. Show current storage devices: ls -l /dev/da*
  4. Insert the drive. It should print a few lines to the console.
  5. Show current storage devices again and find the new device. (df -h may also be used to see which one is in use.)
  6. Mount it: mkdir /var/tmp/usb0 && mount_msdosfs <device> /var/tmp/usb0 (arbitrary path)
  7. Check that it’s mounted properly: ls -l /var/tmp/usb0
  8. Do stuff with it.
  9. Unmount it: umount /var/tmp/usb0 && rmdir /var/tmp/usb0

Upgrade Junos

Normal Method

This should work in most cases and is the most streamlined version, but may not work for major version hops and stuff.

  1. (Info) For virtualized boxes like EX4600 and QFX5100, skip the request system snapshot parts as these boxes are built differently wrt. Junos.
  2. Cleanup old files: request system storage cleanup
    • Do this before mounting the USB or downloading the files, as the upgrade files may get wiped.
  3. Make sure the alternate partition contains a working copy of the current version: See Validate the Partitions.
  4. If downloading from a remote location:
    1. Get the file: file copy <remote-url> /var/tmp/
      • If it says it ran out of space, add staging-directory /var/tmp. By defaults it’s buffered on the root partition, which may be tiny.
      • Alternatively, copy the file into the device from the remote device, using SCP.
  5. If copying from a USB drive:
    1. Format the USB drive using FAT32 and copy the software file to the drive.
    2. Enter shell mode on the device: start shell user root
    3. Mount the USB drive: mkdir /var/tmp/usb0 && mount_msdosfs /dev/da1s1 /var/tmp/usb0
    4. Check the contents (copy the filename for later): ls -l /var/tmp/usb0
    5. Copy the file to internal storage: cp /var/tmp/usb0/jinstall* /var/tmp/
    6. Unmount and remove the USB drive: umount /var/tmp/usb0 && rmdir /var/tmp/usb0
    7. Enter operational CLI again: exit (or cli)
  6. Prepare upgrade: request system software add /var/tmp/<file> no-copy unlink reboot [no-validate] [force-host] (supports auto-complete)
    • no-copy prevents copying the file first (in this case it’s pointless).
    • unlink removes the file afterwards.
    • reboot reboots the device, so the upgrade can begin when booting.
    • If it complains about certificate problems, consider disabling verification using no-validate.
    • For virtualized devices, add force-host to upgrade the host too.
    • If the date is significantly wrong on the device and NTP isn’t used/synced, set it manually with set date <YYYYMMDDhhmm> first so validation doesn’t fail.
    • It may produce some insignificant errors in the process (commands not found etc.).
  7. See Validate the Partitions to copy the upgraded partition to the other partition.

From the Loader

If the normal method did not work, try this instead.

  1. Copy the file to the device disk using the “normal” USB method.
  2. Connect using a serial cable.
  3. Reboot the device and press space at the right time to enter the loader.
    • The message to wait for should look like this: Hit [Enter] to boot immediately, or space bar for command prompt.
  4. Format and flash: install --format file:///jinstall-whatever.tgz (with correct name, no /var/tmp/)
  5. See Validate the Partitions to copy the upgraded partition to the other partition.

Validate the Partitions

Do this before as a check and after to make sure the new image is working and copied to both partitions.

  1. Log into the CLI.
  2. Verify that the system is booted from the active partition of the internal media: show system storage partitions (should show Currently booted from: active)
  3. Verify that the current Junos version for the primary partition is correct: show system snapshot media internal
  4. Copy to the alternate root partition, so both have the same version (may take several minutes): request system snapshot slice alternate
  5. Verify that the primary and backup partitions have the same Junos version: show system snapshot media internal
    • If the command fails, wait a bit and try again. The copy may still be happening in the background.
  6. (Info) To boot from the alternative partition: request system reboot slice alternate media internal

ISSU and NSSU

Just info, no instructions here.

Fix a Corrupt Root Partition

If one of the root partitions get corrupted (e.g. due to sudden power loss), the device will boot to the alternate root partition. This can be fixed by cloning the new active partition to the alternate, corrupt partition.

See Validate the Partitions or [EX] Switch boots from backup root partition after file system corruption occurred on the primary root partition (Juniper).

Info

Junos OS

Versions

Interfaces

Interface name structure:

Physical interfaces:

Prefix Type Example
fe 100M Ethernet fe-0/0/0
ge 1G Ethernet ge-0/0/0
xe 10G Ethernet xe-0/0/0
et 25G/40G/100G Ethernet et-0/0/0
mge Multi-rate Ethernet  
fxp Mgmt. interface on RE (0-1) (SRX)  
me Management Ethernet  
em Management Ethernet  
fc Fibre Channel (FC)  
at ATM  
pt VDSL2  
cl 3G/LTE  
dl Dialer for LTE (cl) dl0.0
se Serial  
e1 E1  
e3 E3  
t1 T1  
t2 T2  
wx WXC ISM  
reth Chassis cluster traffic  

Special interfaces:

Prefix Type Example
lo Loopback (some are internal) lo0
ae Aggregated Ethernet (LAG) ae0
irb IRB irb.0
dsc Discard (internal) dsc
tap Tap (internal) tap
fti Flexible Tunnel Interface (FTI) fti0
gr GRE tunnel gr-0/0/0
ip IP-over-IP tunnel ip-0/0/0
lsq Link services queueing interface (MLPPP, MLFR, CRTP) lsq-0/0/0
lt Logical tunnel (SRX) lt-0/0/0
mt Multicast tunnel mt-0/0/0
sp Adaptive services (unit 16383 is internal) sp-0/0/0

hon.one | HON95/wiki | Edit page