Pages

Wednesday, March 22, 2017

Juniper JUNOS Commands (Tips and Tricks)

Juniper Networks has a Day one book for 'JunOS Tips, Techniques, and Templates 2011' in Junos Fundamentals Series. To record some my own tips, I put them together in this post. Let me know if you have some more to share.

1.  Find big size files 

find . -type f -size +10000 -exec ls -lh {} \; 


root@FW% find . -type f -size +10000 -exec ls -lh {} \;
-rw-r--r--  1 930  929   134M Jan  5 17:34 ./cf/packages/junos-11.4R6.6-domestic
-rw-r--r--  1 root  wheel   139M Sep  8  2011 ./cf/var/log/junos-srxsme-11.2R2.4-domestic.tgz
-rw-r-----  1 root  wheel   4.9M Feb 11 17:12 ./cf/var/db/idpd/db/secdb_02.db
-rw-r-----  1 root  wheel   6.7M Feb 11 17:13 ./cf/var/db/idpd/db/secdb_03.db
-rw-r-----  1 root  wheel    64M Feb 11 17:13 ./cf/var/db/idpd/db/secdb_06.db
-rwxr-xr-x  1 admin  20    24M May 23 08:38 ./cf/var/db/idpd/nsm-download/SignatureUpdate.xml
-r-xr-xr-x  1 root  wheel   5.2M Jan  5 17:33 ./jail/html/dynamic-vpn/client/jam/InstallerComponentSRX.exe
-rw-r--r--  1 root  wheel   139M Sep  8  2011 ./jail/var/log/junos-srxsme-11.2R2.4-domestic.tgz
-rw-r-----  1 root  config    14M Feb  8 22:16 ./mfs/var/run/db/schema.db
-rw-r-----  1 root  wheel    10M Feb  8 22:19 ./mfs/var/sdb/log.0000000001
-r--r--r--  1 root  wheel   6.5M Jan  5 13:59 ./usr/lib/dd/libjkernel-dd.so
-r-xr-xr-x  1 root  wheel    13M Jan  5 15:39 ./usr/sbin/authd
-r-xr-xr-x  1 root  wheel   6.0M Jan  5 16:51 ./usr/sbin/chassisd
-r-xr-xr-x  1 root  wheel    27M Jan  5 13:05 ./usr/sbin/flowd_octeon
-r-xr-xr-x  1 root  wheel    34M Jan  5 13:05 ./usr/sbin/flowd_octeon_hm
-r-xr-xr-x  1 root  wheel   5.5M Jan  5 16:51 ./usr/sbin/kmd
-r-xr-xr-x  1 root  wheel    13M Jan  5 16:24 ./usr/sbin/rpd

% find / -size +100000 | xargs ls -lhS
find: /mfs/var/spool/opielocks: Permission denied
-rw-r--r--  1 930   929     142M Aug 28  2014 /cf/packages/junos-12.1X44-D40.2-domestic
-rw-r-----  1 root  wheel    84M Feb 23 21:31 /cf/var/db/idpd/db/secdb_06.db


2. Connecting to the secondary node from the primary node on an SRX cluster
On the branch SRX devices, this can be achieved by the command:
{primary:node0}
lab@host-A> request routing-engine login node 1

--- JUNOS 10.1R3.7 built 2010-011-10 04:15:10 UTC
{secondary:node1}
lab@host-B>


On the high-end SRX devices, you will need to be in the shell and run the following command:

root@host-A% rlogin -T node1

3. Juniper system software in-service-upgrade (Maintenance) for less downtime upgrade

JUNOS> request system software in-service-upgrade /var/tmp/junos-srxsme-12.1X44-D35.5-domestic.tgz no-sync no-validate 
ISSU: Validating package
WARNING: in-service-upgrade shall reboot both the nodes
         in your cluster. Please ignore any subsequent
         reboot request message
ISSU: start downloading software package on secondary node
Pushing bundle to node1
Formatting alternate root (/dev/da0s1a)...
/dev/da0s1a: 297.9MB (610028 sectors) block size 16384, fragment size 2048
        using 4 cylinder groups of 74.47MB, 4766 blks, 9600 inodes.
super-block backups (for fsck -b #) at:
 32, 152544, 305056, 457568
Installing package '/altroot/cf/packages/install-tmp/junos-12.1X44-D35.5-domestic' ...
Verified junos-boot-srxsme-12.1X44-D35.5.tgz signed by PackageProduction_12_1_0
Verified junos-srxsme-12.1X44-D35.5-domestic signed by PackageProduction_12_1_0
JUNOS 12.1X44-D35.5 will become active at next reboot
WARNING: A reboot is required to load this software correctly
WARNING:     Use the 'request system reboot' command
WARNING:         when software installation is complete
Saving state for rollback ...
ISSU: finished upgrading on secondary node node1
ISSU: start upgrading software package on primary node
Formatting alternate root (/dev/da0s2a)...
/dev/da0s2a: 297.9MB (610044 sectors) block size 16384, fragment size 2048
        using 4 cylinder groups of 74.47MB, 4766 blks, 9600 inodes.
super-block backups (for fsck -b #) at:
 32, 152544, 305056, 457568
Installing package '/altroot/cf/packages/install-tmp/junos-12.1X44-D35.5-domestic' ...
Verified junos-boot-srxsme-12.1X44-D35.5.tgz signed by PackageProduction_12_1_0
Verified junos-srxsme-12.1X44-D35.5-domestic signed by PackageProduction_12_1_0
JUNOS 12.1X44-D35.5 will become active at next reboot
WARNING: A reboot is required to load this software correctly
WARNING:     Use the 'request system reboot' command
WARNING:         when software installation is complete
Saving state for rollback ...
ISSU: failover all redundancy-groups 1...n to primary node
Successfully reset all redundancy-groups priority back to configured ones.
Redundancy-groups-0 will not be reset and the primaryship remains unchanged.
Successfully reset all redundancy-groups priority back to configured ones.
Redundancy-groups-0 will not be reset and the primaryship remains unchanged.
Initiated manual failover for all redundancy-groups to node0
Redundancy-groups-0 will not failover and the primaryship remains unchanged.
ISSU: rebooting Secondary Node
Shutdown NOW!
[pid 69249]



4. Copy files between two Cluster Members

root@fw-2> file copy /var/tmp/junos10.3.tgz node0:/var/tmp/junos10.3.tgz

or use fxp0.0 interface ip to do file transferring:


root@fw-2>file copy /var/tmp/junos10.3.tgz 10.2.8.4:/var/tmp/junos10.3.tgz

5.  Juniper Web Tool :

SRX HA Configuration Generator


6.  Monitor Commands to do flow trace without commit


monitor security flow filter incoming-filter protocol icmp destination-prefix 1.1.1.1
monitor security flow filter outgoing-filter protocol icmp source-prefix 1.1.1.1
monitor security flow file logflow.log
show monitor security flow
show log logflow.log
monitor security flow stop
clear monitor security flow filter incoming-filter
clear monitor security flow filter outgoing-filter

7. Delete Whole Configuartion

  • Delete
root@fw-1# delete
This will delete the entire configuration
Delete everything under this level? [yes,no] (no) yes
root@fw-1# set system root-authentication plain-text-password
New password:
Retype new password:

  • request services fips zeroize
  • request system zeroize
  • load factory-default
  • zeroize 

root@fw-1# request system zeroize

8. Load the Commands/Configuration through the CLI

{primary:node0}[edit]
root@fw-1# load set terminal
[Type ^D at a new line to end input]
load complete

{primary:node0}[edit]
root@fw-1# 

{primary:node0}[edit security zones]
root@fw-1# load merge relative terminal 

[Type ^D at a new line to end input]

security-zone C-Clients {
        tcp-rst;
        address-book {
            address n-10.9.20.0 10.9.20.0/24;
        }
        interfaces {
            reth1.0;
        }

    }
load complete


{primary:node0}[edit security zones]


9. Troubleshoot traffic flowing through SRX


root@fw-srx1> show configuration security flow | display set
set security flow traceoptions file flow-trace
set security flow traceoptions flag basic-datapath
set security flow traceoptions packet-filter f0 source-prefix 10.9.20.14/32
set security flow traceoptions packet-filter f0 destination-prefix 10.9.1.5/32
commit and quit


10. Disable Juniper SRX Clustering

{primary:node1}
user@host> set chassis cluster disable reboot
Successfully disabled chassis cluster. Going to reboot now.


11. Commands to collect logs for JTAC

  • request support information | save /var/log/rsi.node0.txt
  • file archive compress source /var/log/* destination /var/tmp/varlog.node0

12. Installs the new software package

root@fw-2> request system software add /var/tmp/junos-srxsme-12.1X44-D40.2-domestic.tgz no-validate no-copy partition
Checking for free space on /var/tmp/install
Copying package /var/tmp/junos-srxsme-12.1X44-D40.2-domestic.tgz to /var/tmp/install
Checking for basic sanity of copied package
WARNING: Installation with partition option will take several minutes to complete
WARNING: Please do not power-cycle the system till the installation is over
WARNING: A reboot is required to install the software
WARNING:     Use the 'request system reboot' command immediately

{secondary:node1}
root@fw-2> request system reboot
Reboot the system ? [yes,no] (no) yes

Shutdown NOW!
[pid 2098]


Note: Partition option introduced in the command in Release 10.1. of Junos OS. (Optional) Partition option will do  format and re-partition the media before installation.


13. Packet Captures on Juniper SRX

Juniper SRX packet captures
1. Configure the forwarding options and limits
configure shared

set forwarding-options packet-capture file filename JTAC.pcap files 10 size 10000

set forwarding-options packet-capture maximum-capture-size 1500



2. Create your filter

set firewall filter PCAP term capture from source-address 192.168.1.1.32

set firewall filter PCAP term capture from destination-address 10.15.61.45/32

set firewall filter PCAP term capture from protocol tcp

set firewall filter PCAP term capture from destination-port 443

set firewall filter PCAP term capture then accept

set firewall filter PCAP term allow-all-else then accept



3. Define the interface(s) that will capture the trafffic

set interfaces ge-0/0/3 unit 0 family inet filter input PCAP

commit and-quit

**** input indicated to capture packets received.  PCAP is the name of our firewall filter*****

4. Read the tcpdump file from the shell
start shell                                
cd /var/tmp
tcpdump –r pcap.ge-0.0.3


5. Cleanup 
cli
configure
delete interfaces ge-0/0/3 unit 0 family inet filter input PCAP    (stops the cap)      
delete firewall filter PCAP                                   (turns off the filter)
delete forward-options packet-capture
commit and-quit


% rm /var/tmp/pcap.ge-0.0.3.



14. Delete IDP database for System Software Upgrade
Some old SRX series does not have enough storage space to hold the new software release if enabled some other features, such as IDP. IDP database will easily hold 180M space on your system. Based on the information from http://jsrx.juniperwiki.com/index.php?title=IDP#Troubleshooting, to upgrade srx system without enough space, we can delete everything in the idp database, then add your new image and reboot:

root@fw-m-test-1>  start shell 
root@fw-m-test-1% cd /var/db/idpd/db/
root@fw-m-test-1% rm -rfv * 


root@fw-m-test-1% cli

{primary:node0}
root@fw-m-test-1> 

{primary:node0}
root@fw-m-test-1> request system storage cleanup 

List of files to delete:

         Size Date         Name
  4403B Mar 22 15:54 /cf/var/log/default-log-messages.0.gz
    66B Feb  2 21:31 /cf/var/log/idpd_err.20170202
    88B Mar 22 01:38 /cf/var/log/idpd_err.20170322
   152B Mar 22 15:54 /cf/var/log/interactive-commands.0.gz
  9712B Mar 22 15:54 /cf/var/log/messages.0.gz
  35.9K Mar 19 12:45 /cf/var/log/messages.1.gz
   146B Mar 22 15:54 /cf/var/log/traffic-create.0.gz
   144B Mar 22 15:54 /cf/var/log/traffic-deny.0.gz
   143B Mar 22 15:54 /cf/var/log/traffic-log.0.gz
  28.9K Mar 22 15:53 /cf/var/log/wtmp.0.gz
  34.1K Feb 24 20:32 /cf/var/log/wtmp.1.gz
    52B Jan 25 21:06 /cf/var/log/wtmp.2.gz
    60B Mar 15 00:32 /cf/var/tmp/policy_status
     0B Feb 13 21:17 /cf/var/tmp/spu_kmd_init
Delete these files ? [yes,no] (no) yes 


{primary:node0}
root@fw-m-test-1> show version 
node0:
--------------------------------------------------------------------------
Hostname: fw-m-test-1
Model: srx240h
JUNOS Software Release [12.1X44-D40.2]

node1:
--------------------------------------------------------------------------
Hostname: fw-m-test-2
Model: srx240h
JUNOS Software Release [12.1X44-D40.2]

{primary:node0}
root@fw-m-test-1> exit 

root@fw-m-test-1% du -sh /cf/var/db/
187M    /cf/var/db/
root@fw-m-test-1% du -sh /cf/var/db/idpd
167M    /cf/var/db/idpd


root@fw-m-test-1% cd /var/db/idpd/db/
root@fw-m-test-1% ls
__db.register   secdb_01.db     secdb_03.db     secdb_05.db     secdb_07.db     secdb_09.db     secdb_12.db     secdb_14.db     secdb_16.db     secdb_18.db
dfa_cache       secdb_02.db     secdb_04.db     secdb_06.db     secdb_08.db     secdb_10.db     secdb_13.db     secdb_15.db     secdb_17.db
root@fw-m-test-1% rm -rfv * 
__db.register
dfa_cache/rexp_grp_cache.db
dfa_cache/rexp_cache.db
dfa_cache/pcre_cache.db
dfa_cache
secdb_01.db
secdb_02.db
secdb_03.db
secdb_04.db
secdb_05.db
secdb_06.db
secdb_07.db
secdb_08.db
secdb_09.db
secdb_10.db
secdb_12.db
secdb_13.db
secdb_14.db
secdb_15.db
secdb_16.db
secdb_17.db
secdb_18.db
root@fw-m-test-1% cli
{primary:node0}
root@fw-m-test-1> show system storage 
node0:
--------------------------------------------------------------------------
Filesystem              Size       Used      Avail  Capacity   Mounted on
/dev/da0s1a             293M       148M       121M       55%  /
devfs                   1.0K       1.0K         0B      100%  /dev
/dev/md0                390M       390M         0B      100%  /junos
/cf                     293M       148M       121M       55%  /junos/cf
devfs                   1.0K       1.0K         0B      100%  /junos/dev/
procfs                  4.0K       4.0K         0B      100%  /proc
/dev/bo0s3e              24M       194K        22M        1%  /config
/dev/bo0s3f             342M       167M       148M       53%  /cf/var
/dev/md1                168M        19M       135M       12%  /mfs
/cf/var/jail            342M       167M       148M       53%  /jail/var
/cf/var/log             342M       167M       148M       53%  /jail/var/log
devfs                   1.0K       1.0K         0B      100%  /jail/dev
/dev/md2                 39M       4.0K        36M        0%  /mfs/var/run/utm
/dev/md3                1.8M       4.0K       1.7M        0%  /jail/mfs

node1:
--------------------------------------------------------------------------
Filesystem              Size       Used      Avail  Capacity   Mounted on
/dev/da0s1a             293M       148M       121M       55%  /
devfs                   1.0K       1.0K         0B      100%  /dev
/dev/md0                390M       390M         0B      100%  /junos
/cf                     293M       148M       121M       55%  /junos/cf
devfs                   1.0K       1.0K         0B      100%  /junos/dev/
procfs                  4.0K       4.0K         0B      100%  /proc
/dev/bo0s3e              24M       196K        22M        1%  /config
/dev/bo0s3f             342M       160M       156M       51%  /cf/var
/dev/md1                168M        19M       135M       12%  /mfs
/cf/var/jail            342M       160M       156M       51%  /jail/var
/cf/var/log             342M       160M       156M       51%  /jail/var/log
devfs                   1.0K       1.0K         0B      100%  /jail/dev
/dev/md2                 39M       4.0K        36M        0%  /mfs/var/run/utm
/dev/md3                1.8M       4.0K       1.7M        0%  /jail/mfs

{primary:node0}

root@fw-m-test-1> request system software add no-copy validate /var/tmp/junos-srxsme-12.1X46-D55.3-domestic.tgz 
Formatting alternate root (/dev/da0s2a)...
/dev/da0s2a: 298.0MB (610284 sectors) block size 16384, fragment size 2048
        using 4 cylinder groups of 74.50MB, 4768 blks, 9600 inodes.
super-block backups (for fsck -b #) at:
 32, 152608, 305184, 457760
Extracting /var/tmp/junos-srxsme-12.1X46-D55.3-domestic.tgz ...
Checking compatibility with configuration
Initializing...
Verified manifest signed by PackageProduction_12_1_0
Verified junos-12.1X44-D40.2-domestic signed by PackageProduction_12_1_0
Using junos-12.1X46-D55.3-domestic from /altroot/cf/packages/install-tmp/junos-12.1X46-D55.3-domestic
Copying package ...
Verified manifest signed by PackageProductionRSA_2016
Hardware Database regeneration succeeded
Validating against /config/juniper.conf.gz
Usage: license-check -f "<features>" -m -p -q -M -u -U -V
  -V verify if release based licenses are present
rtslib: WARNING version mismatch for msg notify msg: expected 0 got 98,a reboot or software upgrade may be required

rtslib: WARNING version mismatch for msg residx: expected 98 got 0,a reboot or software upgrade may be required

rtslib: WARNING version mismatch for msg unknown: expected 98 got 0,a reboot or software upgrade may be required

rtslib: WARNING version mismatch for msg notify msg: expected 0 got 98,a reboot or software upgrade may be required

rtslib: WARNING version mismatch for msg residx: expected 98 got 0,a reboot or software upgrade may be required

rtslib: WARNING version mismatch for msg unknown: expected 98 got 0,a reboot or software upgrade may be required

rtslib: WARNING version mismatch for msg notify msg: expected 0 got 98,a reboot or software upgrade may be required

rtslib: WARNING version mismatch for msg residx: expected 98 got 0,a reboot or software upgrade may be required

rtslib: WARNING version mismatch for msg unknown: expected 98 got 0,a reboot or software upgrade may be required


Unified access control daemon: [edit services unified-access-control]
Unified access control daemon:   'infranet-controller ic4500'
Unified access control daemon:     warning: We recommend that you configure the ca-profile to verify infranet controller's certificate in order to prevent a man-in-the-middle attack
Connectivity fault management process: rtslib: WARNING version mismatch for msg notify msg: expected 0 got 98,a reboot or software upgrade may be required
Connectivity fault management process:
Connectivity fault management process: rtslib: WARNING version mismatch for msg residx: expected 98 got 0,a reboot or software upgrade may be required
Connectivity fault management process:
Connectivity fault management process: rtslib: WARNING version mismatch for msg unknown: expected 98 got 0,a reboot or software upgrade may be required
Connectivity fault management process:
mgd: commit complete
Validation succeeded
Validating against /config/rescue.conf.gz
Unified access control daemon: [edit services unified-access-control]
Unified access control daemon:   'infranet-controller ic4500'
Unified access control daemon:     warning: We recommend that you configure the ca-profile to verify infranet controller's certificate in order to prevent a man-in-the-middle attack
Connectivity fault management process: rtslib: WARNING version mismatch for msg notify msg: expected 0 got 98,a reboot or software upgrade may be required
Connectivity fault management process:
Connectivity fault management process: rtslib: WARNING version mismatch for msg residx: expected 98 got 0,a reboot or software upgrade may be required
Connectivity fault management process:
Connectivity fault management process: rtslib: WARNING version mismatch for msg unknown: expected 98 got 0,a reboot or software upgrade may be required
Connectivity fault management process:
mgd: commit complete
Validation succeeded
rm: /cf/var/validate/chroot/mfs/var/etc/pam.conf: Operation not permitted
rm: /cf/var/validate/chroot/mfs/var/etc: Directory not empty
rm: /cf/var/validate/chroot/mfs/var: Directory not empty
rm: /cf/var/validate/chroot/mfs: Directory not empty
rm: /cf/var/validate/chroot: Directory not empty
Installing package '/altroot/cf/packages/install-tmp/junos-12.1X46-D55.3-domestic' ...
Verified junos-boot-srxsme-12.1X46-D55.3.tgz signed by PackageProductionRSA_2016
Verified junos-srxsme-12.1X46-D55.3-domestic signed by PackageProductionRSA_2016
JUNOS 12.1X46-D55.3 will become active at next reboot
WARNING: A reboot is required to load this software correctly
WARNING:     Use the 'request system reboot' command
WARNING:         when software installation is complete


{primary:node0}
root@fw-m-test-1> request system reboot 
Reboot the system ? [yes,no] (no) yes 

Shutdown NOW!
[pid 29172]

{primary:node0}
root@fw-m-test-1>                                                                                
*** FINAL System shutdown message from root@fw-m-test-1 ***               

System going down IMMEDIATELY                                                  
                                                                               
The semaphore timeout period has expired.

--- JUNOS 12.1X46-D55.3 built 2016-07-08 18:46:54 UTC



16. Upgrade JunOS from RAM Disk
Here is the steps to upgrade JunOS from RAM disk if you do not have enough available space on your disk, but you have enough memory free to use.

First, make sure you have enough free memory on your system:
Method 1:

john@FW-SRX-0> show system processes extensive 
node0:
--------------------------------------------------------------------------
last pid: 15489; load averages: 0.14, 0.08, 0.08 up 10+23:35:46 18:27:00
124 processes: 18 running, 92 sleeping, 2 zombie, 12 waiting

Mem: 160M Active, 32M Inact, 560M Wired, 17M Cache, 112M Buf, 201M Free
Swap:


PID USERNAME THR PRI NICE SIZE RES STATE C TIME WCPU COMMAND
1114 root 7 76 0 490M 46780K RUN 0 820.3H 281.10% flowd_octeon_hm
22 root 1 171 52 0K 16K RUN 0 226.7H 86.43% idle: cpu0
23 root 1 -20 -139 0K 16K WAIT 0 170:59 0.00% swi7: clock
5 root 1 -84 0 0K 16K rtfifo 0 56:51 0.00% rtfifo_kern_recv
1120 root 1 76 0 4272K 1644K select 0 38:08 0.00% license-check
1117 root 1 76 0 9864K 3088K select 0 12:40 0.00% jsrpd
1119 root 1 76 0 9924K 3544K select 0 11:29 0.00% rtlogd
25 root 1 -40 -159 0K 16K WAIT 0 11:02 0.00% swi2: net
1111 root 2 76 0 20116K 5336K select 0 9:53 0.00% pfed
1104 root 1 76 0 31052K 4920K select 0 9:03 0.00% chassisd
1105 root 1 76 0 7140K 2500K select 0 8:04 0.00% alarmd
48 root 1 -16 0 0K 16K psleep 0 6:57 0.00% vmkmemdaemon
1101 root 1 76 0 2624K 744K select 0 6:31 0.00% bslockd
26 root 1 -16 0 0K 16K - 0 5:41 0.00% yarrow
1167 root 1 76 0 14640K 5500K select 0 2:53 0.00% mib2d
1168 root 1 76 0 12680K 5480K select 0 2:50 0.00% snmpd
41 root 1 20 0 0K 16K vnlrum 0 2:34 0.00% vnlru_



Method 2:

root@FW-1> show chassis routing-engine
node0:
--------------------------------------------------------------------------
Routing Engine status:
Temperature 36 degrees C / 96 degrees F
CPU temperature 34 degrees C / 93 degrees F
Total memory 1024 MB Max 748 MB used ( 73 percent)
Control plane memory 560 MB Max 386 MB used ( 69 percent)
Data plane memory 464 MB Max 362 MB used ( 78 percent)
CPU utilization:
User 10 percent
Background 0 percent
Kernel 5 percent
Interrupt 0 percent
Idle 85 percent
Model RE-SRX240H
Serial ID AABG0967
Start time 2013-10-02 20:50:57 EDT
Uptime 19 minutes, 26 seconds
Last reboot reason 0x200:normal shutdown
Load averages: 1 minute 5 minute 15 minute
0.27 0.21 0.30



The unused part of control plane memory can be used to create a RAM disk. In the above example you can calculate it (560 - 386 = 174 MB free).
Note: Do not try to create a RAM disk if you do not have enough free memory for this operation. The system may halt and stop responding, if you run out of memory while creating or using the RAM disk.

Other steps to create a RAM Disk
0. Login as root to shell.
1. Create tmp directory: "mkdir /var/tmp/disk1"
2. Mount it to RAM: "mount_mfs -s 200m md /var/tmp/disk1/"
3. Copy Junos image to /var/tmp/disk1
4. From CLI run update "request system software add
/var/tmp/disk1/junos-srxsme-11.4R5.5-domestic.tgz no-copy no-validate"
5. If you have managed to upgrade software on node-0 move to node-1 and upgrade Junos on it.
6. Reboot both nodes at same time.

Note: after reboot, the files in RAM disk will disappear automatically.

17. Enable Security Alarms




References:

1. Day One: Junos Tips, Techniques, and Templates 2011 
2. Junos tips and tricks from My work help blog

Tuesday, March 21, 2017

JunOS Space Network Management Platform Basic Configuration including Log Collector

JunOS Space is in my environment and starting to replace NSM. I have played with in testing lab which recorded in my previous posts:
In this post, I will focus on more regarding JunOS Space itself, some basic configuration to get JunOS space into your production environment.

Notes: Recently Space has been upgraded from 14.1 to 16.1 with my post: Juniper JunOS Space Upgrade Procedures from 14.1 to 16.1. The installation and configuration steps for 16.1 is similar as 14.1. This post is updated during configuring JunOS Space 16.1.

1. Review Space Settings


Space release 16.1R2.7 (381623)

Last login: Wed Mar 22 00:18:53 2017 from 10.9.20.14

Welcome to the Junos Space network settings utility.

Initializing, please wait


Junos Space Settings Menu

1> Change Password
2> Change Network Settings
3> Change Time Options
4> Retrieve Logs
5> Security
6> Expand VM Drive Size
7> (Debug) run shell

A> Apply changes
Q> Quit
R> Redraw Menu

Choice [1-7,AQR]: 2

Change Network Settings:
1> Set DNS Servers
2> Change IP Address of Space node
3> Change Static Routes

A> Apply changes
M> Return to Main Menu
R> Redraw Menu

Choice [1-3,AMR]: 2

Change IP Address of Space node:
1> Change VIP
2> Change Node Management Interface
3> Change Device Management Interface
4> Configure NAT

A> Apply changes
M> Return to Main Menu
R> Redraw Menu

Choice [1-4,AMR]:



Your JunOS Space is ready and first thing probably is to review the settings, which you will find from Administration -> Fabric -> Space Node Settings
Fabric Virtual IP: 10.4.20.19
Management IP: 10.4.20.18
Fabric Node Settings

Also review the applications you installed from Administration ->Applications. You will find out the application version from this page.
Applications


2. Licenses
By default, after installed your JunOS Space, it will be on trial license for 60 days. You will need authorization code and serial number purchased from your partner to generate a new license code. Next a couple of screenshots show the license importing procedures.
Juniper Support Site to Generate License for JunOS Space

Authorization Code and Serial Number you got from Partner

Import License into Space

License Type Changed from Trial to Commercial

3. Authentication Servers
It will be your Radius / Tacacs+ Server which you will use it to authenticate your user to log into JunOS Space. After entered the server info, you can test the connection.
Radius / Tacacs+ Authentication Server
Once Authentication Server created and connection tested, you can create create a remote profile for AD account. The users under User Accounts of Role Based Access Control are local accounts. The users under Remote Profile of Role Based Access Control are AD accounts, which authenticated by Radius server. My another post records all steps how to integrate with a free Radius server TekRADIUS LT version.

TekRADIUS

4. SMTP Server
Put your Internal SMTP server in and do test connection.
SMTP Server

5. Proxy Server
Add your proxy server in your environment. If authentication information needed, add them in as well.
Proxy Server
There are no test connection for Proxy server. Usually you can use DMI Schemas to test your Internet connection through the Proxy server you just configured

6. DMI Schemas
You may find out all kinds of support device families and OS version. But the specific one in your environment may be not in this list.
DMI Schemas
You will need to download it from DMI Schemas window. Click the green button icon "Update Schema" beside Actions button. In Update Schema window, Choose SVN Repository, then click Configure button to enter SVN Url (https://xml.juniper.net/dmi/repository/trunk/) and your Juniper Support account as shown from next screenshot.
SVN Access configuration
After all SVN configuration saved, you can choose your Device Family to work on, for example in my case it is JunOS-ES, click Connect button. You will see all Schema available for you to download in Schema Availability. It will take a while to get a full list.

7. Create Domain
If you are managing multiple sites devices, you can create domain for each site and assign corresponding administrator to manage those sites. Next screenshot shows a new domain test1 created under the global domain.
Domain


8. Logging (Log Collector)

By default, the loggine, event, alarm and reporting function will not be enabled until you added your Log Collector node into JunOS Space.

8.1 Download Log Collector Image

Download Log Collector OVA Image for VM on ESX Deployment from Junos Space Security Director -Download Software site. Current version is 14.1R2. Size is about 1.3G.

8.2 Importing into ESX server.

Log Collector VM Settings

8.3. Configure Log Collector.

Change Root Password and Select Deployment option
Default Log collector username and password is root / juniper123. It is still same as old version. After you changed default root password, you can chose one of deployment options. In this case, I choosed All in One Mode. 

All in One mode



In old version, there were only 5 options for you to do configuration

1) Configure IP Address 
2) Configure Time Zone 
3) Configure Name Server Settings 
4) Configure NTP Settings 
5) Quit 



IP Address Configuration
Configure the ip address accordingly on eth0.

8.4 Add Log Collector Node into Junos Space Fabric

Add a specialized node into JunOS Space Fabric: 
add log collerctor node


After a couple of minutes, new log collector should show in the node list. 



 8.5 Enable Logging on SRX Devices

Go to Security Director -> Devices -> Device Management , right click your device, choose Device Configuration -> Modify Configuration -> Security Logging
Security Logging for SRX Device

After finished configuration, select Deploy button at the bottom of window to push following configuration to Juniper SRX firewall.

security {
    log {
        mode stream;
        format sd-syslog;
        source-address 10.9.20.26;
        stream LogCollector {
            host {
                10.9.20.17;
            }
        }
    }
After deployed this secure logging configuration to devices, your log collector should be able to get logs from your Juniper Devices.

9. Space Database Backup and Restore



Reference:





Juniper JunOS Space Upgrade Procedures from 14.1 to 16.1

Usually you can easily upgrade an application from the Junos Space user interface. You must download the image file for the new version of the application, navigate to the Applications page (Network Management Platform > Administration > Applications) and select the application that you want to upgrade. From the right-click menu, choose Upgrade Application to upload the image file into Junos Space via HTTP or SCP.

But upgrade JunOS Space to latest version 16.1 is different and it is not a easy task. There are many steps to follow especially the last step to upgrade to 16.1 from 15.2R2. Here is my recent upgrade procedures.

Steps to upgrade JunOS Space 14.1  to the latest version 16.1:



1. From 14.1, first upgrade to 15.1



    Start Upgrading process from application page:




    You will be redirect to a new page to enter maintenance user name and password to start upgrade process. Username is maintenance. Password is the one you set up before or you can use this link https://kb.juniper.net/InfoCenter/index?page=content&id=KB16853 to reset it. 





    After waited 10 minutes, for somehow, the web gui lost connection. I have to manually restart httpd service to get back into maintenance window.





    Click the option Reboot JunOS Space:


    After reboot and waited 20 minutes, if Space is still in maintenance mode, you can run following commands to get system back into normal operation mode.


    Space release 15.1R4.1 (379522)

    Last login: Sat Mar 11 09:04:58 2017 from 10.94.200.14

    Welcome to the Junos Space network settings utility.

    Initializing, please wait


    Junos Space Settings Menu

    1> Change Password
    2> Change Network Settings
    3> Change Time Options
    4> Retrieve Logs
    5> Security
    6> Expand VM Drive Size
    7> (Debug) run shell

    A> Apply changes
    Q> Quit
    R> Redraw Menu

    Choice [1-7,AQR]:
    7

    [sudo] password for admin:
    [root@space-005056920010 ~]#
    service httpd restart
    Stopping webProxy: [ OK ]
    Starting webProxy: httpd: Could not reliably determine the server's fully qualified domain name, using 10.94.200.18 for ServerName
    [ OK ]
    [root@space-005056920010 ~]#
    service jmp-watchdog start
    jmp-watchdog running
    [root@space-005056920010 ~]#
    service mysql start
    SUCCESS! MySQL running (3911)
    [root@space-005056920010 ~]#
    service jboss-dc start
    jboss domain controller (pid 13534) is already running
    [root@space-005056920010 ~]# service jboss start
    PING jmp-CLUSTER (10.94.200.19) 56(84) bytes of data.
    64 bytes from jmp-CLUSTER (10.94.200.19): icmp_seq=1 ttl=64 time=0.049 ms
    64 bytes from jmp-CLUSTER (10.94.200.19): icmp_seq=2 ttl=64 time=0.043 ms
    64 bytes from jmp-CLUSTER (10.94.200.19): icmp_seq=3 ttl=64 time=0.040 ms

    --- jmp-CLUSTER ping statistics ---
    3 packets transmitted, 3 received, 0% packet loss, time 1999ms
    rtt min/avg/max/mdev = 0.040/0.044/0.049/0.003 ms
    in master node
    domain controller is already running
    host.xml.slave is initialized, skip
    start jboss
    jboss (pid 16674) is running
    start deploy ...
    [root@space-005056920010 ~]#




    2. Upgrade your Network Management Platform (NMP) to the latest release of your current version.
    For instance in my case means going from 15.1R1 to 15.1R4.




    3. Upgrade your other application
    After you have this done you need to upgrade all your Application modules to the latest version compatible for your NMP version (for example upgrade SD to 15.1R2). You didn’t mention having any application, but if you have please don’t skip this step, you can verify this in the NMP under Administration>Applications.

    Here is an example to upgrade Security Director from 14.1 to 15.1 R1.



    You had better to upgrade Security director to the highest release under that version before you go to next version of NMP. In this post, it has been upgrade to 15.1R2 before NMP upgraded to 15.2R1.

    4. Upgrade NMP to next Version's first release
    in my case it is 15.2R1

    It is same steps as you upgrade from 14.1 to 15.1. It will take quite a while after rebooted to get system back into normal. You may have to those shell commands to start some services in step 1.

    Once 15.1 completed, you will have to upgrade to 15.1R2 version by uploading image file '15.2R2.4.img'.  Then you can do your applications such as security director, upgrade from 15.1R2 to 15.2R1 , 15.2R2.


    Here is the new look of Space Security Director 15.2 R1:
    Log In Page




    5. Upgrade NMP from 15.2R2 to 16.1.
      Upgrade NMP from 15.2R2 to 16.1 is a little different from above steps. In Junos Space Network Management Platform Release 16.1R1, CentOS 6.8 is used as the underlying OS. As a direct upgrade of the OS from CentOS 5.9 to CentOS 6.8 is not supported, a direct upgrade to Junos Space Platform Release 16.1R1 by using the Junos Space Platform UI is also not supported. You must follow a multi-step procedure to upgrade to Junos Space Platform Release 16.1R1.

      Here is a link to show all steps. 


      Please pay special attention to the steps to upgrade to the latest version 16.1, there are different that other previous versions.

      Also, if you use a log collector. Versions 15.1, 15.2 and 16.1 of the log collector are not compatible and this will require to erase the old log collector and deploy the newer version instead.

      Finally, you can download the required files for the upgrade in this link:


      to change from one version to the other just use the drop-down menu om the right after selecting the specific application. Please let me know if you have any additional questions or concerns. 




      Troubleshooting
      Not Enough Disk Space
      You may get action failure when you do upgrade because of following error:

      "Upgrade Errors: 10.9.2.8: Has no enough disk space. Needs a minimum of 10G available space in "/" partition.

      Please click OK to stop the upgrade and fix the Upgrade Errors reported."



      [root@space-005056920010 ~]# df -h
      Filesystem Size Used Avail Use% Mounted on
      /dev/mapper/jmpvgnocf-lvroot
      22G 12G 9.0G 56% /
      /dev/mapper/jmpvgnocf-lvtmp
      23G 458M 22G 3% /tmp
      /dev/mapper/jmpvgnocf-lvvar
      51G 8.7G 39G 19% /var
      /dev/mapper/jmpvgnocf-lvlog
      23G 12G 11G 52% /var/log
      /dev/sda1 96M 16M 76M 17% /boot
      tmpfs 3.8G 4.0K 3.8G 1% /dev/shm
      [root@space-005056920010 ~]#
      [root@space-005056920010 /]# du -h | egrep "^[0-9.]+G"
      3.3G ./var/log/jboss/servers/server1
      3.3G ./var/log/jboss/servers
      3.3G ./var/log/jboss
      5.1G ./var/log
      1.2G ./var/cache/jboss/jmp/15.2R2.4
      1.2G ./var/cache/jboss/jmp/payloads/15.2R2.4
      1.2G ./var/cache/jboss/jmp/payloads
      2.4G ./var/cache/jboss/jmp
      5.1G ./var/cache/jboss
      5.2G ./var/cache
      1.1G ./var/chroot/mysql/var/lib/mysql/build_db
      3.0G ./var/chroot/mysql/var/lib/mysql
      3.0G ./var/chroot/mysql/var/lib
      3.0G ./var/chroot/mysql/var
      3.3G ./var/chroot/mysql
      3.3G ./var/chroot
      14G ./var
      du: cannot read directory `./proc/18639': No such file or directory
      du: cannot read directory `./proc/18641': No such file or directory
      du: cannot read directory `./proc/18642': No such file or directory
      du: cannot read directory `./proc/18743': No such file or directory
      du: cannot read directory `./proc/18954': No such file or directory
      du: cannot read directory `./proc/18956': No such file or directory
      du: cannot read directory `./proc/18990': No such file or directory
      du: cannot read directory `./proc/18991': No such file or directory
      du: cannot read directory `./proc/18992': No such file or directory
      du: cannot read directory `./proc/19007': No such file or directory
      du: cannot read directory `./proc/19008': No such file or directory
      du: cannot read directory `./proc/19009': No such file or directory
      du: cannot read directory `./proc/19010': No such file or directory
      du: cannot access `./proc/22119/task/8853/fd/795': No such file or directory
      1.3G ./usr/local/jboss/standalone/data/solr/index
      2.1G ./usr/local/jboss/standalone/data/solr
      2.1G ./usr/local/jboss/standalone/data
      2.4G ./usr/local/jboss/standalone
      1.1G ./usr/local/jboss/domain/tmp/servers/server1/vfs
      1.9G ./usr/local/jboss/domain/tmp/servers/server1
      1.9G ./usr/local/jboss/domain/tmp/servers
      1.9G ./usr/local/jboss/domain/tmp
      1.2G ./usr/local/jboss/domain/data/servers/server1/content
      1.3G ./usr/local/jboss/domain/data/servers/server1
      1.3G ./usr/local/jboss/domain/data/servers/server2/content
      1.3G ./usr/local/jboss/domain/data/servers/server2
      2.5G ./usr/local/jboss/domain/data/servers
      2.5G ./usr/local/jboss/domain/data
      4.4G ./usr/local/jboss/domain
      1.2G ./usr/local/jboss/jmp-tmp/net/juniper/jmp/var/schemas/dmi-space/dmi
      1.2G ./usr/local/jboss/jmp-tmp/net/juniper/jmp/var/schemas/dmi-space
      1.3G ./usr/local/jboss/jmp-tmp/net/juniper/jmp/var/schemas
      1.3G ./usr/local/jboss/jmp-tmp/net/juniper/jmp/var
      1.3G ./usr/local/jboss/jmp-tmp/net/juniper/jmp
      1.3G ./usr/local/jboss/jmp-tmp/net/juniper
      1.3G ./usr/local/jboss/jmp-tmp/net
      1.3G ./usr/local/jboss/jmp-tmp
      8.3G ./usr/local/jboss
      8.5G ./usr/local
      9.8G ./usr
      24G .
      [root@space-005056920010 /]#
      find / -type f -size +100000 -exec ls -lha {} \;
      -rw-r----- 1 root root 518M Mar 14 05:03 /root/dead.letter
      -rw------- 1 root root 64M Mar 14 17:59 /sys/devices/pci0000:00/0000:00:0f.0/resource1
      -rw------- 1 root root 103M Nov 6 04:02 /var/log/SystemStatusLog.19
      -rw------- 1 root root 103M Jun 12 2016 /var/log/SystemStatusLog.40
      -rw------- 1 root root 103M Feb 5 04:02 /var/log/SystemStatusLog.6
      -rw------- 1 root root 103M Jul 31 2016 /var/log/SystemStatusLog.33
      -rw------- 1 root root 103M May 1 2016 /var/log/SystemStatusLog.46
      -rw------- 1 root root 103M May 22 2016 /var/log/SystemStatusLog.43
      -rw------- 1 root root 103M Mar 27 2016 /var/log/SystemStatusLog.51
      -rw------- 1 root root 101M Oct 26 04:02 /var/log/kern.log.2
      -rw------- 1 root root 103M Sep 4 2016 /var/log/SystemStatusLog.28
      -rw------- 1 root root 103M Oct 16 04:02 /var/log/SystemStatusLog.22
      -rw------- 1 root root 103M Feb 26 04:02 /var/log/SystemStatusLog.3
      -rw------- 1 root root 103M Nov 20 04:02 /var/log/SystemStatusLog.17
      -rw------- 1 root root 101M Apr 23 2016 /var/log/kern.log.4
      -rw------- 1 root root 103M Jul 17 2016 /var/log/SystemStatusLog.35
      -rw------- 1 root root 103M Mar 12 04:02 /var/log/SystemStatusLog.1
      -rw------- 1 root root 103M Apr 10 2016 /var/log/SystemStatusLog.49
      -rw------- 1 root root 103M Feb 19 04:02 /var/log/SystemStatusLog.4
      -rw------- 1 root root 103M Aug 21 2016 /var/log/SystemStatusLog.30
      -rw------- 1 root root 103M Oct 23 04:02 /var/log/SystemStatusLog.21
      -rw------- 1 root root 103M Sep 18 04:02 /var/log/SystemStatusLog.26
      -rw------- 1 root root 103M Oct 9 04:02 /var/log/SystemStatusLog.23
      -rw------- 1 root root 103M Jan 1 04:02 /var/log/SystemStatusLog.11
      -rw------- 1 root root 103M Sep 11 2016 /var/log/SystemStatusLog.27
      -rw------- 1 root root 103M Feb 12 04:02 /var/log/SystemStatusLog
      .....