Lpic 2 Linux Engineer · Free Practice Question Medium
Question 12
- A echo 1 > /proc/sys/net/ipv4/ip_forward && sysctl -w net.ipv4.ip_forward=1
- B sysctl -w net.ipv4.ip_forward=1
- C echo 1 > /proc/sys/net/ipv4/ip_forward && sysctl -p
- D echo 1 > /proc/sys/net/ipv6/ip_forward
Reveal correct answer
Correct answer: C
A. This command first enables IP forwarding by writing '1' to the /proc/sys/net/ipv4/ip_forward file, but it does not persist after a system reboot. The second part of the command attempts to set the net.ipv4.ip_forward parameter using sysctl, but it is redundant and unnecessary.
B. This command enables IP forwarding by setting the net.ipv4.ip_forward parameter using sysctl. However, this change will not persist after a system reboot unless the sysctl configuration is saved.
C. This command first enables IP forwarding by writing '1' to the /proc/sys/net/ipv4/ip_forward file, which is the correct way to permanently enable IP forwarding. The second part of the command uses sysctl -p to apply the changes and make them persistent across reboots.
D. This command attempts to enable IPv6 forwarding by writing '1' to the /proc/sys/net/ipv6/ip_forward file, which is not applicable to the scenario described in the question. The question specifically mentions enabling IP forwarding for IPv4, not IPv6.
Discussion
Think the marked answer is wrong, or have a better explanation? Share it below — comments appear after review.
