Користувальницькькі налаштування

Налаштування сайту


uaixshape

Розбіжності

Тут показані розбіжності між вибраною ревізією та поточною версією сторінки.

Посилання на цей список змін

Порівняння попередніх версій Попередня ревізія
Попередня ревізія
uaixshape [2013/03/03 23:32]
uaixshape [2023/06/15 21:01]
nightfly знищено
Рядок 1: Рядок 1:
 +====== Отдельная скорость на UA-IX ======
 +Среди некоторых провайдеров до сих пор является популярной выдача большей скорости "на Украину" абонентам. В случае получения префиксов UA-IX сетей при помощи BGP и заруливания их через другой интерфейс - все более менее понятно. В противном случае возможно использование следующего скрипта:
  
 +<file php update_uaix.php>
 +<?php
 +/////////////////////// CONFIG SECTION ///////////////////
 +
 +//URL to get UA-IX prefixes
 +$prefixes_url='http://www.colocall.net/ua/prefixes.txt';
 +// ipfw command path
 +$ipfw='/sbin/ipfw -q';
 +
 +//ukrainian prefixes table
 +$uaix_table=6;
 +
 +//pipe to shape ukrainian prefixes, upload pipe will be +1
 +$uaix_pipe=6;
 +
 +//UA-IX speed - download and upload
 +$uaix_speed='10Mbit/s';
 +$uaix_upload='5Mbit/s';
 +
 +//shape interface
 +$shape_interface='em2';
 +
 +///////////////////////////////////////////////////////
 +set_time_limit (0);
 +
 +$allprefixes_raw=file_get_contents($prefixes_url);
 +
 +if (!empty($allprefixes_raw)) {
 +
 +$allprefixes=explode("\n", $allprefixes_raw);
 +
 +//flushing old prefixes
 +$table_flush_cmd=$ipfw.' table '.$uaix_table.' flush';
 +shell_exec($table_flush_cmd);
 +
 +//refreshing pipes
 +$pipe_refresh_cmd=$ipfw.' pipe '.$uaix_pipe.' config bw '.$uaix_speed.' queue 32Kbytes mask dst-ip 0xffffffff';
 +shell_exec($pipe_refresh_cmd);
 +
 +$pipe_refresh_cmd=$ipfw.' pipe '.($uaix_pipe+1).' config bw '.$uaix_upload.' queue 32Kbytes mask src-ip 0xffffffff';
 +shell_exec($pipe_refresh_cmd);
 +
 +//extracting ua-ix prefixes
 +foreach ($allprefixes as $each) {
 + $each=trim($each);
 + if (!empty($each)) {
 + $table_add_cmd=$ipfw.' table '.$uaix_table.' add '.$each;
 + shell_exec($table_add_cmd);
 +    }
 +}
 +
 +//adding shaper rules for active ubilling users
 +$unshape_cmd=$ipfw.' delete 11000 11001';
 +shell_exec($unshape_cmd);
 +$shape_cmd=$ipfw.' add 11000 pipe '.($uaix_pipe+1).' ip from table\(3\) to table\('.$uaix_table.'\) via '.$shape_interface.' in';
 +shell_exec($shape_cmd);
 +$shape_cmd=$ipfw.' add 11001 pipe '.$uaix_pipe.' ip from table\('.$uaix_table.'\)  to table\(4\)  via '.$shape_interface.' out';
 +shell_exec($shape_cmd);
 +
 +//all done
 +print(sizeof($allprefixes).' UA-IX prefixes processed'."\n");
 +
 +} else {
 + print("Error receiving UA-IX prefixes");
 +}
 +
 +?>
 +</file> 
 +Как минимум изменения под вашу персональную реальность, требуют опции: $uaix_speed, $uaix_upload, $shape_interface.\\
 +Вызывать мы можем его при помощи команды
 +  php -q /etc/stargazer/update_uaix.php
 +
 +когда и как нам угодно: на старте системы - после инициализации фаервола, либо скажем при помощи crontab.\\
 +
 +После отработки скрипта, мы получим следующие правила в фаерволе:
 +<code>
 +11000 pipe 7 ip from table(3) to table(6) via em2 in
 +11001 pipe 6 ip from table(6) to table(4) via em2 out
 +</code>
 +
 +Собственно в табличке 6 у нас будут все UA-IX префиксы, а в 3,4 как водиться наши активные абоненты. Что откуда тут береться разобраться не должно представлять особых проблем.