linux tc实现ingress&&egress限速

限制网卡的上行流量

上行流量用ingress这个qdisc实现,实现简单的限速

sql 复制代码
tc qdisc add dev wg0 ingress
tc filter add dev wg0 protocol ip ingress  u32 match ip src 13.0.0.3/32 police rate 10mbit burst 10k drop flowid :1
tc filter add dev wg0 protocol ip ingress  u32 match ip src 13.0.0.4/32 police rate 10mbit burst 10k drop flowid :1

限制网卡的下行流量

sql 复制代码
tc qdisc add dev wg0 root handle 1: htb default 2
tc class add dev wg0 parent 1: classid 1:1 htb rate 5Mbit ceil 10Mbit
tc class add dev wg0 parent 1: classid 1:2 htb rate 1000Mbit ceil 10Mbit
tc filter add dev wg0 parent 1: protocol ip prio 1 u32 match ip dst 13.0.0.3/32 flowid 1:1
tc filter add dev wg0 parent 1: protocol ip prio 1 u32 match ip dst 13.0.0.4/32 flowid 1:2

用iperf分别测试上行速率和下行速率

  • 上行 下行流量用htb这个qdisc实现,用不同的class来区分需要限制的ip地址
  • 下行
相关推荐
程序员鱼皮4 分钟前
前特斯拉 AI 总监:AI 编程最大的谎言,是 “提效”
前端·后端·ai·程序员·开发
好好研究1 小时前
SpringBoot使用外置Tomcat
spring boot·后端·tomcat
索荣荣1 小时前
Spring Boot 实现DOCX转PDF(基于docx4j的轻量级开源方案)
spring boot·后端·pdf
mit6.8241 小时前
[todo]10个常见的后端框架
后端
没有bug.的程序员1 小时前
Spring Boot 与 Sleuth:分布式链路追踪的集成、原理与线上故障排查实战
java·spring boot·分布式·后端·分布式链路追踪·sleuth·线上故障排查
爱敲代码的憨仔1 小时前
Spring-AOP
java·后端·spring
短剑重铸之日1 小时前
《设计模式》第四篇:观察者模式
java·后端·观察者模式·设计模式
Hx_Ma162 小时前
SpringBoot注册格式化器
java·spring boot·后端
乔江seven2 小时前
【python轻量级Web框架 Flask 】1 Flask 初识
开发语言·后端·python·flask
知识即是力量ol2 小时前
一次完整的 Spring Security JWT 鉴权链路解析
java·后端·spring·鉴权·springsecurity