Thursday, 11 December 2014

How to create and use a custom application on SRX

There are three basic steps to creating a custom application and applying it to a security policy:
  1. Create address book entries for the source and destination addresses.
  2. Create the custom application if no pre-defined applications encompass the protocol or ports needed.
  3. Create a security policy to permit the traffic using the custom application. 
For this example we will configure a policy to permit a custom application using TCP port 1500 from "local-net" 192.168.10.0/24 to "remote-net" 192.168.20.0/24.

1. Create the address book entries for the source and destination addresses

From J-Web:
  1. Go to Configuration >Security > Policy Elements.

  2. To add an address book entry for each zone, click on Address Books.

  3. Click on the zone for which you would like to add an address book entry (example: zone trust).

  4. If address book entry required does not exist, then click Add....

  5. In the Address Name field specify a name (example: local- net).

    Note: The name must be a string beginning with a letter and consisting of letters, numbers, dashes and underscores.

  6. In IP Address/Prefix, enter the IP address/subnet mask (example: 192.168.10.0/24). or
    in DNS Name, specify a fully qualified domain name. 

    Note:
    The J Series or SRX Series device must have a working DNS server configured to resolve the domain name.

  7. Click OK.

  8. Repeat steps 3-7 for zone untrust, Address Book entry remote-net. Click OK again to return to the Security Policies screen.
From CLI:
    set security zones security-zone trust address-book address local-net 192.168.10.0/24
    set security zones security-zone untrust address-book address remote-net 192.168.20.0/24

2. Create a custom application

From J-Web:
  1. From Configuration > Security > Policy Elements screen, click on Applications.

  2. Select Custom-Applications tab.

  3. Click Add...

  4. Specify Application Name (example: tcp1500), then click (plus box) for Configure top level options.

  5. Click on Match IP protocol, pull down, and choose tcp.

  6. Enter 1500 in the free-form field for Destination port (not the pull-down field). Click OK. 

    Note:
    Since the application can use any source port, it is not necessary to also specify a source port for the application.

  7. Click OK again to return to the Security Policies screen.

From CLI:
    set applications application tcp1500 protocol tcp
    set applications application tcp1500 destination-port 1500
Note: If allowing all applications to traverse the Policy, then no custom application is needed since the pre-defined application “any” already exists, which allows all ports.

3. Create a security policy to permit the traffic, using the custom application

From J-Web:
  1. From Configuration > Security > Policy screen, click Apply Policy.

  2. In Zone Direction, select From Zone trust and To Zone untrust.

  3. Click Add a Policy.

  4. Specify Policy Name (example: policy-tr-unt), then click (plus box) for Match Criteria.

  5. Select Source Address Book local-net object on the right side and click (left arrow) to add to the Matched list.

  6. Select Destination Address Book remote-net object and click (left arrow) to add to the Matched list.

  7. Select Application tcp1500 and click (left arrow) to add to the Matched list. 

  8. For Policy Action, select Permit from the pull-down menu.

  9. Click OK to commit changes.  Then click OK again to return to main policy configuration screen.
From CLI:
    set security policies from-zone trust to-zone untrust policy policy-tr-unt match source-address local-net
    set security policies from-zone trust to-zone untrust policy policy-tr-unt match destination-address remote-net
    set security policies from-zone trust to-zone untrust policy policy-tr-unt match application tcp1500
    set security policies from-zone trust to-zone untrust policy policy-tr-unt then permit
note: The ordering of policies is important.  J Series or SRX Series devices will perform policy lookup from top to bottom until a match is found.  At that point no further policy lookup occurs.  Therefore if a deny all policy exists, then be sure that the policy created is above the deny all policy.  If not, then the policy will never be reached.  To re-arrange policy order, use the Move up or down option in the Security Policies screen in J-Web or the insert command in CLI. 

Examples:

Here are two custom applications created for TCP ports 5000 and 5001:

applications {
    application tcp_port_5000 {
        protocol tcp;
        destination-port 5000;
    }
    application tcp_port_5001 {
        protocol tcp;
        destination-port 5001;
    }
}


A security policy to and from the desired security zones is created. Below, we can see the custom application used:

[security policies]
from-zone inside to-zone outside {
    policy telnet_100 {
        match {
            source-address any;
            destination-address host_public;
            application tcp_port_5000;
        }
        then {
            permit
        }
    }
    policy telnet_101 {
        match {
            source-address any;
            destination-address host_public;
            application tcp_port_5001;
        }
        then {
            permit
        }
    }
}

Sunday, 7 December 2014

Junos Software Installation/Upgrade

Software Installation Preparation


Read the Release Notes, as they document new features, changes in default behavior, known limitations, and issues.

Set up your connection to the SRX to log your session during the installation and through the reboot, as the transcript can provide valuable information if an issue happens and JTAC needs to review it.

Confirm there are no uncommitted changes present because candidate changes are usually lost on a reboot.  Enter the command: 
                           user@srx# top 
              user@srx# show | compare

If the command contains configuration information that you want to keep, then perform a commit.
Backup your configuration, by logging your session while performing the following command.  Keep it in a safe place.     

user@srx> show configuration | no-more
If you want to backup the current Junos and configuration onto media (such as a USB/CF) so that it can be put back into the SRX if the SRX does not boot up and allow the SRX to boot up







request system snapshot media usb                                                 

If you are going to do a J-Web installation or copy the Junos software image to the SRX, then check the flash size and purge unused files:

Check current Flash size:
show system storage | match cf

Purge logfiles:
request system storage cleanup      
If Flashsize is still lower than the size of your image, then try the following:

  • Clear files from the /var/log directory.  Clear or remove any traceoptions files and clear any log files which are not needed.  Note that you will loose all contents of the log file after a clear is done.
    clear log <log-filename>
  • Purge software backup.  Note that if you delete the backup software, you will not be able to rollback using the "request system software rollback" command.
    request system software delete-backup
  • Locate directories on the flash with large amount of data
    show system directory-usage /cf          
  • To save space browse directories and erase files manually:  Be careful with which file you choose to delete.
    file list /var/tmp
    file delete /var/tmp/xyz

    Install Software via CLI

    Follow these steps to copy the software to the SRX device and then perform the software installation via the CLI:
  • Copy software to SRX via SCP or FTP to /var/tmp: 
    For example:
    user@srx>  scp  junos-srxsme-11.4R4.4-domestic.tgz  user@srx:/var/tmp/junos-srxsme-11.4R4.4-domestic.tgz

    OR

    user@srx>  ftp <ip address of local ftp server>  (and login)
    user@srx>  lcd /var/tmp
    user@srx>  bin
    user@srx>  get junos-srxsme-11.4R4.4-domestic.tgz
    user@srx>  bye
  • Install software with the commands below. 
    For example:
    From the local file in /var/tmp
    user@srx>  request system software add no-copy /var/tmp/junos-srxsme-11.4R4.4-domestic.tgz
    user@srx>  request system reboot

    Install Software via CLI

    Follow these steps to install the software via the CLI from a USB stick:
  • Download the Junos upgrade file to the USB stick. 
  • Locate the USB device ID that Junos is associating to the USB stick:
    user@srx> start shell
    user@srx% ls /dev/

  • Insert the USB device into the USB slot.  For example, slot 0 would return the following:
    root# umass0: USB USBFlashDrive, rev 2.00/1.00, addr 2
    da0 at umass-sim0 bus 0 target 0 lun 0
    da0: <USB USBFlashDrive 0100> Removable Direct Access SCSI-0 device
    da0: 1.000MB/s transfers
    da0: 980MB (2007040 512 byte sectors: 64H 32S/T 980C)

    Run the following command

    user@srx% ls /dev/

    Locate difference in outputs to locate drive label. (It will usually be da#s1, i.e. da0s1)
  • Create a mount directory:
    user@srx% mkdir /tmp/usb
  • Mount the USB to the directory:
    user@srx% mount -t msdosfs /dev/<drivelabel, e.g. #da0s1> /tmp/usb

    Example:
    user@srx% mount -t msdosfs /dev/da0s1 /tmp/usb (there is a space between the label name and /tmp)

    Verify that the USB is mounted to the device:
    root@% pwd
    /cf/root
    root@% cd /var/tmp/usb/
    root@% pwd
    /cf/var/tmp/usb
    root@% ls
    junos-jsr-11.4R5.7-export.tgz
  • Exit shell and install the software:
    user@srx% exit
    user@srx> request system software add /tmp/usb/<upgrade filename> no-validate no-copy
  • Upon completion, reboot the SRX:
    user@srx> request system reboot



Tuesday, 2 December 2014

VPN Monitoring -

When you enable VPN monitoring for a specific tunnel, the security device sends ICMP echo requests (or “pings”) through the tunnel at specified intervals (configured in seconds) to monitor network connectivity through the tunnel.
When Optimized is selected, the VPN monitoring behavior changes as follows:
  • The J Series or SRX Series device accepts incoming traffic through the VPN tunnel as a substitute for ICMP echo replies.
  • If there is both incoming and outgoing traffic through the VPN tunnel, the J Series or SRX Series device suppresses VPN monitoring pings.
 If you enable VPN monitoring optimization, be aware that VPN monitoring can no longer provide accurate SNMP statistics.
 Configure via CLI:

set security ipsec vpn <vpn-name> vpn-monitor optimized

Saturday, 22 November 2014

Restart a Junos OS Process

Action
To restart a Junos OS process, use the following Junos OS CLI operational mode command and include the process you wish to restart. For example:
user@host> restart routing

Sample Output
user@host> restart routing Routing protocol daemon started, pid 751 

Meaning
The sample output shows that the routing protocol daemon was restarted and the process identification (PID) was changed from 685 in the previous sample output to 751. 


Options to Restart a Junos OS Process
Option
Description
class-of-service
Restart the class-of-service process, which controls the router’s class-of-service configuration.
gracefully
Restart the software process by sending the equivalent of a UNIX SIGTERM signal.
immediately
Immediately restart the process by sending the equivalent of a UNIX SIGKILL signal.
interface-control
Restart the interface process, which controls the router’s physical interface devices and logical interfaces.
mib-process
Restart the Management Information Base (MIB) II process, which provides the router’s MIB II agent.
network-access-service
Restart the network access process, which provides the router’s Challenge Handshake Authentication Process (CHAP) authentication service.
remote-operations
Restart the remote operations process, which provides the ping and traceroute MIBs.
routing
Restart the routing protocol process, which controls the routing protocols that run on the router and maintains the routing tables.
sampling
Restart the sampling process, which performs packet sampling and cflowd export.
snmp
Restart the Simple Network Management Process (SNMP) process, which provides the router’s SNMP master agent.
soft
Reread and reactivate the configuration without completely restarting the software processes. For example, Border Gateway Protocol (BGP) peers stay up and the routing table stays constant. This option is the equivalent of a UNIX SIGHUP signal; omitting this option is the equivalent of a UNIX SIGTERM (kill) operation.

Monday, 10 November 2014

SRX Getting Started - Install license for Antivirus, Web Filter, IDP, or Antispam

Following steps involved in installing a license for Antivirus, Web Filter (URL Filter), IDP or Antispam on a SRX device.


Problem or Goal:
Install subscription license

Cause:

Solution:
The following features require a subscription license:
  • Antivirus
  • Web Filter
  • IDP
  • Antispam
The high memory system option is also required to use these features. UTM is not supported on the low memory version.  For ordering information, refer to the SRX datasheet.  

The instructions for installing the subscription licence via the CLI are documented below.  For J-Web instructions, refer to the Technical Documentation link below.

Install Subscription License

Perform the following steps to activate, install, and verify the subscription license:
  1. First, activate your subscription license by entering the authorization code and chassis serial number into the Subscription Registration system. Refer to KB9731 - How do I activate a subscription license for my ScreenOS firewall or SRX Series product for more information. If you still need help, please contact Customer Care for subscription and licensing issues.


  2. Then, install the license on the SRX in one of two ways -- automatically or manually:
    a. Automatically: 
    Confirm the SRX device has connectivity to the Internet and DNS configured.  Then run the following command to request the license from the License Management Server and install it:

     root> request system license update          

    (The output of the command show configuration system license displays the default URL for the License Management Server.)

    OR
    b. Manually:
    Licenses can also be loaded manually via JWeb, NSM, or using the CLI. The CLI command is as follows:

    root> request system license add terminal
    [Type ^D at a new line to end input,
    enter blank line between each license key]
    Paste the license key and press enter
    Type Ctrl+D

    The License key should be added successfully.


  3. Verify the license is installed using the command:
  4. root> show system license 
    License usage: 
                                     Licenses     Licenses    Licenses    Expiry
      Feature name                       used    installed      needed 
      av_key_kaspersky_engine               0            1           0    2013-03-06 01:00:00 CET
      anti_spam_key_sbl                     1            0           1    25 days
      wf_key_surfcontrol_cpa                1            0           1    25 days
     
    • SRX Branch platforms support three different Anti-Virus types. For Antivirus-Express engine and Kaspersky engine look for the feature name "av_key_kaspersky_engine".   For Sophos engine, look for the feature name "av_key_sophos_engine".
    • Note: Sophos Antivirus is supported from Junos 11.1 onwards. The Antivirus Express feature is not supported on SRX100 and SRX110 platforms.

    • SRX Branch platform supports three different Web-Filter (URL Filtering) types. For Integrated Web Filtering look for the feature name "wf_key_surfcontrol_cpa". For Enhanced Web Filtering, look for the feature name "wf_key_websense_ewf ". The Redirect Web filtering feature does not need a license on the SRX.

    • For IDP, look for feature 'idp-sig'. 

    • For Antispam, look for feature "anti_spam_key_sbl"

NOTE: If running a Chassis Cluster, then the license needs to be installed on both nodes.

Trial licenses are available and valid for 4 weeks; you can only fetch a trial license once per year for each device serial number. Use the command:    request system license update trial

Tuesday, 4 November 2014

JUNOS : Configuring IPS Features on the SRX

Getting Started with IPS on the SRX

We should perform a few steps before we configure SRX IPS. Here is a list of things to do before configuring the SRX for IPS functionality:
  1. Install the license.
    You must install an IDP license before you can download any attack objects. If you are using only custom attack objects, you don’t need to install a license (earlier versions had a bug where they required it), but if you want to download Juniper predefined attack objects, you must have this license. Juniper provides you with the ability to download a 30-day trial license to permit this functionality for a brief period of time to evaluate the functionality. We covered license installation earlier in the book; all you need is the request system license add command either specifying a file, or copying and pasting it into the terminal.
  2. Configure network access.
    Before you can download the attack objects, you must have network connectivity to either the Juniper download server or a local server from which the signatures can be downloaded. This typically requires network configuration ...

    Deploying and Tuning IPS

    Deploying IPS requires a slight learning curve. You could memorize every command and feature by heart, and still have a rocky deployment. The challenge is that every environment is different, just like a fingerprint or DNA. There are different applications, different volumes of the applications, different policies on what is accepted activity, and different resources to protect; all which can make for different goals for the IPS. Although this book can’t tell you exactly what your policy should be, it can certainly help you to build and deploy that policy.

    First Steps to Deploying IPS

    Before you get too caught up in the actual deployment do a bit of legwork and map out the policy which you want to deploy. Think of it as brainstorming for your IPS. You should identify the assets you want to protect, and identify the systems and applications and how they interact with others in your network. You may need to contact the application owners beforehand to identify this information. You should also determine your IPD protection goals. This would include the types of threats you want to prevent, and any other factors that might limit the scope of the deployment. (Often this involves management approval so that there aren’t any surprises.)

    Building the Policy

    Once you have identified the assets and the goals of the IPS, and you have gotten all of the necessary approvals, you should be ready to build your IPS policy on the SRX. Remember that if you are using predefined

Friday, 31 October 2014

Need to make a new user's home directory manually on all SRX platforms (including Firefly Perimeter) running with Junos OS release 12.1X47-D10

Alert Type:

PSN - Product Support Notification
 
Product Affected:

All SRX platforms and Firefly Perimeter
 
Alert Description:

Due to an internal build error, if a new user is configured on any of SRX devices (including Firefly Perimeter), which is running with Junos OS 12.1X47-D10. The user's home directory will not be created automatically.



e.g.,

[edit]
root@SRX# set system login user newuser class operator authentication plain-text-password 
New password:
Retype new password:

[edit]
root@SRX# commit and-quit 
commit complete
Exiting configuration mode

root@SRX> file list detail /var/home/ | match newuser    

root@SRX>


If you try to login to the SRX device using the new login username, you can login to the device, but it shows error messages, which cannot change to home directory.
% ssh newuser@172.22.145.106
Password:
--- JUNOS 12.1X47-D10.4 built 2014-08-14 22:48:52 UTC
Could not chdir to home directory /var/home/newuser: No such file or directory
newuser@SRX> 

Solution:
The correction is included in Junos OS 12.1X47-D11 (refer to the download links below), 12.1X47-D15 (scheduled to be released in early December 2014) and above.



Workaround:
  1. After creating a new user on the CLI or J-Web, type "start shell" or "start shell user root" in Junos CLI without double quotes
  2. Create the user's home directory and change the ownership

% mkdir -p /var/home/(username)

% chown -R -P -f (userid or username):20 /var/home/(username)
e.g.,

root@SRX> start shell 
root@SRX% mkdir -p /var/home/newuser
root@SRX% chown -R -P -f newuser:20 /var/home/newuser
root@SRX% ls -al /var/home/newuser
total 8
drwxr-xr-x   2 newuser  20      512 Oct  8 21:47 .
drwxr-xr-x  34 root     wheel  1024 Oct  8 21:47 ..


OR

root@SRX% chown -R -P -f 2009:20 /var/home/newuser
root@SRX% ls -al /var/home/newuser
total 8
drwxr-xr-x   2 newuser  20      512 Oct  8 21:47 .
drwxr-xr-x  34 root     wheel  1024 Oct  8 21:47 ..


NOTE: The userid's of each login name can be verified from the configuration.
e.g.,

[edit]
root@SRX# show system login user newuser 
uid 2009;   <-- LOOK HERE (uid stands for userid)
class operator;
authentication {
    encrypted-password "$1$FyKeeKqo$XKT8V1udIJbT9f4fpw2Yc."; ## SECRET-DATA
}

loading...