root@jsrx# edit security nat destination
This way we got into the destination NAT configuration section. First you need to create an address entry (pool) of our web server.root@jsrx# set pool web-server address 10.1.1.100 port 80
Next, create a rule-set, i.e. Code of Destination Nata:root@jsrx# set rule-set DNAT from zone untrust
Thereby we say that this set of rules works for packages that come from the untrust zone, i.e. in our case from the Internet. In this example, everything is fine, but sometimes it may be necessary to specify which particular interface the packets for this set of rules should come from. In this case, the phrase from zone untrust
should be replaced with from interface ge-0/0/0
(as in our example). You can also specify the source of the routing-instance
packet packets, but this is a more rare case, we will not think about it.In the first line, we indicate our external IP-address to which clients will knock. In the second line, we specify the external port, and in the third - the actual pool itself, which we described at the beginning.root@jsrx# set rule-set DNAT rule dnat_for_web match destination-address 1.2.3.4
root@jsrx# set rule-set DNAT rule dnat_for_web match destination-port 80
root@jsrx# set rule-set DNAT rule dnat_for_web then destination-nat pool web-server
Doroot@jsrx# top edit security address-book global
root@jsrx# set address web_server 10.1.1.100
root@jsrx# top edit security policies from-zone untrust to-zone trust
root@jsrx# set policy web_access match source-address any
root@jsrx# set policy web_access match destination-address web_server
root@jsrx# set policy web_access match application any
root@jsrx# set policy web_access then permit
root@jsrx# commit check
then if everything went okroot@jsrx# commit
This completes the destination NAT'a, everything is quite simple. The final config is shown below:root @ jsrx # show security nat destination pool web-server { address 10.1.1.100/32 port 80; } rule-set DNAT { from zone untrust; rule dnat_for_web { match { destination-address 1.2.3.4/32; destination-port 80; } then { destination-nat pool web-server; } } } root @ jsrx # show security address-book global address web_server 10.1.1.100/32; root @ jsrx # show security policies from-zone to-zone trust policy web_access { match { source-address any; destination-address web_server; application any; } then { permit; } }
root@jsrx> show security nat destination rule _
The Translation hits line will show the number of times the triggering has been activated. Very handy diagnostic tool Nata. Such a moment: destination NAT'a rules are processed BEFORE checking for compliance with policies. Therefore, if you see by the meter that forwarding is triggered, but there is no access, it is worth checking the policies. Most likely, you just forgot to add something there.match application any
in the policy config, then you are right. In an amicable way, for security reasons, it is necessary to enter the name of a specific application (that is, the port) that will be used by external clients. You can write match application junos-http
for the web server. I will write more about applications in Junos OS later.Source: https://habr.com/ru/post/166637/
All Articles