Ubuntu – How to setup DHCP-Server interfaces so they are mapped/bridged to each other


I have recently setup a DHCP-Server on an Ubuntu 10.04 server machine. The machine has two interfaces (eth0, eth1). I have the DHCP server setup correctly because computers connecting to the network get a DHCP IP address but they cannot connect to the outside world.

I believe it has to do with the two interfaces being mapped/bridged together. How do I properly map one interface to the other? Is it bridging or mapping?

I see on this page: https://help.ubuntu.com/community/dhcp3-server they do something like

mapping hotplug
    script grep
    map eth1

What does that exactly do?

In other places I see the following:

iface br0 inet static
bridge_ports eth0 eth1

Which is better or more efficient?

Sorry for all the questions, I'm a noob at setting up a DCHP Server.

Thanks for your help.

Best Answer

Edit /etc/network/interfaces to have a section like this:

iface br0 inet static
   bridge_ports eth0 eth1

(This is assuming you are using 192.168.0.x addressses for you dhcp server.) Then you just use br0 instead of eth0 or eth1 when you are doing your configuration file. With this method, you don't need anything fancy in the configuration file to try to connect the two interfaces to each other. You just need a section that tells the DHCP server to run on br0, just like it was one ethernet port. You could use a section something like this for the DHCP server:

subnet netmask {

        option routers        ; #You might have to comment this line out.
        option subnet-mask    ;
        option broadcast-address;
        default-lease-time 86400;
        max-lease-time 86400;

Hopefully that answers your question as you asked it. However, it sounds like maybe you are trying to share internet among multiple computers. You think you need a DHCP server to do that, and so you are trying to set one up. Am I right so far? If so, there should be a simpler solution:
(this solution assumes you get addresses automatically on eth0. If you have to set them manually, this method would still work, but there would be extra steps)
First, shut down all your eth0 and eth1 interfaces. (sudo ifdown ethX if you're using /etc/network/interfaces to manage them, or disconnect in NetworkManager applet if you are using that.) Then edit /etc/network/interfaces and add a section like this (commenting out eth0 or eth1 sections if needed):

iface br0 inet dhcp
   bridge_ports eth0 eth1

then do sudo ifup br0. This should make your ports eth0 and eth1 act just like a networking switch, except that your Ubuntu computer is also plugged into this networking switch. Assuming that you could automatically get addresses on eth0 before, this will be passed on to eth1 computers also.

Let me know how my answer works.