On a Linux router, packet forwarding for IPv4 has been enabled. After a reboot, the machine no longer forwards IP packets from other hosts. The command:

echo 1 > /proc/sys/net/ipv4/ip_forward

temporarily resolves this issue.

Which one of the following options is the best way to ensure this setting is saved across system restarts?

A. Add echo 1 > /proc/sys/net/ipv4/ip_forward to the root user login script
B. Add echo 1 > /proc/sys/net/ipv4/ip_forward to any user login script
C. In /etc/sysctl.conf change net.ipv4.ip_forward to 1
D. In /etc/rc.local add net.ipv4.ip_forward = 1
E. In /etc/sysconfig/iptables-config add ipv4.ip_forward = 1

题解

直接更改 /proc 目录里的文件,只会影响到内存的内容,并不会将设置存在任何硬盘的设置档内。反过来若是直接设置硬盘的设置档,则可以永久地让设置套用至 /proc 的目录中,例如修改「/etc/sysctl.conf」会影响到「/proc/sys/」。

所以这题答案是选项「C」。