Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I know it is possible to share an internet connection with another pc using ip-forwarding and masquerade.

Is it possible to set up the sharing computer as a DHCP server, so the settings (ip, gateway, dns) get configured for the client automatically?

The current way I do it, is that I setup the client NICs manually to access the internet from the client.

edit: this is the setup i plan to realize


share|improve this question
yes, it is possible. I suggest to edit the question to add some details of your systems and perhaps change it such that you ask how to do it. This would make the question more interesting and useful ... – maxschlepzig Aug 10 '11 at 18:36
I am doing something very similar except I have a WLAN interface in the gateway and a simple switch instead of an AP. You can also run DNS resolver and HTTP proxy on the gateway. I am running log server and torrent client on it too. If you have a full blown PC as your gateway there are lots of thing you can do. You can have centralized passwords with LDAP. Or WPA with certificates. Your own mail server. Anything. – stribika Aug 11 '11 at 18:32
up vote 4 down vote accepted

Yes, you can do that.

You should look into dnsmasq. It is designed to serve this very need.

The default DHCP server on Linux is usually ISC dhcpd. It's possible to make it work in this role, too, but it's a bit more difficult to configure, and it has to be manually configured to get the DNS server integration you get for free with dnsmasq.

share|improve this answer
I second the recommendation for dnsmasq. See also Working DNS-DHCP combo for LAN, How to make a machine accessible from the LAN using its hostname – Gilles Aug 10 '11 at 21:46
I finally got it working. dnsmasq works like a charm and so does my home-network me-happy. Though it was more work than expected once I got into into security. iptables and securing ssh took most of the time. thank u very much. my main resource was wiki.archlinux.org/index.php/Simple_Stateful_Firewall dnsmasq's config is self-explanatory – unR Aug 16 '11 at 20:16

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.