NOTE: Although this guide should work in most cases, it is not flawless and may require minor modifications to make the process work for your use case. Please do point out corrections and changes.
UPDATE (22-Oct-2018): Since this post still gets lots of hits despite being 6 years old, I have made some revisions to make it compatible with modern times. Major changes include:
- Remove useless information
- Replace ifconfig with ip
- Replace dhcpd with dnsmasq