Pipework允许您在任意复杂的场景中将容器连接在一起。Pipework使用cgroups和namespace,并使用“普通”LXC容器(用它创建lxc-start
)和令人敬畏的Docker。
github.com代码路径:https://github.com/jpetazzo/pipework
https://github.com/jpetazzo/pipework.git
创建目录jpetazzo:
librant@ubuntu:~/gowork/src/github.com$ mkdir jpetazzo
进入到jpetazzo中,下载pipework代码:
librant@ubuntu:~/gowork/src/github.com/jpetazzo$ git clone https://github.com/jpetazzo/pipework.git
https://www.aliyun.com/jiaocheng/1381773.html
pipework语法:
pipework <hostinterface> [-i containerinterface] [-l localinterfacename] [-a addressfamily] <guest> <ipaddr>/<subnet>
pipework --wait [-i containerinterface]: 这条命令用于等待指定接口真正创建完成。
-i containerinterface: 参数指定要等待的接口名称; 如果没有指定-i参数,则默认等待名为eth1的接口创建完成。
pipework tc <guest> <tc_command>:用于在指定容器内执行tc流量控制命令
这条命令用于在<guest>指定的容器名所在的网络命名空间中执行流量控制命令<tc_command>
脚本会查找<guest>容器的pid,并在/var/run/netns下建立相应网络命名空间的符号链接,然后通过ip netns exec在指定网络命名空间中执行tc命令。
pipework rule <guest> <rule_command>:用于在指定容器内执行ip rule命令。和上面tc的原理类似。
pipework route <guest> <route_command>:用于在指定容器内执行ip route命令,和上面一条命令原理类似。
pipework [--direct-phys] <hostinterface> [-i containerinterface] [-l localinterfacename] [-a addressfamily] <guest> <ipaddr>/<subnet>[@default_gateway] [macaddr][@vlan]
pipework [--direct-phys] <hostinterface> [-i containerinterface] [-l localinterfacename] <guest> dhcp [macaddr][@vlan]
用于为指定的<guest>容器创建网卡,并桥接到<hostinterface>指定的宿主设备。
linux bridge不支持创建vlan,如果要创建vlan只能使用openvswitch或者物理网卡。
pipework使用shell脚本编写,整个文件大约460行代码,很适合学习网络相关的知识。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有