Internet Connection Sharing for Linux

The world is slowly becoming a better place, and so today I thought that perhaps the right-click-to-share-my-internet-connection reality had come to Linux. I.e., I was in no mood to manually setup IP Masquerading and a DNS cache and a DHCP server on my Linux box.

I found no useful articles. I swear every one of them was written before Linux kernel version 2.6 was even introduced. Anyways, I use Debian, and I figured out there exist two wonderful packages: ipmasq and dnsmasq.

aptitude install ipmasq dnsmasq

It is then necessary to edit /etc/dnsmasq.conf to enable its built-in DHCP server. That file is well-commented; you shouldn’t have much trouble figuring it out. Note also that dnsmasq keeps current leases in /var/lib/misc/dnsmasq.leases by default. This is configured in /etc/dnsmasq.conf with the dhcp-leasefile directive.

Also, if ipmasq gives you a hard time about your kernel:

FATAL: Module ip_tables not found.
iptables v1.3.6: can’t initialize iptables table `nat’: Table does not exist (do you need to insmod?)
Perhaps iptables or your kernel needs to be upgraded.

…then you need a kernel with ip_tables support. Here is a Gentoo wiki page about building a kernel with iptables support.

UPDATE 2009.03.20

Here’s the kind of idiot’s guide I like to find: ConnectionSharing.

UPDATE 2010.02.17

It seems that a package called firestarter available for both Debian and Ubuntu (and more) also has a fairly painless point-and-click sharing option, but it sounds like having this peacefully coexist with a more sophisticated DHCP setup on the internet network could get painful.


Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s