mirror of
https://github.com/yanfeizhang/coder-kung-fu.git
synced 2026-05-09 15:43:03 +08:00
feat: add veth test
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
- [通过多 IP 达成单机百万连接(支持c、java、php三种语言)](tests/network/test02)
|
||||
- [通过端口重用达成单机百万连接(支持c、java、php三种语言)](tests/network/test03)
|
||||
- [一个模拟 tcpdump 的简单抓包程序](tests/network/test04)
|
||||
- [简单的veth通信](tests/network/test09)
|
||||
- [用 bridge 连接本机上的多组 veth,使其可以互相通信](tests/network/test05)
|
||||
- [命令行使用 namespace 的简单实验](tests/network/test06)
|
||||
- [手工模拟实现一个可以和外部通信的容器网络](tests/network/test07)
|
||||
|
||||
25
tests/network/test09/Makefile
Normal file
25
tests/network/test09/Makefile
Normal file
@@ -0,0 +1,25 @@
|
||||
.PHONY: create-veth
|
||||
create-veth:
|
||||
ip link add veth1 type veth peer name veth1_p
|
||||
ip addr add 192.168.1.1/24 dev veth1
|
||||
ip addr add 192.168.1.2/24 dev veth1_p
|
||||
ip link set veth1 up
|
||||
ip link set veth1_p up
|
||||
ifconfig
|
||||
|
||||
.PHONY: setting
|
||||
setting:
|
||||
echo 0 > /proc/sys/net/ipv4/conf/veth1/rp_filter
|
||||
echo 0 > /proc/sys/net/ipv4/conf/veth1_p/rp_filter
|
||||
echo 1 > /proc/sys/net/ipv4/conf/veth1/accept_local
|
||||
echo 1 > /proc/sys/net/ipv4/conf/veth1_p/accept_local
|
||||
|
||||
.PHONY: ping
|
||||
ping:
|
||||
ping 192.168.1.2 -I veth1
|
||||
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
ip link delete veth1
|
||||
ip link delete veth1_p
|
||||
0
tests/network/test09/main.c
Normal file
0
tests/network/test09/main.c
Normal file
Reference in New Issue
Block a user