feat: add veth test

This commit is contained in:
yanfeizhang
2023-12-26 09:24:39 +08:00
parent 62fe708a13
commit ea18a8f023
3 changed files with 26 additions and 0 deletions

View File

@@ -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)

View 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

View File