A Linux host will act as a router between two classroom VLANs. You enabled forwarding with:
# sysctl -w net.ipv4.ip_forward=1
Traffic now routes correctly; however, after every reboot the setting reverts to 0. Using only the native sysctl mechanism (no firewall or network-script tweaks), which command sequence both activates IPv4 forwarding immediately and guarantees it remains enabled across future boots?
The sysctl -w command writes the value to the running kernel only; the change is lost at the next restart. To make the parameter persistent, it must appear in a configuration file that systemd-sysctl reads at boot (such as /etc/sysctl.conf or a custom file in /etc/sysctl.d) and then be re-loaded for the current session with sysctl -p. Appending the line
net.ipv4.ip_forward = 1
to /etc/sysctl.conf followed by sysctl -p (or reboot) fulfills both requirements. The other options either manipulate firewall/NAT rules or write directly to /proc, neither of which stores the value in a persistent sysctl configuration file.
Ask Bash
Bash is our AI bot, trained to help you pass your exam. AI Generated Content may display inaccurate information, always double-check anything important.
What does the sysctl command do in Linux?
Open an interactive chat with Bash
Why is the /etc/sysctl.conf file important?
Open an interactive chat with Bash
What is the difference between sysctl and modifying /proc directly?
Open an interactive chat with Bash
CompTIA Linux+ XK0-006 (V8)
Security
Your Score:
Report Issue
Bash, the Crucial Exams Chat Bot
AI Bot
Loading...
Loading...
Loading...
IT & Cybersecurity Package Join Premium for Full Access