Запомняне

» Здравейте
[ Вход :: Регистриране ]
 » Начало » Li Форуми » Help & Support » Networking » Имам рутер които има и шеирър
Тема: Имам рутер които има и шеирър
Мнение #1
Написано на: Ноември 09 2007, 01:14
dobchev

No avatar chosen




Група: Li fans
Мнения: 2
Регистриран: Октомври 2007

Оценка: няма

Offline
Имам рутер които има и шеирър искам да мога да коригирам всичко това през уеб ас го имам уеба обаче как да наварща нещата кои е този скрипт които щте ми барка в рутера това е шеиръра
#!/usr/bin/perl

use CGI;
use strict;
use warnings;

my $dev_ext     = "eth0"; # External interface using for upload
my $dev_int     = "eth1"; # Internal interface using for download
my $rate_limit  = "100Mbit";

#########################################

Adding basic rules in traffic control #

#########################################
  my $delroot_dev0  = "/sbin/tc qdisc del dev $dev_ext root";
  my $addroot_dev0  = "/sbin/tc qdisc add dev $dev_ext root handle 1 htb default 30 r2q 100";
  my $addclass_dev0 = "/sbin/tc class add dev $dev_ext parent 1: classid 1:1 htb rate $rate_limit burst 15k";

  my $delroot_dev1  = "/sbin/tc qdisc del dev $dev_int root";
  my $addroot_dev1  = "/sbin/tc qdisc add dev $dev_int root handle 1 htb default 30 r2q 100";
  my $addclass_dev1 = "/sbin/tc class add dev $dev_int parent 1: classid 1:2 htb rate $rate_limit burst 15k";


  `$delroot_dev0`;
  `$addroot_dev0`;
  `$addclass_dev0`;

  `$delroot_dev1`;
  `$addroot_dev1`;
  `$addclass_dev1`;

#########################################

my @sport_range = ("20","21","22","25","80","110"
;,"143","443","3389");

  my $basicclass_sport  = "/sbin/tc class add dev $dev_ext parent 1:1 classid 1:10 htb rate $rate_limit burst 15k";
  my $basicqdisc_sport  = "/sbin/tc qdisc add dev $dev_ext parent 1:10 handle 10 sfq perturb 10";

  `$basicclass_sport`;

  `$basicqdisc_sport`;


foreach my $sport (@sport_range){
  my $basicfilter_sport = "/sbin/tc filter add dev $dev_ext parent 1:0 protocol ip prio 100 u32 match ip sport $sport 0xffff classid 1:10";

  `$basicfilter_sport`;

}


my @dport_range = ("20","21","22","25","80","110"
;,"143","443","3389");

  my $basicclass_dport  = "/sbin/tc class add dev $dev_int parent 1:2 classid 1:20 htb rate $rate_limit burst 15k";
  my $basicqdisc_dport  = "/sbin/tc qdisc add dev $dev_int parent 1:20 handle 20 sfq perturb 10";

  `$basicclass_dport`;

  `$basicqdisc_dport`;


foreach my $dport (@dport_range){

  my $basicfilter_dport = "/sbin/tc filter add dev $dev_int parent 1:0 protocol ip prio 100 u32 match ip dport $dport 0xffff classid 1:20";

  `$basicfilter_dport`;

}



  my $class_default = "/sbin/tc class add dev $dev_int parent 1:2 classid 1:30 htb rate 50Kbit ceil 2500Kbit burst 25k";
  my $qdisc_default = "/sbin/tc qdisc add dev $dev_int parent 1:30 handle 30 sfq perturb 10";

  `$class_default`;
  `$qdisc_default`;

  &users_shapers();




sub users_shapers(){

my ($ip, $id, $bgmin, $bgmax, $intmin, $intmax);

my $rates_limit = "2500";

$bgmin  = $rates_limit;
$bgmax  = $rates_limit;
$intmin = $rates_limit;
$intmax = $rates_limit;

  for ($ip=1;$ip<254;$ip++){
 
my $ips = ($ip^32-24);
      $id = sprintf("%X", $ips + 0x200);
      my $class_bg_ul = "tc class add dev $dev_int parent 1:2 classid 1:0".$id." htb rate ".$bgmin."Kbit ceil ".$bgmax."Kbit prio 5";
      my $qdisc_bg_ul = "tc qdisc add dev $dev_int parent 1:0".$id." handle 0".$id." sfq perturb 10 ";
my $addr_bg_ul  = "/sbin/tc filter add dev $dev_int parent 1:0 protocol ip prio 100 u32 match ip src 10.10.77.2".$ip." classid 1:0".$id."";

      $id = sprintf("%X", $ips + 0x800);
      my $class_bg_dl = "tc class add dev $dev_ext parent 1:1 classid 1:0".$id." htb rate ".$bgmin."Kbit ceil ".$bgmax."Kbit prio 5";
      my $qdisc_bg_dl = "tc qdisc add dev $dev_ext parent 1:0".$id." handle ".$id." sfq perturb 10 ";
my $addr_bg_dl  = "/sbin/tc filter add dev $dev_int parent 1:0 protocol ip prio 100 u32 match ip dst 10.10.77.2".$ip." classid 1:0".$id."";

      $id = sprintf("%X", $ips + 0x400);
      my $class_int_ul = "tc class add dev $dev_int parent 1:25 classid 1:0".$id." htb rate ".$intmin."Kbit ceil ".$intmax."Kbit prio 4";
      my $qdisc_int_ul = "tc qdisc add dev $dev_int parent 1:0".$id." handle ".$id." sfq perturb 10 ";
my $addr_int_ul  = "/sbin/tc filter add dev $dev_int parent 1:0 protocol ip prio 100 u32 match ip src 10.10.77.2".$ip." classid 1:0".$id."";

      $id = sprintf("%X", $ips + 0x300);
      my $class_int_dl = "tc class add dev $dev_ext parent 1:20 classid 1:0".$id." htb rate ".$intmin."Kbit ceil ".$intmax."Kbit prio 4";
      my $qdisc_int_dl = "tc qdisc add dev $dev_ext parent 1:0".$id." handle ".$id." sfq perturb 10 ";
my $addr_int_dl  = "/sbin/tc filter add dev $dev_int parent 1:0 protocol ip prio 100 u32 match ip dst 10.10.77.2".$ip." classid 1:0".$id."";
 
   
      `$class_bg_ul`;
      `$qdisc_bg_ul`;
`$addr_bg_ul`;

`$class_int_ul`;
`$qdisc_int_ul`;
`$addr_int_ul`;

      `$class_bg_dl`;
      `$qdisc_bg_dl`;
`$addr_bg_dl`;

`$class_int_dl`;
`$qdisc_int_dl`;
`$addr_int_dl`;
  }
}
Обаче искам да го създавам през уев като ип и на оприделени места да пипа заштото тука имаме ип и скоруст нали те трябва дасе коригират на даено ир ако знае н,кои нека каже и блогодаря
Контакти:  dobchev
WEB  
Общо 0 отговор(а) от Ноември 09 2007, 01:14 до сега
 » Начало » Li Форуми » Help & Support » Networking » Имам рутер които има и шеирър

© 2014 Linux Index Project
Powered by iF 1.0.0 © 2006 ikonForums