Turn you Mac into a super router
Hello,
I searched and found that it is possible to turn your Mac into a router. You might have old Mac computers. How about set it up as a router? By this, you can do some research and experiment on that Mac computer, which is really challenging and interesting.
macOS has another name: Unix. It's not Unix-like, such as Linux, etc. It's really a certified Unix. And Unix's most apparent characteristics is that you can do everything by the CLI (command line). Mac has a nice GUI (graphic user interface), but it also has a power CLI - the Terminal.
You guys might ask why a Mac could be turned into a router? What's the basic rationale? To explain this is simple. In the System Preferences > Sharing, there is an option called Internet Sharing. It is right this Internet Sharing that turns your Mac into a router. So it is possible to achieve this goal on Mac in theory. Below I will tell how to enable this function by CLI.
First, you have to run this command to turn on the routing function, also known as packet forwarding function.
sysctl -w net.inet.ip.forwarding=1
However, this would lose function after you reboot your Mac. To enable it on booting, create a file via PICO editor:
/private/etc/sysctl.conf
and write a line:
net.inet.ip.forwarding=1
Done. Now you Mac becomes a router.