yes that is very nerdy, martian, but there is of course lots of help online. You can even get a distro thats already set up for this:
List of router or firewall distributions - Wikipedia, the free encyclopedia
Also, don't forget that the gateway computer would need a second NIC to connect to your modem.
Personally, I just use a router with Linux custom firmware for the performance boost and features like bandwidth monitoring and configurable firewall rules.