Changeset 128


Ignore:
Timestamp:
Dec 23, 2008, 8:23:59 AM (16 years ago)
Author:
george
Message:
  • Upraveno: Skripty pro generování nastavení routeru.
Location:
system/generators
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • system/generators/dns.php

    r122 r128  
    1010$BaseDir = '/var/named/chroot/var/named/';
    1111$MailServer = 'centrala';
     12$NameServers = array('centrala', 'tv');
    1213
    1314// === Local network DNS server ===
     
    1718fputs($File,'$ORIGIN zdechov.net.'."\n".
    1819'$TTL 86400'."\n".
    19 "zdechov.net.\tIN\tSOA\tns1.zdechov.net.\troot.zdechov.net.     (\n".
    20 "\t\t\t".$Serial."\t; serial\n".
    21 "\t\t\t".$RefreshTime."\t; refresh\n".
    22 "\t\t\t".$RetryTime."\t; retry\n".
    23 "\t\t\t".$ExpireTime."\t; expire\n".
    24 "\t\t\t".$MinimumTime."\t; minimum\n".
    25 "\t\t\t)\n".
    26 "\t\tIN\tNS\tns1.zdechov.net.\n".
    27 "\t\tIN\tNS\tns2.zdechov.net.\n".
     20"zdechov.net.\tIN\tSOA\t".$NameServers[0].".zdechov.net.\troot.zdechov.net.     (\n".
     21"\t\t\t".$Serial."\t; serial\n".
     22"\t\t\t".$RefreshTime."\t; refresh\n".
     23"\t\t\t".$RetryTime."\t; retry\n".
     24"\t\t\t".$ExpireTime."\t; expire\n".
     25"\t\t\t".$MinimumTime."\t; minimum\n".
     26"\t\t\t)\n".
     27"\t\tIN\tNS\t".$NameServers[0].".zdechov.net.\n".
     28"\t\tIN\tNS\t".$NameServers[1].".zdechov.net.\n".
    2829"\t\t\tTXT\t".'"community network ZdechovNET"'."\n".
    2930// "\t\tIN\tA\t192.168.0.1\n".
     
    6566  fputs($File,
    6667  '$TTL 86400'."\n".
    67   "@\tIN\tSOA\tns1.zdechov.net.\troot.zdechov.net.      (\n".
    68   "\t\t\t\t".$Serial."\t; serial\n".
    69   "\t\t\t\t".$RefreshTime."\t; refresh\n".
    70   "\t\t\t\t".$RetryTime."\t; retry\n".
    71   "\t\t\t\t".$ExpireTime."\t; expire\n".
    72   "\t\t\t\t".$MinimumTime."\t; minimum\n".
    73   "\t\t\t\t)\n".
    74   "@\tIN\tNS\tns1.zdechov.net.\n".
    75   "\tIN\tNS\tns2.zdechov.net.\n\n");
     68  "@\tIN\tSOA\t".$NameServers[0].".zdechov.net.\troot.zdechov.net.      (\n".
     69  "\t\t\t\t".$Serial."\t; serial\n".
     70  "\t\t\t\t".$RefreshTime."\t; refresh\n".
     71  "\t\t\t\t".$RetryTime."\t; retry\n".
     72  "\t\t\t\t".$ExpireTime."\t; expire\n".
     73  "\t\t\t\t".$MinimumTime."\t; minimum\n".
     74  "\t\t\t\t)\n".
     75  "@\tIN\tNS\t".$NameServers[0].".zdechov.net.\n".
     76  "\tIN\tNS\t".$NameServers[1].".zdechov.net.\n\n");
    7677  $DbResult = $Database->select('hosts','*','IP LIKE "'.$Network.'%"');
    7778  while($Row = $DbResult->fetch_array())
     
    9192  fputs($File,
    9293  '$TTL 86400'."\n".
    93   "@\tIN\tSOA\tns1.zdechov.net.\troot.zdechov.net.      (\n".
    94   "\t\t\t\t".$Serial."\t; serial\n".
    95   "\t\t\t\t".$RefreshTime."\t; refresh\n".
    96   "\t\t\t\t".$RetryTime."\t; retry\n".
    97   "\t\t\t\t".$ExpireTime."\t; expire\n".
    98   "\t\t\t\t".$MinimumTime."\t; minimum\n".
    99   "\t\t\t\t)\n".
    100   "@\tIN\tNS\tns1.zdechov.net.\n".
    101   "\tIN\tNS\tns2.zdechov.net.\n\n");
     94  "@\tIN\tSOA\t".$NameServers[0].".zdechov.net.\troot.zdechov.net.      (\n".
     95  "\t\t\t\t".$Serial."\t; serial\n".
     96  "\t\t\t\t".$RefreshTime."\t; refresh\n".
     97  "\t\t\t\t".$RetryTime."\t; retry\n".
     98  "\t\t\t\t".$ExpireTime."\t; expire\n".
     99  "\t\t\t\t".$MinimumTime."\t; minimum\n".
     100  "\t\t\t\t)\n".
     101  "@\tIN\tNS\t".$NameServers[0].".zdechov.net.\n".
     102  "\tIN\tNS\t".$NameServers[1].".zdechov.net.\n\n");
    102103  $DbResult = $Database->select('hosts','*','external_ip LIKE "'.$Network.'.%"');
    103104  while($Row = $DbResult->fetch_array())
     
    115116$Header = '$ORIGIN zdechov.net.'."\n".
    116117'$TTL 86400'."\n".
    117 "zdechov.net.\tIN\tSOA\tns1.zdechov.net.\troot.zdechov.net.     (\t\n".
     118"zdechov.net.\tIN\tSOA\t".$NameServers[0].".zdechov.net.\troot.zdechov.net.     (\t\n".
    118119"\t\t\t".$Serial."\t; serial\n".
    119120"\t\t\t".$RefreshTime."\t; refresh\n".
     
    123124"\t\t\t)\n".
    124125"\t\t\tTXT\t".'"community network ZdechovNET"'."\n".
    125 "\t\tIN\tNS\tns1.zdechov.net.\n".
    126 "\t\tIN\tNS\tns2.zdechov.net.\n".
     126"\t\tIN\tNS\t".$NameServers[0].".zdechov.net.\n".
     127"\t\tIN\tNS\t".$NameServers[1].".zdechov.net.\n".
    127128"\t\tIN\tNS\tplandsfeld.avonet.cz.\n";
    128129// "\t\tIN\tA\t81.2.194.142\n".
     
    141142{
    142143  $Data = strtolower($Row['name']);
    143   if(strlen($Data)<8) $Data .= "\t";
     144  if(strlen($Data) < 8) $Data .= "\t";
    144145  fputs($File,$Data."\tIN\tA\t".$Row['external_ip']."\n");
    145146}
     
    163164  fputs($File,
    164165  '$TTL 86400'."\n".
    165   "@\tIN\tSOA\tns1.zdechov.net.\troot.zdechov.net.      (\n".
    166   "\t\t\t\t".$Serial."\t; serial\n".
    167   "\t\t\t\t".$RefreshTime."\t; refresh\n".
    168   "\t\t\t\t".$RetryTime."\t; retry\n".
    169   "\t\t\t\t".$ExpireTime."\t; expire\n".
    170   "\t\t\t\t".$MinimumTime."\t; minimum\n".
    171   "\t\t\t\t)\n".
    172   "@\tIN\tNS\tns1.zdechov.net.\n\n".
     166  "@\tIN\tSOA\t".$NameServers[0].".zdechov.net.\troot.zdechov.net.      (\n".
     167  "\t\t\t\t".$Serial."\t; serial\n".
     168  "\t\t\t\t".$RefreshTime."\t; refresh\n".
     169  "\t\t\t\t".$RetryTime."\t; retry\n".
     170  "\t\t\t\t".$ExpireTime."\t; expire\n".
     171  "\t\t\t\t".$MinimumTime."\t; minimum\n".
     172  "\t\t\t\t)\n".
     173  "@\tIN\tNS\t".$NameServers[0].".zdechov.net.\n\n".
    173174  "\t\t\tNS\tplandsfeld.avonet.cz.\n".
    174   "\t\t\tNS\tns2.zdechov.net.\n");
     175  "\t\t\tNS\t".$NameServers[1].".zdechov.net.\n");
    175176
    176177  $DbResult = $Database->select('hosts','*','external_ip LIKE "'.$Network.'.%"');
     
    192193$Header = '$ORIGIN zdechov.zlin.czf.'."\n".
    193194'$TTL 86400'."\n".
    194 $Domain.".\tIN\tSOA\tns1.".$Domain.".\troot.".$Domain." (\n".
     195$Domain.".\tIN\tSOA\t".$NameServers[0].".".$Domain.".\troot.".$Domain." (\n".
    195196"\t\t\t".$Serial."\t; serial\n".
    196197"\t\t\t".$RefreshTime."\t; refresh\n".
     
    200201"\t\t\t)\n".
    201202"\t\t\tTXT\t".'"Community network ZdechovNET"'."\n".
    202 "\t\t\tNS\tns1.".$Domain.".\n".
    203 "\t\t\tNS\tns2.".$Domain.".\n".
     203"\t\t\tNS\t".$NameServers[0].".".$Domain.".\n".
     204"\t\t\tNS\t".$NameServers[1].".".$Domain.".\n".
    204205"\t\t\tNS\tserver.zlin.czf.\n";
    205206"\t\t\tMX\t10 ".$MailServer.".".$Domain.".\n";
     
    209210$Header = '$ORIGIN zdechov.zlin.czf.'."\n".
    210211'$TTL 86400'."\n".
    211 $Domain.".\tIN\tSOA\tns1.".$Domain.".\troot.".$Domain." (\n".
     212$Domain.".\tIN\tSOA\t".$NameServers[0].".".$Domain.".\troot.".$Domain." (\n".
    212213"\t\t\t".$Serial."\t; serial\n".
    213214"\t\t\t".$RefreshTime."\t; refresh\n".
     
    217218"\t\t\t)\n".
    218219"\t\t\tTXT\t".'"Community network ZdechovNET"'."\n".
    219 "\t\t\tNS\tns1.".$Domain.".\n".
    220 "\t\t\tNS\tns2.".$Domain.".\n".
     220"\t\t\tNS\t".$NameServers[0].".".$Domain.".\n".
     221"\t\t\tNS\t".$NameServers[1].".".$Domain.".\n".
    221222"\t\t\tNS\tserver.zlin.czf.\n";
    222223"\t\t\tMX\t10 ".$MailServer.".".$Domain.".\n";
     
    253254  $File = fopen($BaseDir.'czfree/'.$Parts[2].'.'.$Parts[1].'.'.$Parts[0].'.in-addr.arpa.zone', 'w+');
    254255  $File2 = fopen($BaseDir.'internal/'.$Parts[2].'.'.$Parts[1].'.'.$Parts[0].'.in-addr.arpa.zone', 'w+');
    255   $Nameserver = 'centrala';
    256256  $Header = '$TTL 86400'."\n".
    257   "@\tIN\tSOA\tns1.".$Domain.".\troot.".$Domain.".      (\n".
    258   "\t\t\t\t".$Serial."\t; serial\n".
    259   "\t\t\t\t".$RefreshTime."\t; refresh\n".
    260   "\t\t\t\t".$RetryTime."\t; retry\n".
    261   "\t\t\t\t".$ExpireTime."\t; expire\n".
    262   "\t\t\t\t".$MinimumTime."\t; minimum\n".
    263   "\t\t\t\t)\n".
    264   "@\tIN\tNS\tns1.".$Domain.".\n".
    265   "@\tIN\tNS\tns2.".$Domain.".\n".
     257  "@\tIN\tSOA\t".$NameServers[0].".".$Domain.".\troot.".$Domain.".      (\n".
     258  "\t\t\t\t".$Serial."\t; serial\n".
     259  "\t\t\t\t".$RefreshTime."\t; refresh\n".
     260  "\t\t\t\t".$RetryTime."\t; retry\n".
     261  "\t\t\t\t".$ExpireTime."\t; expire\n".
     262  "\t\t\t\t".$MinimumTime."\t; minimum\n".
     263  "\t\t\t\t)\n".
     264  "@\tIN\tNS\t".$NameServers[0].".".$Domain.".\n".
     265  "@\tIN\tNS\t".$NameServers[1].".".$Domain.".\n".
    266266  "\tIN\tNS\tserver.zlin.czf.\n\n";
    267267  fputs($File, $Header);
    268268
    269   $Nameserver = 'centrala-ext';
    270269  $Header = '$TTL 86400'."\n".
    271   "@\tIN\tSOA\tns1.".$Domain.".\troot.".$Domain.".      (\n".
    272   "\t\t\t\t".$Serial."\t; serial\n".
    273   "\t\t\t\t".$RefreshTime."\t; refresh\n".
    274   "\t\t\t\t".$RetryTime."\t; retry\n".
    275   "\t\t\t\t".$ExpireTime."\t; expire\n".
    276   "\t\t\t\t".$MinimumTime."\t; minimum\n".
    277   "\t\t\t\t)\n".
    278   "@\tIN\tNS\tns1.".$Domain.".\n";
    279   "@\tIN\tNS\tns2.".$Domain.".\n";
     270  "@\tIN\tSOA\t".$NameServers[0]."-ext.".$Domain.".\troot.".$Domain.".  (\n".
     271  "\t\t\t\t".$Serial."\t; serial\n".
     272  "\t\t\t\t".$RefreshTime."\t; refresh\n".
     273  "\t\t\t\t".$RetryTime."\t; retry\n".
     274  "\t\t\t\t".$ExpireTime."\t; expire\n".
     275  "\t\t\t\t".$MinimumTime."\t; minimum\n".
     276  "\t\t\t\t)\n".
     277  "@\tIN\tNS\t".$NameServers[0]."-ext.".$Domain.".\n";
     278  "@\tIN\tNS\t".$NameServers[1]."-ext.".$Domain.".\n";
    280279  "\tIN\tNS\tserver.zlin.czf.\n\n";
    281280
  • system/generators/global.php

    r37 r128  
    22
    33$MaxSubnet = 7;
    4 
     4$InetInterface = 'eth3';
    55
    66/*
    7 
    87function ToVpnIp($Host)
    9 { 
    10   if($Host['external_ip'] == '') 
     8{
     9  if($Host['external_ip'] == '')
    1110  {
    1211    $Parts = explode('.', $Host['IP']);
    1312    return('172.16.'.$Parts[2].'.'.$Parts[3]);
    14   } else 
     13  } else
    1514  {
    1615    return($Host['external_ip']);
     
    1918
    2019function ToCzfreeIp($Host)
    21 { 
     20{
    2221    $Parts = explode('.', $Host['external_ip']);
    2322    if($Host['name'] == 'CENTRALA') return('10.144.1.1');
  • system/generators/iptables.php

    r118 r128  
    11<?php
     2include('global.php');
    23include_once('/a/www/centrala/global.php');
    34
     
    5455        //{
    5556        //  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        //  exec('/sbin/iptables -t nat -A POSTROUTING -m tcp -p tcp -s '.$Row['IP'].' --sport 3725 -o '.$InetInterface.' -j SNAT --to-source '.$Row['external_ip'].':3724');
    5758        //}
    5859        if(strtolower($Row['name']) != 'gate')
     
    6263            echo($Row['name'].'='.$Row['external_ip']."\n");
    6364           
    64             exec('/sbin/iptables -t nat -A PreroutingDNAT -i eth1 -d '.$Row['external_ip'].' -j DNAT --to-destination '.$Row['IP']);
    65             exec('/sbin/iptables -t nat -A PreroutingDNAT -i eth1 -d '.$Row['external_ip'].' -j ACCEPT');
    66             exec('/sbin/iptables -t nat -A POSTROUTING -s '.$Row['IP'].' -o eth1 -j SNAT --to-source '.$Row['external_ip']);
     65            exec('/sbin/iptables -t nat -A PreroutingDNAT -i '.$InetInterface.' -d '.$Row['external_ip'].' -j DNAT --to-destination '.$Row['IP']);
     66            exec('/sbin/iptables -t nat -A PreroutingDNAT -i '.$InetInterface.' -d '.$Row['external_ip'].' -j ACCEPT');
     67            exec('/sbin/iptables -t nat -A POSTROUTING -s '.$Row['IP'].' -o '.$InetInterface.' -j SNAT --to-source '.$Row['external_ip']);
    6768          }
    6869          //exec('/sbin/iptables -t nat -A Block -m mac --mac-source '.$Row['MAC']." -j Proxy");
     
    101102//exec('/sbin/iptables -t nat -A PreroutingDNAT -p tcp -m tcp --dport 25 -d '.$Row['external_ip'].' -j DNAT --to-destination '.$Row['IP']);
    102103//exec('/sbin/iptables -t nat -A PreroutingDNAT -p tcp -m tcp --dport 25 -d '.$Row['external_ip'].' -j ACCEPT');
    103 //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']);
     104//exec('/sbin/iptables -t nat -A POSTROUTING -p tcp -m tcp --dport 25 -s 212.111.4.174 -o '.$InetInterface.' -j SNAT --to-source '.$Row['external_ip']);
    104105
    105106// Local network NAT
    106107$DbResult = $Database->select('hosts', '*', 'name="gate"');
    107108$Row = $DbResult->fetch_array();
    108 exec('/sbin/iptables -t nat -A POSTROUTING -s 192.168.0.0/255.255.0.0 -o eth1 -j SNAT --to-source '.$Row['external_ip']);
    109 //exec('/sbin/iptables -t nat -A POSTROUTING -s 10.0.0.0/255.0.0.0 -o eth1 -j SNAT --to-source '.$Row['external_ip']);
    110 //exec('/sbin/iptables -t nat -A POSTROUTING -s 212.111.16.94 -o eth1 -j MASQUERADE');
     109exec('/sbin/iptables -t nat -A POSTROUTING -s 192.168.0.0/255.255.0.0 -o  '.$InetInterface.' -j SNAT --to-source '.$Row['external_ip']);
     110//exec('/sbin/iptables -t nat -A POSTROUTING -s 10.0.0.0/255.0.0.0 -o '.$InetInterface.' -j SNAT --to-source '.$Row['external_ip']);
     111//exec('/sbin/iptables -t nat -A POSTROUTING -s 212.111.16.94 -o '.$InetInterface.' -j MASQUERADE');
    111112
    112113exec('/sbin/iptables-save>/etc/sysconfig/iptables');
  • system/generators/traffic_shaping.php

    r118 r128  
    11<?php
    2  
     2
    33$Enabled = 1;
    44$ClassesEnabled = 1;
     5include('global.php');
    56include_once('/a/www/centrala/global.php');
    67include_once('/a/www/centrala/finance/include.php');
     
    2324$VoipSpeedIn = 100; //$SpeedReserve;
    2425$VoipSpeedOut = 100; //$SpeedReserve;
    25 $InetInterface = 'eth1';
    26 $OutInterface = 'eth1';
     26$OutInterface = $InetInterface;
    2727$InInterface = 'ifb0';
    2828$FreeInetSpeed = 64;
Note: See TracChangeset for help on using the changeset viewer.