diff -ur 0-5tag_abills_03.07.2009/Abills/modules/Dv/templates/dv_tt.tpl abills/Abills/modules/Dv/templates/dv_tt.tpl
--- 0-5tag_abills_03.07.2009/Abills/modules/Dv/templates/dv_tt.tpl	2009-06-17 13:43:14.000000000 +0400
+++ abills/Abills/modules/Dv/templates/dv_tt.tpl	2009-09-04 02:04:48.000000000 +0400
@@ -12,10 +12,11 @@
 <tr><td colspan=2>$_PREPAID (Mb):</td><td><input type=text size=12 name='TT_PREPAID' value='%TT_PREPAID%'></td></tr>
 <tr><td rowspan=2>$_SPEED (Kbits):</td><td>IN</td><td><input type=text size=12 name='TT_SPEED_IN' value='%TT_SPEED_IN%'></td></tr>
 <tr><td>OUT</td><td><input type=text size=12 name='TT_SPEED_OUT' value='%TT_SPEED_OUT%'></td></tr>
+<tr><td colspan=2>$_NG_NAT:</td><td><input type=text name='TT_NG_NAT' value='%TT_NG_NAT%'></td></tr>
 <tr><td colspan=2>$_DESCRIBE:</td><td><input type=text name='TT_DESCRIBE' value='%TT_DESCRIBE%'></td></tr>
 <tr><td colspan=2>$_EXPRASSION:</td><td><textarea name='TT_EXPRASSION' cols=40 rows=8>%TT_EXPRASSION%</textarea></td></tr>
 
-<tr><td colspan=2>NETS</td><td>%NETS_SEL%</td></tr>
+<tr><td colspan=2>$_NETS</td><td>%NETS_SEL%</td></tr>
 <tr><th colspan=3>%DV_EXPPP_NETFILES%</th></tr>
 </table>
 <input type=submit name='%ACTION%' value='%LNG_ACTION%'>
diff -ur 0-5tag_abills_03.07.2009/Abills/modules/Dv/webinterface abills/Abills/modules/Dv/webinterface
--- 0-5tag_abills_03.07.2009/Abills/modules/Dv/webinterface	2009-09-02 19:24:41.000000000 +0400
+++ abills/Abills/modules/Dv/webinterface	2009-09-04 05:44:17.000000000 +0400
@@ -4324,6 +4382,7 @@
       TT_NET_ID_0    => $FORM{TT_NETS_0},
       TT_PREPAID_0   => $FORM{TT_PREPAID_0},
       TT_SPEED_0     => $FORM{TT_SPEED_0},
+      TT_NG_NAT_0  => $FORM{TT_NG_NAT_0},
 
       TT_DESCRIBE_1  => $FORM{'TT_DESCRIBE_1'},
       TT_PRICE_IN_1  => $FORM{TT_PRICE_IN_1},
@@ -4331,10 +4390,12 @@
       TT_NETS_1      => $FORM{TT_NETS_1},
       TT_PREPAID_1   => $FORM{TT_PREPAID_1},
       TT_SPEED_1     => $FORM{TT_SPEED_1},
+      TT_NG_NAT_1  => $FORM{TT_NG_NAT_1},
 
       TT_DESCRIBE_2 => $FORM{TT_DESCRIBE_2},
       TT_NETS_2     => $FORM{TT_NETS_2},
       TT_SPEED_2    => $FORM{TT_SPEED_2},
+      TT_NG_NAT_2  => $FORM{TT_NG_NAT_2},
 
       EX_FILE_PATH  => "$conf{DV_EXPPP_NETFILES}"
     });
diff -ur 0-5tag_abills_03.07.2009/Abills/mysql/Tariffs.pm abills/Abills/mysql/Tariffs.pm
--- 0-5tag_abills_03.07.2009/Abills/mysql/Tariffs.pm	2009-09-01 08:23:25.000000000 +0400
+++ abills/Abills/mysql/Tariffs.pm	2009-09-04 00:08:07.000000000 +0400
@@ -757,7 +757,9 @@
       TT_NET_ID     => 0,
       TT_PREPAID    => 0,
       TT_SPEED_IN   => 0,
-      TT_SPEED_OUT  => 0);
+      TT_SPEED_OUT  => 0,
+      TT_NG_NAT     => 0
+      );
 
 #      TT_DESCRIBE_1 => '',
 #      TT_PRICE_IN_1 => '0.00000',
@@ -795,14 +798,14 @@
 	  my $show_nets = ($attr->{SHOW_NETS}) ? ', tc.nets' : '';
 	  
 	  $self->query($db, "SELECT tt.id, in_price, out_price, prepaid, in_speed, 
-	    out_speed, descr, tc.name, expression, tt.net_id $show_nets
+	    out_speed, descr, tc.name, expression, tt.net_id $show_nets, ng_nat
      FROM trafic_tarifs  tt 
      LEFT JOIN  traffic_classes tc ON (tc.id=tt.net_id)
      WHERE tt.interval_id='$attr->{TI_ID}'
      ORDER BY tt.id DESC;");
    }	
 	else {
-	  $self->query($db, "SELECT id, in_price, out_price, prepaid, in_speed, out_speed, descr, net_id, expression
+	  $self->query($db, "SELECT id, in_price, out_price, prepaid, in_speed, out_speed, descr, net_id, expression, ng_nat
      FROM trafic_tarifs 
      WHERE tp_id='$self->{TP_ID}'
      ORDER BY tt.id;");
@@ -813,7 +816,7 @@
   my $a_ref = $self->{list};
 
   foreach my $row (@$a_ref) {
-      my ($id, $tarif_in, $tarif_out, $prepaid, $speed_in, $speed_out, $describe, $nets) = @$row;
+      my ($id, $tarif_in, $tarif_out, $prepaid, $speed_in, $speed_out, $describe, $nets, $ng_nat) = @$row;
       $self->{'TT_DESCRIBE_'. $id}   = $describe;
       $self->{'TT_PRICE_IN_' . $id}  = $tarif_in;
       $self->{'TT_PRICE_OUT_' . $id} = $tarif_out;
@@ -821,6 +824,7 @@
       $self->{'TT_PREPAID_' .$id}    = $prepaid;
       $self->{'TT_SPEED_IN' .$id}    = $speed_in;
       $self->{'TT_SPEED_OUT' .$id}   = $speed_out;
+      $self->{'TT_NG_NAT_'. $id}   = $ng_nat;
    }
 
   return $self;
@@ -843,7 +847,8 @@
   $self->query($db, "SELECT id, interval_id, in_price, out_price, prepaid, in_speed, out_speed, 
 	     descr, 
 	     net_id,
-	     expression
+	     expression,
+	     ng_nat
      FROM trafic_tarifs 
      WHERE 
      interval_id='$attr->{TI_ID}'
@@ -860,7 +865,8 @@
    $self->{TT_SPEED_OUT},
    $self->{TT_DESCRIBE},
    $self->{TT_NET_ID},
-   $self->{TT_EXPRASSION}
+   $self->{TT_EXPRASSION},
+   $self->{TT_NG_NAT}
   ) = @{ $self->{list}->[0] };
 
 	
@@ -884,10 +890,10 @@
    }
   
   $self->query($db, "INSERT INTO trafic_tarifs  
-    (interval_id, id, descr,  in_price,  out_price,  net_id,  prepaid,  in_speed, out_speed, expression)
+    (interval_id, id, descr,  in_price,  out_price,  net_id,  prepaid,  in_speed, out_speed, expression, ng_nat)
     VALUES 
     ('$DATA{TI_ID}', '$DATA{TT_ID}',   '$DATA{TT_DESCRIBE}', '$DATA{TT_PRICE_IN}',  '$DATA{TT_PRICE_OUT}',
-     '$DATA{TT_NET_ID}', '$DATA{TT_PREPAID}', '$DATA{TT_SPEED_IN}', '$DATA{TT_SPEED_OUT}', '$DATA{TT_EXPRASSION}')", 'do');
+     '$DATA{TT_NET_ID}', '$DATA{TT_PREPAID}', '$DATA{TT_SPEED_IN}', '$DATA{TT_SPEED_OUT}', '$DATA{TT_EXPRASSION}', '$DATA{TT_NG_NAT}')", 'do');
 
 
   if ($attr->{DV_EXPPP_NETFILES} && $attr->{NETS}) {
@@ -919,7 +925,8 @@
     prepaid='". $DATA{TT_PREPAID} ."',
     in_speed='". $DATA{TT_SPEED_IN} ."',
     out_speed='". $DATA{TT_SPEED_OUT} ."',
-    expression = '". $DATA{TT_EXPRASSION} ."'
+    expression = '". $DATA{TT_EXPRASSION} ."',
+    ng_nat='". $DATA{TT_NG_NAT} ."'
     WHERE 
     interval_id='$attr->{TI_ID}' and id='$DATA{TT_ID}';", 'do');
 
diff -ur 0-5tag_abills_03.07.2009/cgi-bin/admin/index.cgi abills/cgi-bin/admin/index.cgi
--- 0-5tag_abills_03.07.2009/cgi-bin/admin/index.cgi	2009-09-03 02:01:49.000000000 +0400
+++ abills/cgi-bin/admin/index.cgi	2009-09-04 02:02:48.000000000 +0400
@@ -2313,8 +2313,8 @@
      	 #Traffic tariff IN (1 Mb) Traffic tariff OUT (1 Mb) Prepaid (Mb) Speed (Kbits) Describe NETS 
 
        my $table2 = $html->table({ width       => '100%',
-                                   title_plain => ["#", "$_TRAFFIC_TARIFF In ", "$_TRAFFIC_TARIFF Out ", "$_PREPAID", "$_SPEED IN",  "$_SPEED OUT", "DESCRIBE", "NETS", "-", "-"],
-                                   cols_align  => ['center', 'right', 'right', 'right', 'right', 'right', 'left', 'right', 'center', 'center', 'center'],
+                                   title_plain => ["#", "$_TRAFFIC_TARIFF In ", "$_TRAFFIC_TARIFF Out ", "$_PREPAID", "$_SPEED IN",  "$_SPEED OUT", "$_DESCRIBE", "$_NG_NAT", "$_NETS", "-", "-"],
+                                   cols_align  => ['center', 'right', 'right', 'right', 'right', 'right', 'left', 'right', 'left', 'center', 'center', 'center'],
                                    caption     => "$_TRAFIC_TARIFS"
                                   } );
 
@@ -2328,14 +2328,15 @@
            $line->[4], 
            $line->[5], 
            $line->[6], 
+           $line->[10], 
            convert($line->[7], { text2html => 1  }),
            $html->button($_CHANGE, "index=$index$pages_qs&tt=$TI_ID&chg=$line->[0]"),
            $html->button($_DEL, "index=$index$pages_qs&tt=$TI_ID&del=$line->[0]", { MESSAGE => "$_DEL [$line->[0]]?" } ));
         }
 
        my $table_traf = $table2->show();
-  
-       $table->addtd($table->td("$table_traf", { bgcolor => $_COLORS[2], colspan => 7}));
+ 
+       $table->addtd($table->td("$table_traf", { bgcolor => $_COLORS[2], colspan => 8}));
      }
      
    };
diff -ur 0-5tag_abills_03.07.2009/language/russian.pl abills/language/russian.pl
--- 0-5tag_abills_03.07.2009/language/russian.pl	2009-09-02 11:37:34.000000000 +0400
+++ abills/language/russian.pl	2009-09-04 00:12:13.000000000 +0400
@@ -354,3 +354,6 @@
 $_COR_BANK_ACCOUNT="Êîðåñï. ñ÷åò";
 $_MAX_SESSION_DURATION="Ìàêc. âðåìÿ ñåññèè";
 $_HANGUPED="Îòêëþ÷åí";
+
+$_NG_NAT="Õóê NG_NAT";
+$_NETS="Ñåòè";
diff -ur 0-5tag_abills_03.07.2009/libexec/linkupdown abills/libexec/linkupdown
--- 0-5tag_abills_03.07.2009/libexec/linkupdown	2009-09-01 19:15:32.000000000 +0400
+++ abills/libexec/linkupdown	2009-09-04 01:57:07.000000000 +0400
 @@ -229,6 +229,7 @@
 if ($ACTION eq 'up') {
   my %speeds = ();
   my %nets   = ();
+  my %ng_nat = ();
   my %expr   = ();

   if (! defined($user)) {
@@ -283,11 +284,12 @@
       while(my($k, $v)=each( %TT_IDS)) {
         print "$k, $v\n" if ($debug > 0);
         $user->{TI_ID}=$v;
-             my $list = $tariffs->tt_list({ TI_ID => $v });
+             my $list = $tariffs->tt_list({ TI_ID => $v, SHOW_NETS => 1 });
              foreach my $line (@$list)  {
                  $speeds{$line->[0]}{IN}="$line->[4]";
                  $speeds{$line->[0]}{OUT}="$line->[5]";
-                 $nets{$line->[0]}="$line->[7]";
+                 $nets{$line->[0]}="$line->[10]";
+                 $ng_nat{$line->[0]}="$line->[11]";
                  $expr{$line->[0]}="$line->[8]" if (length($line->[8]) > 5);
                  #print "$line->[0] $line->[4]\n";
              }
@@ -419,6 +421,17 @@
      }
     #FreeBSD ipfw pipe shaper
     else {
+    $rules_divert_one = $START_FW[3] + $inum * 2;
+    $rules_divert_two = $START_FW[3] + $inum * 2 +1;
+    if ($ng_nat{$traf_type} && $ng_nat{$traf_type} ne 0)
+    {
+        if ($traf_type eq 0)
+        {
+               push @FW_ACTIONS, "$IPFW add $rules_divert_two netgraph $ng_nat{$traf_type} tag 1 ip from $HISADDR to $nets{$traf_type} via $INTERFACE in";
+        } else {
+               push @FW_ACTIONS, "$IPFW add $rules_divert_one netgraph $ng_nat{$traf_type} tag 1 ip from $HISADDR to $nets{$traf_type} via $INTERFACE in";
+        }
+    }
     if ($speed_in > 0) {
         $pipe_exist=1;
           #In;