This article contains information on configuring a tunnel policy for the local site of a site-to-site policy-based VPN on a J Series or SRX Series device.
Refer to example network diagram below:
Site A: 192.168.10.1 is the IP assigned to interface ge-0/0/0.0, and the interface is a member of zone "trust" facing 192.168.10.0/24 subnet. 172.16.10.1 is the IP assigned to interface ge-0/0/3.0 and interface is a member of zone "untrust" facing the Internet.. Site B: 192.168.20.1 is the IP assigned to interface ge-0/0/0.0, and the interface is a member of zone "trust" facing 192.168.20.0/24 subnet. 172.16.20.1 is the IP assigned to interface ge-0/0/3.0 and interface is a member of zone "untrust" facing the Internet. Assume that on Site A, hosts on "siteA" 192.168.10.0/24 need to be able to reach any host on Site B,"siteB" 192.168.20.0/24 network across the VPN. Also assume that the VPN needs to be bi-directional which means that Site A also needs to be able to reach hosts on Site B. Also, assume that IKE phase 1 and phase 2 are already configured with ipsec-vpn name of "remote-vpn". Both sides of the diagram can be configured similarly, so for the purposes of this article, only the Left side configuration will be shown.
J-Web : Go to Configure> Security >Policy Elements >Address Book To add an address book entry for each zone, click on Add Click on the zone for which you would like to add an address book entry (example: zone trust ). If address book entry required does not exist, then click Add... In the Address Name field specify a name (example: " siteA" ). Note, the name must be a string beginning with a letter and consisting of letters, numbers, dashes and/or underscores. 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. Click OK . Repeat steps 3-7 for zone untrust Address Book entry " siteB ". Click OK again to return to the Security Policies screen. CLI : root@SiteA> set security zones security-zone trust address-book address siteA 192.168.10.0/24 root@SiteA> set security zones security-zone untrust address-book address siteB 192.168.20.0/24
root@SiteA> set security zones security-zone trust address-book address siteA 192.168.10.0/24 root@SiteA> set security zones security-zone untrust address-book address siteB 192.168.20.0/24
J-Web: From Configure > Security > Policy Elements screen, click on Applications . Select Custom-Applications tab. Click Add... Specify Application Name (example: tcp1500 ), then click ' + ' (plus box) for Configure top level options . Click on Match IP protocol pull down and choose tcp . Enter 1500 in the freeform field for Destination port (not the pull down field). Note, since the application can use any source port then it is not necessary to also specify source port for the application. Click OK . Then click OK again to return to the Security Policies screen. CLI: root@SiteA> set applications application tcp1500 protocol tcp root@SiteA> set applications application tcp1500 destination-port 1500 Note that if allowing all applications to traverse the VPN then no custom application is needed since pre-defined application "any" already exists. So, for this example the above step is not necessary.
root@SiteA> set applications application tcp1500 protocol tcp root@SiteA> set applications application tcp1500 destination-port 1500
J-Web: From Configure >Security > Policy screen, click Apply Policy In Zone Direction , select From Zone trust and To Zone untrust. Click Add a Policy . Specify Policy Name (example: "vpnpolicy-tr-unt" ), then click ' + ' (plus box) for Match Criterias . Select Source Address Book "siteA" object on the right side and click (left arrow) to add to the Matched list. Select Destination Address Book "siteB" object and click (left arrow) to add to the Matched list. Select Application " any" and click (left arrow) to add to the Matched list. For Policy Action , select Permit from the pull down. Note, this will show more options. For IPSec-VPN Tunnel select configured IPSec profile "remote-vpn" from the pull down. Do NOT specify Pair Policy at this time as this will need to be done when other direction policy is created. Click OK to commit changes. Repeat steps 2-9 above for the from-zone "untrust" to-zone "trust" tunnel policy (Source and Destination addresses will be the reverse). Specify the Pair Policy with the name of your local to remote policy "vpnpolicy-tr-unt" . Click OK to commit changes. Then click OK again to return to main policy configuration screen. CLI: root@SiteA> set security policies from-zone trust to-zone untrust policy vpnpolicy-tr-unt match source-address siteA root@SiteA> set security policies from-zone trust to-zone untrust policy vpnpolicy-tr-unt match destination-address siteB root@SiteA> set security policies from-zone trust to-zone untrust policy vpnpolicy-tr-unt match application any root@SiteA> set security policies from-zone trust to-zone untrust policy vpnpolicy-tr-unt then permit tunnel ipsec-vpn remote-vpn root@SiteA> set security policies from-zone trust to-zone untrust policy vpnpolicy-tr-unt then permit tunnel pair-policy vpnpolicy-unt-tr root@SiteA> set security policies from-zone untrust to-zone trust policy vpnpolicy-unt-tr match source-address siteB root@SiteA> set security policies from-zone untrust to-zone trust policy vpnpolicy-unt-tr match destination-address siteA root@SiteA> set security policies from-zone untrust to-zone trust policy vpnpolicy-unt-tr match application any root@SiteA> set security policies from-zone untrust to-zone trust policy vpnpolicy-unt-tr then permit tunnel ipsec-vpn remote-vpn root@SiteA> set security policies from-zone untrust to-zone trust policy vpnpolicy-unt-tr then permit tunnel pair-policy vpnpolicy-tr-unt
root@SiteA> set security policies from-zone trust to-zone untrust policy vpnpolicy-tr-unt match source-address siteA root@SiteA> set security policies from-zone trust to-zone untrust policy vpnpolicy-tr-unt match destination-address siteB root@SiteA> set security policies from-zone trust to-zone untrust policy vpnpolicy-tr-unt match application any root@SiteA> set security policies from-zone trust to-zone untrust policy vpnpolicy-tr-unt then permit tunnel ipsec-vpn remote-vpn root@SiteA> set security policies from-zone trust to-zone untrust policy vpnpolicy-tr-unt then permit tunnel pair-policy vpnpolicy-unt-tr root@SiteA> set security policies from-zone untrust to-zone trust policy vpnpolicy-unt-tr match source-address siteB root@SiteA> set security policies from-zone untrust to-zone trust policy vpnpolicy-unt-tr match destination-address siteA root@SiteA> set security policies from-zone untrust to-zone trust policy vpnpolicy-unt-tr match application any root@SiteA> set security policies from-zone untrust to-zone trust policy vpnpolicy-unt-tr then permit tunnel ipsec-vpn remote-vpn root@SiteA> set security policies from-zone untrust to-zone trust policy vpnpolicy-unt-tr then permit tunnel pair-policy vpnpolicy-tr-unt
The ordering of policies is important. Junos on a J Series or SRX Series device will perform a policy lookup from top to bottom until a match is found. At that point no further policy lookup occurs. Therefore if a permit all policy exists then be sure that the tunnel policy is above the permit all policy. If not then the tunnel policy will never be reached. To re-arrange policy order, use the Move up or down option in the Security Policies screen in JWeb or the Insert command in CLI. For more information on policy ordering, refer to KB10120-How to change the order of policies on a J Series or SRX Series device [juniper.net]
The ordering of policies is important. JUNOS-ES will perform policy lookup from top to bottom until a match is found. At that point no further policy lookup occurs. Therefore if a permit all policy exists then be sure that the tunnel policy is above the permit all policy. If not then the tunnel policy will never be reached. To re-arrange policy order, use the Move up or down option in the Security Policies screen in JWeb or the Insert command in CLI.