# dhcpd with multiple subnet [solved]

## DaviXX

Hi,

I would like to make a dhcp server which can handle multiple subnet sections (subnet XXX.XXX.XXX.XXX netmask 255.255.255.192 { } ), as soon i put a second section subnet, my dhcp server, at restart, say the message below.

my ifconfig as an adress ip and an alias eth0:1 configuration.

there is an option that i have forget ?

(sorry for my bad english, i'm french)

 *Quote:*   

> May  6 09:28:27 [dhcpd] Wrote 0 deleted host decls to leases file.
> 
> May  6 09:28:27 [dhcpd] Wrote 0 new dynamic host decls to leases file.
> 
> May  6 09:28:27 [dhcpd] Wrote 0 leases to leases file.
> ...

 

thanks

----------

## moocha

You need to enclose in a shared-network declaration all subnets that actually share the same physical network. For example, if you have two subnets 192.168.1.0/24 and 192.168.2.0/24, that are both accessible via the same physical interface, you need something like:

```
shared-network mysharednet {

    subnet 192.168.1.0 netmask 255.255.255.0 {

        blah blah blah;

    }

    subnet 192.168.2.0 netmask 255.255.255.0 {

        yada yada yada;

    }

}
```

----------

## Jerri

 *moocha wrote:*   

> For example, if you have two subnets 192.168.1.0/24 and 192.168.2.0/24, that are both accessible via the same physical interface

 

would this include multiple interfaces that are "connected" via iptables or pf?  

I have a router with 4 nic's (3 internal subnets, one external).  I haven't set them up as bridges, I use pf for nat'ing and redirection... however, when it comes to declaring multiple subnets for dhcpd, i'm not sure if they are actually shared or not.. 

Here is a snipped from my dhcpd conf:

```
shared-network LOCAL-NET {

        subnet 192.168.1.0 netmask 255.255.255.0 {

                option routers 192.168.1.1;

                option ntp-servers 192.168.1.1;

                range 192.168.1.100 192.168.1.150;

        }

        

        subnet 192.168.2.0 netmask 255.255.255.0 {

                option routers 192.168.2.1;

                option ntp-servers 192.168.2.1;

                range 192.168.2.10 192.168.2.30;

        }
```

so if subnet 192.168.1.0 is on interface 1 and subnet 192.168.2.0 is on interface 2

and i attach a host to interface 2 and then request an ip address, I get an ip like 192.168.1.101.  This ofcourse is wrong.  it should only be the case if the host was attached to interface 1.  it *should* get an ip like 192.168.2.11.  

I don't know if i'm making any sense... but, what have I got to lose :)

----------

## moocha

If the subnets correspond to different physical interfaces, then the only explanation is that you did something voodoo with your routing / NAT. Note that aliases do NOT count as interfaces, they're just syntactic sugar.

----------

## Jerri

Apparently, it was just a matter of removing the shared-network declaration...

 *Quote:*   

> something voodoo

 

i hate it when i do that :)

----------

## moocha

 *Jerri wrote:*   

> Apparently, it was just a matter of removing the shared-network declaration...

 Well, yes, shared-network must only be used when you have multiple subnets on the same physical interface (but then it must be used). *Jerri wrote:*   

>  *Quote:*   something voodoo 
> 
> i hate it when i do that 

 I was tempted to reply "Don't do it, then" - but the sheer hypocrisy would have probably caused my fingernails to drop off  :Very Happy: . *cue in flashback to the memorable day when I decided that the File System Hierarchy standard was just silly and I would be better off with my own path layout*

----------

