How do I emulate Internet Sharing from the command line?
This could possibly get you part of the way on your journey to the final solution, though it hasn't worked for me so far on mountain lion.  I'd very much like to know what your solution is if you find one!