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?
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?
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.
sysctl -w net.ipv4.ip_forward=1 sysctl net.ipv4.ip_forward
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
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)
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
By the way, two interfaces must be in the same zone.