Red Hat Certified System Administrator RHCSA · Free Practice Question Medium
Question 41
On ServerB, configure IPv4 packet forwarding to enable the system to forward IPv4 packets between network interfaces. Ensure that this configuration is applied immediately and persists after a system reboot.
-
A
Pass
-
B
Fail
Reveal correct answer
Correct answer: A
Explanation
Answer:
To enable IPv4 packet forwarding and make it persistent across reboots, follow these steps:
Check the Current State of IPv4 Packet Forwarding:
- # sysctl net.ipv4.ip_forward
OR
- # cat /proc/sys/net/ipv4/ip_forward
Explanation: This command checks if IPv4 packet forwarding is enabled. An output of
0means it is currently disabled, while1means it is enabled. If the output is0, proceed with the following steps to enable and persist the setting.
Edit the
sysctl.confFile to Enable Packet Forwarding:- # vim /etc/sysctl.conf
Explanation: The
/etc/sysctl.conffile contains kernel parameter settings that apply at boot. Editing this file makes the IPv4 forwarding setting persistent.
Add the IPv4 Forwarding Setting:
Press
Ito enter insert mode, then add the following line:- net.ipv4.ip_forward=1
Explanation: Adding
net.ipv4.ip_forward=1enables IPv4 forwarding at the kernel level. The1sets it to enabled, while0would disable it.Alternative Command:
Instead of manually editing, you can append the setting to
sysctl.confwith:- # echo "net.ipv4.ip_forward=1" >> /etc/sysctl.conf
Save and Exit the
sysctl.confFile:Press
Escto switch to command mode, then type:wqand pressEnterto save and exitvim.
Apply the Changes Immediately:
- # sysctl -p
Explanation: The
-poption reloads settings from/etc/sysctl.conf, applying any changes immediately without needing a reboot.
Verify IPv4 Packet Forwarding:
- # cat /proc/sys/net/ipv4/ip_forward
OR
- # sysctl net.ipv4.ip_forward
Explanation: Either command verifies that IPv4 packet forwarding is enabled. The output should show
1, confirming the setting is active.
Confirm Persistence Across Reboots:
Reboot the System:
- # reboot
Verification After Reboot:
After the reboot, check the status of IPv4 packet forwarding again:
- # cat /proc/sys/net/ipv4/ip_forward
OR
- # sysctl net.ipv4.ip_forward
Expected Output: The output should show
1, indicating that IPv4 forwarding remains enabled and the setting persisted through the reboot.
Additional Notes:
Understanding
sysctlandsysctl.conf:sysctl: The command configures kernel parameters at runtime. With
-p, it reads settings from/etc/sysctl.conf./etc/sysctl.conf: This file stores persistent kernel settings. Changes here are applied automatically on reboot.
Common Errors and Troubleshooting:
Permissions: Ensure you run all commands with root privileges.
Verifying After Changes: Always verify the forwarding status after making changes to ensure they’re applied successfully.
Discussion
Think the marked answer is wrong, or have a better explanation? Share it below — comments appear after review.
