sysctl net.ipv4.ip_forward# 0意味着未开启sysctl -w net.ipv4.ip_forward=1echo net.ipv4.ip_forward=1 >> /usr/lib/sysctl.d/00-system.confsysctl -pbridge-netfilter 设置可以使 iptables 规则可以在 Linux Bridges 上面工作,就像 Docker 和 Kubernetes 设置的那样。
此设置对于 Linux 内核进行宿主机和容器之间进行数据包的地址转换是必须的。
[root@t91 home]# sysctl net.bridge.bridge-nf-call-iptablesnet.bridge.bridge-nf-call-iptables = 1# 如果是0,则表示未开启modprobe br_netfiltersysctl -w net.bridge.bridge-nf-call-iptables=1echo net.bridge.bridge-nf-call-iptables=1 >> /etc/sysconf.d/10-bridge-nf-call-iptables.confsysctl -pKubernetes 提供了各种网络插件来支持其集群功能,同时也对传统的基于 IP 和端口的应用程序提供了向后兼容的支持。
最常见的 一种 Kubernetes 网络方案就是利用 VxLan Overlay 网络,其中的 IP 数据包被封装在 UDP 中通过8472端口进行数据传输。
$ ping 10.244.1.4 PING 10.244.1.4 (10.244.1.4): 56 data bytes^C--- 10.244.1.4 ping statistics ---5 packets transmitted, 0 packets received, 100% packet loss# 在服务端执行iperf -s -p 8472 -u# 在客户端执行iperf -c 172.28.128.103 -u -p 8472 -b 1K