EX200 Exam QuestionsBrowse all questions from this exam

EX200 Exam - Question 56


SIMULATION -

Your System is going to use as a Router for two networks. One Network is 192.168.0.0/24 and Another Network is 192.168.1.0/24. Both network's IP address has assigned. How will you forward the packets from one network to another network?

Show Answer
Correct Answer:

To configure a Linux system to route packets between two networks (192.168.0.0/24 and 192.168.1.0/24), you need to enable IP forwarding on the system. This ensures that the Linux kernel can forward packets from one network interface to another. This can be achieved in two main steps: enabling IP forwarding in the current session and ensuring that IP forwarding is enabled on subsequent reboots. To enable IP forwarding in the current session, execute the command: echo '1' > /proc/sys/net/ipv4/ip_forward. For the setting to persist across reboots, add the line net.ipv4.ip_forward = 1 to the /etc/sysctl.conf file and then run sysctl -p to apply the changes without rebooting, or store the setting in a dedicated configuration file within /etc/sysctl.d directory (e.g., via echo 'net.ipv4.ip_forward=1' > /etc/sysctl.d/ipforward.conf) and run sysctl -p. These steps will ensure IP forwarding is enabled both immediately and after any future reboots.

Discussion

3 comments
Sign in to comment
QuangTruong
Jun 11, 2021

sysctl -w net.ipv4.ip_forward=1 sysctl net.ipv4.ip_forward

badguy001djh
Aug 6, 2021

Firewalld had been added a new option,--add-forward, in version 0.9.0 .With this option packects from one interface can be forwarded to another interface. https://firewalld.org/2020/04/intra-zone-forwarding

badguy001djh
Aug 6, 2021

By the way, two interfaces must be in the same zone.

syed2020
Aug 12, 2022

If you want your change to survive the reboot, insert below line vi /etc/sysctl.conf net.ipv4.ip_forward=1 reboot the machine and check cat /proc/sys/net/ipv4/ip_foward

wizojlo
Mar 6, 2024

Directly editing sysctl.conf is not recommended anymore, configs now go to /etc/sysctl.d directory. echo 'net.ipv4.ip_forward=1' >> /etc/sysctl.d/ipforward.conf sysctl -p reboot sysctl net.ipv4.ip_forward (to verify; should return a value of 1)