问题
在 RHEL 7 服务器上重新启动后,sysctl 参数未生效。
在重新启动服务器之前禁用参数“net.ipv4.conf.all.forwarding”。
# cat /proc/sys/net/ipv4/conf/all/forwarding 1
# sysctl net.ipv4.conf.all.forwarding=0 net.ipv4.conf.all.forwarding = 0
# cat /proc/sys/net/ipv4/conf/all/forwarding 0
#cat /etc/sysctl.conf|grep net.ipv4.conf.all.forwarding net.ipv4.conf.all.forwarding = 0
# shutdown -r now
# cat /proc/sys/net/ipv4/conf/all/forwarding ### Gets enabled after reboot. 1
on It Road.com
解决方案
RHEL 7 有一个名为“tuned”的服务,它有助于创建自定义配置文件,它会覆盖 /etc/sysctl.conf 文件中设置的“sysctl”值,因为“tuned”服务将在“sysctl”服务之后启动。
使用以下任一方法在 RHEL/CentOS 7 服务器上定义内核参数。
- 检查受影响服务器中的活动 tuned配置文件。
# tuned-adm active Current active profile: virtual-guest
- 导航到相应的优化配置文件目录并验证有问题的 sysctl 内核参数是否使用任何替代值定义。
# cd /usr/lib/tuned/virtual-guest # cat tuned.conf # # tuned configuration # [main] include=throughput-performance [sysctl] net.ipv4.conf.all.forwarding = 1
如果是,那么有两个选项可以在重新启动后修复不正确的 sysctl 内核参数。
a) 删除调整配置文件中的条目,以便“/etc/sysctl.conf”值生效。
# cd /usr/lib/tuned/virtual-guest # cat tuned.conf # # tuned configuration # [main] include=throughput-performance [sysctl]
b) 否则,删除“/etc/sysctl.conf”中的条目,这将使调整后的值在重新启动后保持不变。
# cat /etc/sysctl.conf | grep net.ipv4.conf.all.forwarding #
在这种情况下,请确保我们在调整后的配置文件中存在该参数。
# cd /usr/lib/tuned/virtual-guest # cat tuned.conf # # tuned configuration # [main] include=throughput-performance [sysctl] net.ipv4.conf.all.forwarding = 0
日期:2020-09-17 00:12:07 来源:oir作者:oir