LPIC-2 Exam 202 (Linux Engineer) — Question 32
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?
Answer options
- 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/sysct1.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
Correct answer: C
Explanation
The correct answer is C because modifying /etc/sysctl.conf ensures that the setting is applied at boot time when the system processes the sysctl settings. Options A and B are incorrect as they only apply to user sessions and do not affect system-wide settings. Options D and E are also incorrect since they do not use the correct method for making kernel parameters persistent across reboots.