Changeset 37 for system/generators/iptables.php
- Timestamp:
- Jan 31, 2008, 8:38:47 PM (17 years ago)
- Location:
- system
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
system
-
Property svn:ignore
set to
nohup.out
-
Property svn:ignore
set to
-
system/generators/iptables.php
r7 r37 1 <? 2 include('global.php'); 3 include_once('../../html/is/db.php'); 4 DB_Init('localhost', 'root', '', 'is'); 1 <?php 2 include_once('../../html/global.php'); 5 3 6 4 // Generate firewall rules … … 11 9 12 10 // Blocking according IP address 13 DB_Select('users', '*', 'inet = 0');14 while($User = DB_Row())11 $DbResult = $Database->select('users', '*', 'inet = 0'); 12 while($User = $DbResult->fetch_array()) 15 13 { 16 DB_Save(); 17 DB_Select('hosts', '*', "block<2 AND MAC!='' AND user=".$User['id']); 18 while($Row = DB_Row()) 14 $DbResult2 = $Database->select('hosts', '*', "block<2 AND MAC!='' AND user=".$User['id']); 15 while($Row = $DbResult2->fetch_array()) 19 16 { 20 17 exec('iptables -t nat -A Block -s '.$Row['IP'].' -j Local'); 21 18 } 22 DB_Load();23 19 } 24 DB_Select('users', '*', 'inet = 1');25 while($User = DB_Row())20 $DbResult = $Database->select('users', '*', 'inet = 1'); 21 while($User = $DbResult->fetch_array()) 26 22 { 27 DB_Save(); 28 DB_Select('hosts','*',"block<2 AND MAC!='' AND vpn=1 AND user=".$User['id']); 29 while($Row = DB_Row()) 23 $DbResult2 = $Database->select('hosts','*',"block<2 AND MAC!='' AND vpn=1 AND user=".$User['id']); 24 while($Row = $DbResult2->fetch_array()) 30 25 { 31 26 exec('iptables -t nat -A Block -s '.$Row['IP'].' -j Local'); 32 27 } 33 DB_Load();34 28 } 35 29 36 30 // Blocking according MAC address 37 DB_Select('users', '*');38 while($User = DB_Row())31 $DbResult = $Database->select('users', '*'); 32 while($User = $DbResult->fetch_array()) 39 33 { 40 34 //echo($User['fullname']."\n"); 41 DB_Save(); 42 DB_Select('hosts','*','block<2 AND MAC!="" AND user='.$User['id'].' ORDER BY id DESC'); 43 while($Row = DB_Row()) 35 $DbResult2 = $Database->select('hosts','*','block<2 AND MAC!="" AND user='.$User['id'].' ORDER BY id DESC'); 36 while($Row = $DbResult2->fetch_array()) 44 37 { 45 38 //echo(' '.$Row['name']." ".$Row['MAC']." "); … … 92 85 //echo("\n"); 93 86 } 94 DB_Load();95 87 } 96 88 97 89 // SMTP NAT port 25 98 DB_Select('hosts', '*', 'name="MAIL"');99 $Row = DB_Row();90 $DbResult = $Database->select('hosts', '*', 'name="MAIL"'); 91 $Row = $DbResult->fetch_array(); 100 92 exec('iptables -t nat -A PreroutingDNAT -p tcp -m tcp --dport 25 -d 212.111.4.174 -j DROP'); 101 93 exec('iptables -t nat -A PreroutingDNAT -p tcp -m tcp --dport 25 -d '.$Row['external_ip'].' -j DNAT --to-destination '.$Row['IP']); … … 104 96 105 97 // Local network NAT 106 DB_Select('hosts', '*', 'name="GATE"');107 $Row = DB_Row();98 $DbResult = $Database->select('hosts', '*', 'name="GATE"'); 99 $Row = $DbResult->fetch_array(); 108 100 exec('iptables -t nat -A POSTROUTING -s 192.168.0.0/255.255.0.0 -o eth1 -j SNAT --to-source '.$Row['external_ip']); 109 101 //exec('iptables -t nat -A POSTROUTING -s 10.0.0.0/255.0.0.0 -o eth1 -j SNAT --to-source '.$Row['external_ip']);
Note:
See TracChangeset
for help on using the changeset viewer.