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地址
  • 下行
相关推荐
花月C1 小时前
Mysql-定时删除数据库中的验证码
数据库·后端·mysql·spring
XMYX-07 小时前
Spring Boot + Prometheus 实现应用监控(基于 Actuator 和 Micrometer)
spring boot·后端·prometheus
@yanyu6668 小时前
springboot实现查询学生
java·spring boot·后端
酷爱码9 小时前
Spring Boot项目中JSON解析库的深度解析与应用实践
spring boot·后端·json
AI小智9 小时前
Google刀刃向内,开源“深度研究Agent”:Gemini 2.5 + LangGraph 打造搜索终结者!
后端
java干货10 小时前
虚拟线程与消息队列:Spring Boot 3.5 中异步架构的演进与选择
spring boot·后端·架构
一只叫煤球的猫10 小时前
MySQL 8.0 SQL优化黑科技,面试官都不一定知道!
后端·sql·mysql
写bug写bug11 小时前
如何正确地对接口进行防御式编程
java·后端·代码规范
不超限11 小时前
Asp.net core 使用EntityFrame Work
后端·asp.net