{"id":59,"date":"2020-06-19T19:09:42","date_gmt":"2020-06-19T17:09:42","guid":{"rendered":"https:\/\/whatifsecu.tech\/?p=59"},"modified":"2020-07-11T00:30:36","modified_gmt":"2020-07-10T22:30:36","slug":"fortigate-pat-without-nat","status":"publish","type":"post","link":"https:\/\/whatifsecu.tech\/?p=59","title":{"rendered":"FortiGate PAT without NAT &#8211; Port redirection"},"content":{"rendered":"\n<p> Port Redirection on VIP with same External and Mapped IP<\/p>\n\n\n\n<table class=\"wp-block-table\"><tbody><tr><td>Products : FortiGate<\/td><\/tr><tr><td> <a href=\"https:\/\/kb.fortinet.com\/kb\/documentLink.do?externalID=FD45204\">https:\/\/kb.fortinet.com\/kb\/documentLink.do?externalID=FD45204<\/a> <\/td><\/tr><\/tbody><\/table>\n\n\n\n<p>This article describes how to apply port redirection for specific application in VIP when External and Mapped IP addresses are the same.Below is the diagram of a client trying to connect to the application server on port 2022 while the server is listening on port 22, the VIP settings have the same IP for both External and Mapped IP.<\/p>\n\n\n\n<p>What I want to highlight is that does not work in FortiOS 6.2 or FortiOS 6.4<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"602\" height=\"361\" src=\"https:\/\/whatifsecu.tech\/wp-content\/uploads\/2020\/06\/image.png\" alt=\"\" class=\"wp-image-60\" srcset=\"https:\/\/whatifsecu.tech\/wp-content\/uploads\/2020\/06\/image.png 602w, https:\/\/whatifsecu.tech\/wp-content\/uploads\/2020\/06\/image-300x180.png 300w\" sizes=\"auto, (max-width: 602px) 100vw, 602px\" \/><\/figure>\n\n\n\n<p>Solution<\/p>\n\n\n\n<p>Create DNAT VIP using CLI and configure the same IP for both External and Internal IP with the required port redirection. Ensure arp-reply setting is disable, else the response will come from the FortiGate interface.<br><\/p>\n\n\n\n<p><strong># edit \u201cSSH_redirect&#8221;<\/strong><br>&nbsp;&nbsp;&nbsp; set extip 10.130.0.52<br>&nbsp;&nbsp;&nbsp; set extintf \u201cany&#8221;<br>&nbsp;&nbsp;&nbsp; set arp-reply disable&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<strong>&lt;- arp-reply must be disable, else it will hit local-in policy<\/strong><br>&nbsp;&nbsp;&nbsp; set portforward enable<br>&nbsp;&nbsp;&nbsp; set mappedip &#8220;10.130.0.52&#8221;<br>&nbsp;&nbsp;&nbsp; set extport 2022<br>&nbsp;&nbsp;&nbsp; set mappedport 22<br>nextNext, create a new firewall policy as below by referencing the VIP object:<br><\/p>\n\n\n\n<p><strong># config firewall policy<\/strong><br>&nbsp;&nbsp;&nbsp; edit 1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; set srcintf &#8220;port1&#8221;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; set dstintf &#8220;port2&#8221;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; set srcaddr &#8220;all&#8221;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; set dstaddr &#8220;SSH_redirect&#8221;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; set action accept&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; set schedule &#8220;always&#8221;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; set service &#8220;ALL&#8221;&nbsp;&nbsp;&nbsp; end<\/p>\n\n\n\n<p>Debug flow output as below indicate the the traffic have been accepted:id=20085 trace_id=1 func=print_pkt_detail line=5347 msg=&#8221;vd-root received a packet(proto=6, 10.129.0.2:50213-&gt;10.130.0.52:2022) from port1. flag [S], seq 1249160343, ack 0, win 8192&#8243;<br>id=20085 trace_id=1 func=init_ip_session_common line=5506 msg=&#8221;allocate a new session-0000d0c9&#8243;<br>id=20085 trace_id=1 func=fw_pre_route_handler line=185 msg=&#8221;VIP-10.130.0.52:22, outdev-unkown&#8221;<br>id=20085 trace_id=1 func=__ip_session_run_tuple line=3268 msg=&#8221;DNAT 10.130.0.52:2022-&gt;10.130.0.52:22&#8243;<br>id=20085 trace_id=1 func=vf_ip_route_input_common line=2574 msg=&#8221;find a route: flag=04000000 gw-10.130.0.52 via port2&#8243;<br>id=20085 trace_id=1 func=fw_forward_handler line=743 msg=&#8221;Allowed by Policy-58:&#8221;<br>id=20085 trace_id=2 func=print_pkt_detail line=5347 msg=&#8221;vd-root received a packet(proto=6, 10.129.0.2:50213-&gt;10.130.0.52:2022) from port1. flag [.], seq 1249160344, ack 3448098817, win 256&#8243;<br>id=20085 trace_id=2 func=resolve_ip_tuple_fast line=5422 msg=&#8221;Find an existing session, id-0000d0c9, original direction&#8221;<br>id=20085 trace_id=2 func=__ip_session_run_tuple line=3268 msg=&#8221;DNAT 10.130.0.52:2022-&gt;10.130.0.52:22&#8243;<br>id=20085 trace_id=3 func=print_pkt_detail line=5347 msg=&#8221;vd-root received a packet(proto=6, 10.129.0.2:50213-&gt;10.130.0.52:2022) from port1. flag [.], seq 1249160344, ack 3448098817, win 256&#8243; <\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>En version 6.0 et sup\u00e9rieur, cette configuration n&#8217;est pas autoris\u00e9e:<br>FortiGate affiche &#8220;Mapped IP must be different from External IP&#8221;<\/p>\n\n\n\n<p><strong>Static\nNAT&#8217;s extip should be different from mappedip.<\/strong><\/p>\n\n\n\n<p><strong>object check operator error, -8, discard the settingCommand fail. Return code 1<\/strong><\/p>\n\n\n\n<p>L&#8217;astuce consiste \u00e0 configurer la VIP en mode load-balance ! Et ouai !<\/p>\n\n\n\n<p>config firewall vip<br> edit &#8220;test&#8221;<br> set type load-balance  &lt;&#8212;&#8212;&#8212;-<br> set extip 192.168.3.2<br> set arp-reply disable &lt;&#8212;&#8211;<br> set extintf &#8220;lan&#8221;<br> set portforward enable<br> set mappedip &#8220;192.168.3.2&#8221;<br> set extport 10443<br> set mappedport 443<br> next<br> end<\/p>\n\n\n\n<p>Pour la petite histoire, j\u2019ai essay\u00e9 en mode normal et en mode Central NAT. J\u2019ai essay\u00e9 avec extip = 0\/0, pas mieux.<\/p>\n\n\n\n<p>Par ailleurs, il y a aussi une commande qui a\ndisparu&nbsp;(alors qu\u2019elle existait en 5.4):<\/p>\n\n\n\n<figure class=\"wp-block-image is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/whatifsecu.tech\/wp-content\/uploads\/2020\/06\/translated-nat-port.png\" alt=\"\" class=\"wp-image-91\" width=\"442\" height=\"244\" srcset=\"https:\/\/whatifsecu.tech\/wp-content\/uploads\/2020\/06\/translated-nat-port.png 991w, https:\/\/whatifsecu.tech\/wp-content\/uploads\/2020\/06\/translated-nat-port-300x166.png 300w, https:\/\/whatifsecu.tech\/wp-content\/uploads\/2020\/06\/translated-nat-port-768x424.png 768w\" sizes=\"auto, (max-width: 442px) 100vw, 442px\" \/><\/figure>\n\n\n\n<p>Pas de r\u00e9ponse du support sur ce point&#8230; mais on a trouv\u00e9 une solution satisfaisante donc&#8230;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Port Redirection on VIP with same External and Mapped IP Products : FortiGate https:\/\/kb.fortinet.com\/kb\/documentLink.do?externalID=FD45204 This article describes how to apply port redirection for specific application in VIP when External and Mapped IP addresses are the same.Below is the diagram of&hellip; <a href=\"https:\/\/whatifsecu.tech\/?p=59\" class=\"more-link\">Continue Reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-59","post","type-post","status-publish","format-standard","hentry","category-non-classe"],"_links":{"self":[{"href":"https:\/\/whatifsecu.tech\/index.php?rest_route=\/wp\/v2\/posts\/59","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/whatifsecu.tech\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/whatifsecu.tech\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/whatifsecu.tech\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/whatifsecu.tech\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=59"}],"version-history":[{"count":4,"href":"https:\/\/whatifsecu.tech\/index.php?rest_route=\/wp\/v2\/posts\/59\/revisions"}],"predecessor-version":[{"id":93,"href":"https:\/\/whatifsecu.tech\/index.php?rest_route=\/wp\/v2\/posts\/59\/revisions\/93"}],"wp:attachment":[{"href":"https:\/\/whatifsecu.tech\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=59"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/whatifsecu.tech\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=59"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/whatifsecu.tech\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=59"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}