Rather than "roll your own", you could use one of the purpose-built firewall/
router Linux distributions. (Such may also exist for (Free|Net|Open)BSD.)
I've used both IpCop and Smoothwall; both support various kinds of WAN links,
including USB modems:
http://www.ipcop.org/
http://smoothwall.org/
HTH,
David