Next: , Previous: ACL, Up: Configuration


3.3 The <nat> section

The NAT section is used to define network address translation rules, these rules allow one to translate the source or destination IP address within packets. A common use for this is when a webserver is behind a firewall, requests are made to a globally routable IP address and translated to the internal IP address of the webserver and visa versa.

This section has the following syntax...

     <firewall>
     .
     .
     .
         <nat>
             <snat>
                 <rule name="traf_from_webserver"
                         to-src="<globally routable IP here>">
                     traffic_from_webserver
                 </rule>
             </snat>
             <dnat>
                 <rule name="traf_to_webserver" to-dst="192.168.1.100">
                     traffic_to_webserver
                 </rule>
             </dnat>
             <masq>
                 <rule name="traf_to_from_inside">
                     internal_dsl_ips
                 </rule>
             </masq>
         </nat>
     .
     .
     .
     </firewall>


There are 3 tags available, <snat>, <dnat> and <masq>, these three tags are used for source network address translation, destination address translation and masquerading respectively.

Valid options for these tags are as follows...


An example using the above definitions would look something like this...
     <firewall>
         # Global configuration and access classes
         <global>
             <class name="traf_from_webserver">
                 <address src="192.168.0.100"/>
             </class>
             <class name="traf_to_webserver">
                 <address dst="<globally routable IP here>"/>
             </class>
         </global>
     
         # Network address translation
         <nat>
             <snat>
                 <rule to-src="<globally routable IP here>">
                     traf_from_webserver
                 </rule>
             </snat>
             <dnat>
                 <rule to-dst="192.168.0.100">
                     traf_to_webserver
                 </rule>
             </dnat>
         </nat>
     </firewall>


Here is an example if you pc is acting as a DSL router...

     <firewall>
         # Global configuration and access classes
         <global>
             <class name="traf_going_to_dsl">
                 <address src="192.168.0.0/24"/>
             </class>
         </global>
     
         # Network address translation
         <nat>
             <masq>
                 <rule name="masq_traffic_going_out">
                     traf_going_to_dsl
                 </rule>
             </masq>
         </nat>
     </firewall>