如何在 CentOS 7 上可靠地设置 net.core.ipv4.conf.rp_filter = 0?

Jas*_*n R 1 networking sysctl centos7

我想在 CentOS 7 机器上禁用反向路径过滤。我有一个文件/etc/sysctl.d/包含以下内容,试图为我的所有网络接口禁用它:

net.ipv4.conf.all.rp_filter = 0
net.ipv4.conf.default.rp_filter = 0
net.ipv4.conf.enp1s0f0.rp_filter = 0
net.ipv4.conf.enp1s0f1.rp_filter = 0
net.ipv4.conf.enp1s0f2.rp_filter = 0
net.ipv4.conf.enp1s0f3.rp_filter = 0
net.ipv4.conf.ens1f0.rp_filter = 0
net.ipv4.conf.ens1f1.rp_filter = 0
net.ipv4.conf.lo.rp_filter = 0
Run Code Online (Sandbox Code Playgroud)

但是,启动后,alldefault条目仍然设置为 1。我必须在启动系统后手动设置它们,以根据需要将它们设置为 0。同样,如果我通过 停止并重新启动网络systemctl restart network.service,它们将再次重置为 1。

有什么办法可以让这个设置按照我想要的方式进行吗?

Jas*_*n R 5

事实证明,还有另一个目录 ,/usr/lib/sysctl.d/它的内容在启动时应用 sysctl 选项时也会被考虑(按字典顺序),这一事实让我很困惑。有一个现有文件,50-default.conf按字典顺序晚于我的文件,其设置为:

net.ipv4.conf.all.rp_filter = 1
net.ipv4.conf.default.rp_filter = 1
Run Code Online (Sandbox Code Playgroud)

我将我的文件重命名为晚于这个文件并且它有效。