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?
Suggested Answer:See explanation below.
echo "1" >/proc/sys/net/ipv4/ip_forward vi /etc/sysctl.conf net.ipv4.ip_forward = 1 If you want to use the Linux System as a Router to make communication between different networks, you need enable the IP forwarding. To enable on running session just set value 1 to /proc/sys/net/ipv4/ip_forward. As well as automatically turn on the IP forwarding features on next boot set on /etc/sysctl.conf file.
NEVER Directly edit sysctl.conf is not recommended, create customised file in the /etc/sysctl.d directory.
echo 'net.ipv4.ip_forward=1' >> /etc/sysctl.d/IP_Forwarding.conf
sysctl --load /etc/sysctl.d/IP_Forwarding.conf
***DO NOT make mistake like others do and use -p because the option -p ONLY works if you edited the /etc/sysctl.conf file which is NOT recommended, so if you use customized file as per above **Highly recommended** then you must use option --load as per above example
confirm by either
sysctl -a | grep ip_forward or
cat /proc/sys/net/ipv4/ip_forward
NOTE:REBOOT is highly recommended but not necessary if you use the above procedure
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)
Your answer is great, however DO NOT use -p if you making customized file because -p reads from the /etc/sysctl.conf file and NOT customized file to read from customized file
use this sysctl --load /PATH_to_fileName - see my answer above
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
A voting comment increases the vote count for the chosen answer by one.
Upvoting a comment with a selected answer will also increase the vote count towards that answer by one.
So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.
Lazylinux
3 months, 2 weeks agosyed2020
2 years, 3 months agowizojlo
9 months agoLazylinux
3 months, 2 weeks agobadguy001djh
3 years, 4 months agobadguy001djh
3 years, 4 months agoQuangTruong
3 years, 5 months ago