Ignore:
Timestamp:
Nov 9, 2008, 8:05:48 PM (16 years ago)
Author:
george
Message:
  • Opraveno: Korekce systémových skriptů po aktualizaci Centrály
File:
1 edited

Legend:

Unmodified
Added
Removed
  • system/generators/iptables.php

    r103 r112  
    88//    exec('/sbin/iptables -t nat -A Block -p tcp --destination-port 80 -j REDIRECT --to-ports 3128');
    99
     10
     11
     12/*
    1013// Blocking according IP address
    1114$DbResult = $Database->select('users', '*', 'inet = 0');
     
    1821  }
    1922}
    20 $DbResult = $Database->select('users', '*', 'inet = 1'); 
     23$DbResult = $Database->select('users', '*', 'inet = 1');
    2124while($User = $DbResult->fetch_array())
    2225{
     
    2831}
    2932
     33*/
     34
    3035// Blocking according MAC address
    31 $DbResult = $Database->select('users', '*'); 
     36$DbResult = $Database->select('users', '*');
    3237while($User = $DbResult->fetch_array())
    3338{
     
    3944    if($User['inet'] == 0)
    4045    {
    41       if(($Row['block'] == 0) and ($Row['type'] == 1)) exec('/sbin/iptables -t nat -A Block -m mac --mac-source '.$Row['MAC']." -j Proxy");
    42         else exec('/sbin/iptables -t nat -A Block -m mac --mac-source '.$Row['MAC']." -j Local");
     46      //if(($Row['block'] == 0) and ($Row['type'] == 1)) exec('/sbin/iptables -t nat -A Block -m mac --mac-source '.$Row['MAC']." -j Proxy");
     47      //    else exec('/sbin/iptables -t nat -A Block -m mac --mac-source '.$Row['MAC']." -j Local");
    4348    } else {
    4449      if($Row['vpn'] == 0)
     
    4651        $CZFreeLocalIP = $Row['IP'];
    4752        //echo($Row['external_ip']."\n");
    48         if($Row['name'] == 'TBC')
    49         {
    50           exec('/sbin/iptables -t nat -A PreroutingDNAT -m tcp -p tcp --dport 3724 -d '.$Row['external_ip'].' -j DNAT --to-destination '.$Row['IP'].':3725'); 
    51           exec('/sbin/iptables -t nat -A POSTROUTING -m tcp -p tcp -s '.$Row['IP'].' --sport 3725 -o eth1 -j SNAT --to-source '.$Row['external_ip'].':3724'); 
    52         }
     53        //if($Row['name'] == 'TBC')
     54        //{
     55        //  exec('/sbin/iptables -t nat -A PreroutingDNAT -m tcp -p tcp --dport 3724 -d '.$Row['external_ip'].' -j DNAT --to-destination '.$Row['IP'].':3725');
     56        //  exec('/sbin/iptables -t nat -A POSTROUTING -m tcp -p tcp -s '.$Row['IP'].' --sport 3725 -o eth1 -j SNAT --to-source '.$Row['external_ip'].':3724');
     57        //}
    5358        if(strtolower($Row['name']) != 'centrala')
    5459        {
    5560          if($Row['external_ip'] != '')
    5661          {
    57             exec('/sbin/iptables -t nat -A PreroutingDNAT -i eth1 -d '.$Row['external_ip'].' -j DNAT --to-destination '.$Row['IP']); 
    58             exec('/sbin/iptables -t nat -A PreroutingDNAT -i eth1 -d '.$Row['external_ip'].' -j ACCEPT'); 
    59             exec('/sbin/iptables -t nat -A POSTROUTING -s '.$Row['IP'].' -o eth1 -j SNAT --to-source '.$Row['external_ip']); 
     62            exec('/sbin/iptables -t nat -A PreroutingDNAT -i eth1 -d '.$Row['external_ip'].' -j DNAT --to-destination '.$Row['IP']);
     63            exec('/sbin/iptables -t nat -A PreroutingDNAT -i eth1 -d '.$Row['external_ip'].' -j ACCEPT');
     64            exec('/sbin/iptables -t nat -A POSTROUTING -s '.$Row['IP'].' -o eth1 -j SNAT --to-source '.$Row['external_ip']);
    6065          }
    61           exec('/sbin/iptables -t nat -A Block -m mac --mac-source '.$Row['MAC']." -j Proxy");
     66          //exec('/sbin/iptables -t nat -A Block -m mac --mac-source '.$Row['MAC']." -j Proxy");
    6267        }
    6368      }
    64       else 
     69      else
    6570      {
    6671        $CZFreeLocalIP = $Row['external_ip'];
    6772 //echo('vpn');
    68         //exec('/sbin/iptables -t nat -A PreroutingDNAT -s '.$Row['IP'].' -p udp -m udp --dport 55556 -j DROP'); 
    69         if($Row['external_ip'] != '') exec('/sbin/iptables -t nat -A PreroutingDNAT -d '.$Row['external_ip'].' -j ACCEPT'); 
     73        //exec('/sbin/iptables -t nat -A PreroutingDNAT -s '.$Row['IP'].' -p udp -m udp --dport 55556 -j DROP');
     74        if($Row['external_ip'] != '') exec('/sbin/iptables -t nat -A PreroutingDNAT -d '.$Row['external_ip'].' -j ACCEPT');
    7075        exec('/sbin/iptables -t nat -A Block -s '.ToVpnIp($Row)." -j Proxy");
    7176
    72         if($Row['vpn'] == 1)
    73         {
    74           exec('/sbin/iptables -t nat -A Block -m mac --mac-source '.$Row['MAC']." -j Local");
    75         } else if($Row['vpn'] == 2) exec('/sbin/iptables -t nat -A Block -m mac --mac-source '.$Row['MAC']." -j Proxy");
     77        //if($Row['vpn'] == 1)
     78        //{
     79          //exec('/sbin/iptables -t nat -A Block -m mac --mac-source '.$Row['MAC']." -j Local");
     80        //} else if($Row['vpn'] == 2) exec('/sbin/iptables -t nat -A Block -m mac --mac-source '.$Row['MAC']." -j Proxy");
    7681      }
    7782      if($Row['czfree_ip'] != '')
    7883      {
    7984        // CZFree
    80         exec('/sbin/iptables -t nat -A PreroutingDNAT -i tun0 -d '.$Row['czfree_ip'].' -j DNAT --to-destination '.$CZFreeLocalIP); 
    81         exec('/sbin/iptables -t nat -A PreroutingDNAT -i tun0 -d '.$Row['czfree_ip'].' -j ACCEPT'); 
    82         exec('/sbin/iptables -t nat -A POSTROUTING -s '.$CZFreeLocalIP.' -o tun0 -j SNAT --to-source '.$Row['czfree_ip']); 
     85        exec('/sbin/iptables -t nat -A PreroutingDNAT -i tun0 -d '.$Row['czfree_ip'].' -j DNAT --to-destination '.$CZFreeLocalIP);
     86        exec('/sbin/iptables -t nat -A PreroutingDNAT -i tun0 -d '.$Row['czfree_ip'].' -j ACCEPT');
     87        exec('/sbin/iptables -t nat -A POSTROUTING -s '.$CZFreeLocalIP.' -o tun0 -j SNAT --to-source '.$Row['czfree_ip']);
    8388      }
    8489    }
     
    8792}
    8893
     94
    8995// SMTP NAT port 25
    90 $DbResult = $Database->select('hosts', '*', 'name="MAIL"');
     96$DbResult = $Database->select('hosts', '*', 'name="mail"');
    9197$Row = $DbResult->fetch_array();
    92 exec('/sbin/iptables -t nat -A PreroutingDNAT -p tcp -m tcp --dport 25 -d 212.111.4.174 -j DROP'); 
    93 exec('/sbin/iptables -t nat -A PreroutingDNAT -p tcp -m tcp --dport 25 -d '.$Row['external_ip'].' -j DNAT --to-destination '.$Row['IP']); 
    94 exec('/sbin/iptables -t nat -A PreroutingDNAT -p tcp -m tcp --dport 25 -d '.$Row['external_ip'].' -j ACCEPT'); 
    95 exec('/sbin/iptables -t nat -A POSTROUTING -p tcp -m tcp --dport 25 -s 212.111.4.174 -o eth1 -j SNAT --to-source '.$Row['external_ip']); 
     98exec('/sbin/iptables -t nat -A PreroutingDNAT -p tcp -m tcp --dport 25 -d 212.111.4.174 -j DROP');
     99exec('/sbin/iptables -t nat -A PreroutingDNAT -p tcp -m tcp --dport 25 -d '.$Row['external_ip'].' -j DNAT --to-destination '.$Row['IP']);
     100exec('/sbin/iptables -t nat -A PreroutingDNAT -p tcp -m tcp --dport 25 -d '.$Row['external_ip'].' -j ACCEPT');
     101exec('/sbin/iptables -t nat -A POSTROUTING -p tcp -m tcp --dport 25 -s 212.111.4.174 -o eth1 -j SNAT --to-source '.$Row['external_ip']);
    96102
    97103// Local network NAT
    98 $DbResult = $Database->select('hosts', '*', 'name="GATE"');
     104$DbResult = $Database->select('hosts', '*', 'name="gate"');
    99105$Row = $DbResult->fetch_array();
    100106exec('/sbin/iptables -t nat -A POSTROUTING -s 192.168.0.0/255.255.0.0 -o eth1 -j SNAT --to-source '.$Row['external_ip']);
Note: See TracChangeset for help on using the changeset viewer.