Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/shell/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Shell 使用qdisc和tc的ipset带宽成形_Shell_Sh_Bandwidth_Trafficshaping - Fatal编程技术网

Shell 使用qdisc和tc的ipset带宽成形

Shell 使用qdisc和tc的ipset带宽成形,shell,sh,bandwidth,trafficshaping,Shell,Sh,Bandwidth,Trafficshaping,我正在尝试使用ipset进行带宽控制。我修改了它以获得ipsetnames 这是我的手稿 TC=/sbin/tc IF=wlan0 # Interface DNLD=1mbit # DOWNLOAD Limit UPLD=1mbit # UPLOAD Limit IP1="myIPset1" # Host IP IP2="myIPset2" U32="$TC filter add dev $IF protocol ip pa

我正在尝试使用ipset进行带宽控制。我修改了它以获得ipsetnames

这是我的手稿

TC=/sbin/tc
IF=wlan0             # Interface 
DNLD=1mbit          # DOWNLOAD Limit
UPLD=1mbit          # UPLOAD Limit 
IP1="myIPset1"     # Host IP
IP2="myIPset2"
U32="$TC filter add dev $IF protocol ip parent 1:0 prio 1 u32"

start() {

    $TC qdisc add dev $IF root handle 1: htb default 30
    $TC class add dev $IF parent 1: classid 1:1 htb rate $DNLD
    $TC class add dev $IF parent 1: classid 1:2 htb rate $UPLD
    $U32 match iptables dst $IP flowid 1:1
    $U32 match iptables src $IP flowid 1:2

        #second chain
    $TC qdisc add dev $IF root handle 1: htb default 30
    $TC class add dev $IF parent 1: classid 1:1 htb rate $DNLD
    $TC class add dev $IF parent 1: classid 1:2 htb rate $UPLD
    $U32 match iptables dst $IP1 flowid 1:1
    $U32 match iptables src $IP1 flowid 1:2
}

stop() {

    $TC qdisc del dev $IF root

}

restart() {

    stop
    sleep 1
    start
    }

show() {

    $TC -s qdisc ls dev $IF
    }
case "$1" in

  start)
        echo -n "Starting bandwidth shaping: "
    start
    echo "done"
    ;;

  stop)

    echo -n "Stopping bandwidth shaping: "
    stop
    echo "done"
    ;;

  restart)
        echo -n "Restarting bandwidth shaping: "
    restart
    echo "done"
    ;;
  show)
        echo "Bandwidth shaping status for $IF:\n"
    show
    echo ""
    ;;

  *)
        pwd=$(pwd)
    echo "Usage: $(/usr/bin/dirname $pwd)/tc.bash {start|stop|restart|show}"
    ;;

esac
exit 0
当我尝试使用Shaping脚本启动Bandwith时,我得到以下输出。 开始带宽整形:非法“匹配”

这并不是在塑造带宽。如果我使用IP地址,它可以正常工作

我是qdisc和tc的新手,可以这样做吗

提前谢谢

Illegal "match"
RTNETLINK answers: File exists
RTNETLINK answers: File exists
RTNETLINK answers: File exists
Illegal "match"
Illegal "match"
done