背景
客户说有一个 IP Forwarding Enabled 的漏洞,需要将 echo 0 > /proc/sys/net/ipv4/ip_forward
分析
我们当前系统为Centos 7,当前该参数的值为:
[root@k8s-master harbor]# cat /proc/sys/net/ipv4/ip_forward1
经过查询资料,该值在系统初始的时候为 0, 代表是禁用状态的。
那么什么时候改这个参数了呢?
发现是在安装K8s的时候,设定基础配置的时候,修改的此参数,具体为:
2.1.5 设置网桥,配置转发参数
vi /etc/sysctl.d/99-sysctl.conf
net.ipv4.ip_forward = 1
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
vm.swappiness=0
modprobe br_netfilter
ls /proc/sys/net/bridge
sysctl -p /etc/sysctl.d/99-sysctl.conf

这个时候加上的
那如果不设定这个参数呢? 后面在kubeadm初始化k8s时就会报错:
详见:https://blog.csdn.net/qq_41489540/article/details/114220234
思考
那么对于报的IP Forwarding Enabled 的漏洞,在有K8s 服务的 Centos 中该怎样修复呢?
