Junos OS Security Objects · Topic 4 of 4

Applications and Application Layer Gateways

Learn SRX predefined and custom applications, application sets, inactivity timeouts, and how ALGs open pinholes and fix NAT for FTP and SIP.

  • 6 min
In a nutshell
  • Every security policy must match an application, an application set or any.
  • Predefined applications start with junos- and live in the junos-defaults group.
  • Custom applications use protocol, destination-port, optional inactivity-timeout and optional application-protocol.

What it is

An application on an SRX is a named definition of traffic by protocol and port, such as TCP destination port 443. Every security policy must match at least one application, either a predefined one, a custom one, an application set or any.

An Application Layer Gateway (ALG) is a helper for protocols that do not fit a simple port match. FTP, SIP and similar protocols negotiate extra connections inside the payload, and the ALG reads that negotiation so the SRX can permit the extra connections and translate the addresses inside them.

Policy matchApplicationprotocol and portALG protocolALG readscontrol channelPinhole fordata connection

How it works

Predefined applications

Junos OS ships with many applications whose names start with junos-. They are stored in the hidden junos-defaults configuration group.

ApplicationProtocol and port
junos-httpTCP 80
junos-httpsTCP 443
junos-sshTCP 22
junos-telnetTCP 23
junos-ftpTCP 21, with the FTP ALG
junos-dns-udpUDP 53
junos-pingICMP echo

To see exactly what a predefined application matches, display the defaults group:

user@srx> show configuration groups junos-defaults applications application junos-https

Custom applications

When no predefined entry fits, define your own under [edit applications].

applications {
    application TCP-8080 {
        protocol tcp;
        destination-port 8080;
        inactivity-timeout 3600;
    }
    application-set WEB-APPS {
        application junos-http;
        application junos-https;
        application TCP-8080;
    }
}

The same objects in set form:

user@srx# set applications application TCP-8080 protocol tcp
user@srx# set applications application TCP-8080 destination-port 8080
user@srx# set applications application TCP-8080 inactivity-timeout 3600
user@srx# set applications application-set WEB-APPS application junos-http
user@srx# set applications application-set WEB-APPS application junos-https
user@srx# set applications application-set WEB-APPS application TCP-8080
FieldMeaning
protocolIP protocol: tcp, udp, icmp or a number
destination-portPort or range the server listens on, such as 8080 or 8000-8099
source-portClient port; usually left out, because clients use random ports
inactivity-timeoutIdle seconds before the session closes, or never
application-protocolThe ALG to use, such as ftp

A policy then uses the application or set by name:

user@srx# set security policies from-zone trust to-zone dmz policy WEB match source-address any destination-address WEB-SERVERS application WEB-APPS

How applications match

A policy matches an application on the packet header (protocol and ports), not the payload. A web server on TCP 8080 matches TCP-8080, not junos-http, even though the traffic is HTTP.

Several applications in one policy, or the members of an application set, are combined with OR. The keyword any matches all protocols and ports.

Why some protocols need an ALG

FTP opens a control connection on TCP 21, then agrees on a separate data connection on a dynamic port, and the address and port are written inside the FTP commands. A port-based firewall cannot predict that port, and NAT would leave the private address inside the payload.

Clientcontrol TCP 21ServerALGreads PORT or PASVPinholefor the data portClientdata connectionServermatches pinholePermitted

What an ALG does

JobDetail
Inspect the control channelReads the commands that negotiate addresses and ports
Open pinholesCreates temporary openings so the related data or media connection is permitted without its own policy
Fix NATRewrites the addresses and ports inside the payload when NAT translates the packet header
Close pinholesRemoves the openings when the control session ends or the pinhole times out

The related connections are tied to the parent session, so you only need a policy for the control connection.

Protocols with ALGs

ALGProtocol type
FTP, TFTPFile transfer with separate data connections
SIP, H.323, MGCP, SCCPVoice and video signaling with separate media streams
RTSPStreaming media control
DNSName resolution checks
SUNRPC, MSRPCRemote procedure calls with dynamic ports
PPTPPoint to point tunneling

When an ALG is used

An ALG is applied to a session when the matched application calls for it, such as junos-ftp, or when traffic uses the ALG's well-known port. A custom application on a non-standard port can be tied to an ALG with application-protocol:

user@srx# set applications application FTP-2121 application-protocol ftp
user@srx# set applications application FTP-2121 protocol tcp
user@srx# set applications application FTP-2121 destination-port 2121

ALGs run as a service in the first packet path, after the policy lookup and NAT, and continue on the fast path for every packet of the session.

Managing ALGs

CommandPurpose
show security alg statusLists each ALG and whether it is enabled
set security alg sip disableDisables one ALG, here SIP
show security flow sessionShows the control session and its related sessions

Common mistakes

Writing a policy for the FTP data port. With the FTP ALG, the data connection uses a pinhole tied to the control session; it needs no policy of its own.

Expecting port 8080 to match junos-http. Applications match the port, not the content. HTTP on port 8080 needs a custom application.

Running FTP on a custom port without application-protocol. A custom application on port 2121 does not use the FTP ALG unless application-protocol ftp is set.

Forgetting that application is mandatory. Every policy needs a match application, even if it is any.

Watch out

If you disable an ALG, protocols that depend on it, such as active FTP through NAT, can fail even though the policy permits the control connection.

What to remember for the exam

  • Every security policy must match an application, an application set or any.
  • Predefined applications start with junos- and live in the junos-defaults group.
  • Custom applications use protocol, destination-port, optional inactivity-timeout and optional application-protocol.
  • Application sets group applications; several applications in a policy are combined with OR.
  • Applications match protocol and port only, not payload content.
  • ALGs read control traffic, open pinholes for related connections and fix addresses inside the payload for NAT.
  • show security alg status shows which ALGs are enabled.

Check yourself

  • Active FTP through the SRX works with a policy for junos-ftp only. Why is no policy needed for the data connection?

    The FTP ALG reads the control channel and opens a pinhole for the data connection, which is tied to the control session.

  • A custom application defines TCP 2121 for an FTP server. What must be added for the FTP ALG to work?

    application-protocol ftp on that application, so the SRX applies the FTP ALG to port 2121.

  • How do you see what a predefined application such as junos-https matches?

    Display it from the defaults group, for example show configuration groups junos-defaults applications application junos-https.

Topic 4 of 4 in Junos OS Security Objects

Test yourself on Junos OS Security Objects

The full Juniper JNCIA-SEC JN0-232 question bank has 658 questions, with timed practice exams and an explanation for every answer.

This study guide is independent and is not affiliated with, endorsed by, or sponsored by Juniper. Vendor names, certification names and exam codes are trademarks of their respective owners and are used for identification only.