Skip to content
KitploitKITPLOIT
工具博客
提交
工具博客
提交

黑客、渗透测试和网络安全工具,武装您的安全武器库!

Kitploit 是一个黑客、网络安全和渗透测试工具的目录。发现最新的项目更新,查找漏洞、分析系统、自动化测试并加强你的安全。

··订阅源·联系·隐私·© 2026 Kitploit

工具目录

分类

查看所有分类
Loading categories
tcconfig — 一个 tc 命令的封装器,便于对网络接口/Docker 容器(veth)设置网络带宽/延迟/丢包/报文损坏等流量控制。 | Kitploit
工具/GitHubGitHub/thombashi/tcconfig
通用工具网络安全混沌工程
GitHubthombashi/tcconfig

tcconfig

一个 tc 命令的封装器,便于对网络接口/Docker 容器(veth)设置网络带宽/延迟/丢包/报文损坏等流量控制。

查看仓库网站
85390104个月前Kitploit 审核通过

最受欢迎

查看全部 →

发现我们社区最常用的工具。

探索所有工具

浏览我们的工具集合

查看所有工具 →
分享

.. contents:: tcconfig :backlinks: top :depth: 2

摘要

tcconfig <https://github.com/thombashi/tcconfig>__ 是一个 tc 命令的封装工具。简化了对网络接口/Docker容器(veth)进行网络带宽/延迟/丢包/包损坏等流量控制的设置。

|PyPI pkg ver| |Supported Python ver| |CI status| |CodeQL|

.. |PyPI pkg ver| image:: https://badge.fury.io/py/tcconfig.svg :target: https://badge.fury.io/py/tcconfig :alt: PyPI package version

.. |Supported Python ver| image:: https://img.shields.io/pypi/pyversions/tcconfig.svg :target: https://pypi.org/project/tcconfig :alt: Supported Python versions

.. |CI status| image:: https://github.com/thombashi/tcconfig/actions/workflows/ci.yml/badge.svg :target: https://github.com/thombashi/tcconfig/actions/workflows/ci.yml :alt: Test CI status

.. |CodeQL| image:: https://github.com/thombashi/tcconfig/actions/workflows/build_and_release.yml/badge.svg :target: https://github.com/thombashi/tcconfig/actions/workflows/build_and_release.yml :alt: Build CI status

流量控制

设置流量整形规则 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 轻松将流量整形规则应用于特定网络:

  • 出站/入站数据包
  • 源/目标 IP 地址/网络(IPv4/IPv6)
  • 源/目标端口

可用参数 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 可对网络接口设置以下参数:

  • 网络带宽速率 [G/M/K bps]
  • 网络延迟 [微秒/毫秒/秒/分钟]
  • 丢包率 [%]
  • 数据包损坏率 [%]
  • 数据包重复率 [%]
  • 数据包重排序率 [%]
  • 数据包限制计数 [COUNT]

目标对象 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  • 网络接口:例如 eth0
  • Docker 容器(与容器对应的 veth)

.. image:: docs/gif/tcset_example.gif

用法

设置流量控制(tcset 命令)

tcset 是一个向网络接口(设备)添加流量控制规则的命令。

例如:将带宽限制设置为最大 100Kbps ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ .. code-block:: console

root@kitploit:~
# tcset eth0 --rate 100Kbps

例如:设置网络延迟 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 你可以使用时间单位(如 us/sec/min 等)来指定延迟时间。

设置 100 毫秒的网络延迟 ''''''''''''''''''''''''''''''''''''''''''''''''''' .. code-block:: console

root@kitploit:~
# tcset eth0 --delay 100ms

设置 10 秒的网络延迟 ''''''''''''''''''''''''''''''''''''''''''''''''''' .. code-block:: console

root@kitploit:~
# tcset eth0 --delay 10sec

设置 0.5 分钟(30 秒)的网络延迟 ''''''''''''''''''''''''''''''''''''''''''''''''''' .. code-block:: console

root@kitploit:~
# tcset eth0 --delay 0.5min

你还可以使用以下时间单位:

.. table::

root@kitploit:~
+------------+----------------------------------------------------------+
|    单位    |                可用的指定方式(字符串)                    |
+============+==========================================================+
|小时        |``h``/``hour``/``hours``                                  |
+------------+----------------------------------------------------------+
|分钟        |``m``/``min``/``mins``/``minute``/``minutes``             |
+------------+----------------------------------------------------------+
|秒          |``s``/``sec``/``secs``/``second``/``seconds``             |
+------------+----------------------------------------------------------+
|毫秒        |``ms``/``msec``/``msecs``/``millisecond``/``milliseconds``|
+------------+----------------------------------------------------------+
|微秒        |``us``/``usec``/``usecs``/``microsecond``/``microseconds``|
+------------+----------------------------------------------------------+

例如:设置 0.1% 丢包率 ^^^^^^^^^^^^^^^^^^^^^^^^^ .. code-block:: console

root@kitploit:~
# tcset eth0 --loss 0.1%

例如:同时设置以上所有参数 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ .. code-block:: console

root@kitploit:~
# tcset eth0 --rate 100Kbps --delay 100ms --loss 0.1%

例如:指定流量控制的 IP 地址 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ .. code-block:: console

root@kitploit:~
# tcset eth0 --delay 100ms --network 192.168.0.10

例如:指定流量控制的 IP 网络和端口 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ .. code-block:: console

root@kitploit:~
# tcset eth0 --delay 100ms --network 192.168.0.0/24 --port 80

对 Docker 容器设置流量控制 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 在 Docker 主机上使用 --docker 选项执行 tcconfig:

.. code-block:: console

root@kitploit:~
# tcset <容器名称或 ID> --docker ...

你可以使用 --src-container/--dst-container 选项指定源/目标容器。

在 Docker 容器内部设置流量控制 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 如果你想在容器内设置 tc 规则,需要使用 --cap-add NET_ADMIN 选项运行容器:

.. code-block:: console

root@kitploit:~
docker run -d --cap-add NET_ADMIN -t <Docker 镜像>

内置 tcconfig 的容器镜像可在 https://hub.docker.com/r/thombashi/tcconfig/ 获取。

删除流量控制(tcdel 命令)

tcdel 是一个从网络接口(设备)删除流量整形规则的命令。

例如:删除 eth0 的流量控制 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 你可以使用 -a/--all 选项删除 eth0 的所有整形规则:

.. code-block:: console

root@kitploit:~
# tcdel eth0 --all

显示流量控制配置(tcshow 命令)

tcshow 是一个显示当前网络接口流量控制设置的命令。

示例 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

.. code-block:: console

root@kitploit:~
# tcset eth0 --delay 10ms --delay-distro 2  --loss 0.01% --rate 0.25Mbps --network 192.168.0.10 --port 8080
# tcset eth0 --delay 1ms --loss 0.02% --rate 500Kbps --direction incoming
# tcshow eth0
{
    "eth0": {
        "outgoing": {
            "dst-network=192.168.0.10/32, dst-port=8080, protocol=ip": {
                "filter_id": "800::800",
                "delay": "10.0ms",
                "delay-distro": "2.0ms",
                "loss": "0.01%",
                "rate": "250Kbps"
            }
        },
        "incoming": {
            "protocol=ip": {
                "filter_id": "800::800",
                "delay": "1.0ms",
                "loss": "0.02%",
                "rate": "500Kbps"
            }
        }
    }
}

更多信息

更多示例请访问: https://tcconfig.rtfd.io/en/latest/pages/usage/index.html

安装

安装:pip

可以通过 pip(Python 包管理器)命令从 PyPI 安装 tcconfig。

.. code:: console

root@kitploit:~
sudo pip install tcconfig

安装:dpkg(Debian/Ubuntu)

.. code:: console

root@kitploit:~
curl -sSL https://raw.githubusercontent.com/thombashi/tcconfig/master/scripts/installer.sh | sudo bash

依赖

  • Python 3.9+
  • Python 包依赖(自动安装) <https://github.com/thombashi/tcconfig/network/dependencies>__

Linux 包

  • 必须:tc 命令所需:
    • Ubuntu/Debian: iproute2
    • Fedora/RHEL: iproute-tc
  • 可选:使用 --iptables 选项时需要:
    • iptables

Linux 内核模块

  • sch_netem

可选的 Python 包

  • Pygments <http://pygments.org/>__

文档

https://tcconfig.rtfd.io/

故障排除

https://tcconfig.rtfd.io/en/latest/pages/troubleshooting.html

Docker 镜像

https://hub.docker.com/r/thombashi/tcconfig/

赞助商

|chasbecker| |shiguredo| |b4tman| |Arturi0| |github|

.. |chasbecker| image:: https://avatars.githubusercontent.com/u/44389260?s=48&u=6da7176e51ae2654bcfd22564772ef8a3bb22318&v=4 :target: https://github.com/chasbecker :alt: ex-sponsor: Charles Becker (chasbecker) .. |shiguredo| image:: https://avatars.githubusercontent.com/u/2549434?s=48&v=4 :target: https://github.com/shiguredo :alt: ex-sponsor: 時雨堂 (shiguredo) .. |b4tman| image:: https://avatars.githubusercontent.com/u/3658062?s=48&v=4 :target: https://github.com/b4tman :alt: onetime: Dmitry Belyaev (b4tman) .. |Arturi0| image:: https://avatars.githubusercontent.com/u/46711571?s=48&u=57687c0e02d5d6e8eeaf9177f7b7af4c9f275eb5&v=4 :target: https://github.com/Arturi0 :alt: onetime: Arturi0 .. |github| image:: https://avatars.githubusercontent.com/u/9919?s=48&v=4 :target: https://github.com/github :alt: onetime: GitHub (github)

成为赞助商 <https://github.com/sponsors/thombashi>__

下载工具