Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

How do setup dhcpd.conf so that all clients connected to NIC 1 will have 192.168.2.x IPs and all clients connected to NIC 2 gets 192.168.3.x IPs and all with netmask 255.255.248.0.

My current dhcpd.conf config file:

option subnet-mask 255.255.248.0;

subnet 192.168.0.0 netmask 255.255.248.0 {
    option routers 192.168.2.10;
    option broadcast-address 192.168.2.255;
    option subnet-mask 255.255.248.0;
    option domain-name-servers 192.168.2.10;
    range 192.168.2.30 192.168.2.250;
}

subnet 192.168.0.0 netmask 255.255.248.0 {
    option routers 192.168.3.10;
    option broadcast-address 192.168.3.255;
    option subnet-mask 255.255.248.0;
    option domain-name-servers 192.168.3.10;
    range 192.168.3.30 192.168.3.250;
}

host host1 {
    hardware ethernet xxxxxxxxxxxxxx;
    fixed-address 192.168.2.10;
}

host host2 {
    hardware ethernet xxxxxxxxxxxxxx;
    fixed-address 192.168.3.10;
}
share|improve this question
    
Also, use the "code" function next time you post, well, code. That will force it to be rendered in a monospaced font, and as such, will be much easier for us to read. –  EEAA Nov 21 '09 at 6:38
    
:) Thanks, Zoredache. –  EEAA Nov 21 '09 at 6:50
    
Also good to add a tag for your OS; there is more than one DHCP vendor. –  Jimmy Shelter Nov 21 '09 at 11:27
add comment

2 Answers

Your dhcpd.conf file is correctly set up, but your subnets are badly defined. You can not use a 21 bit netmask (255.255.248.0) with your numbering scheme. If you use a 24 bit mask (255.255.255.0) instead it should work.

With a 21 bit mask:

Address:    192.168.2.0           11000000.10101000.00000 010.00000000
Address:    192.168.3.0           11000000.10101000.00000 011.00000000
Netmask:    255.255.248.0 (/21)   11111111.11111111.11111 000.00000000
                                                          ^^^

Here, the ".2" and ".3" is outside the netmask, and is therefore not included in the subnet definitions.

With a 24 bit mask:

Address:    192.168.2.0           11000000.10101000.00000010.00000000
Address:    192.168.3.0           11000000.10101000.00000011.00000000
Netmask:    255.255.255.0 (/24)   11111111.11111111.11111111.00000000
                                                         ^^^

Now the ".2" and ".3" is inside the netmask, and is therefore part of the subnet definitions.

share|improve this answer
add comment

There are a few ways to go at this. The easiest, but not necessarily the best way is to run two different dhcpd processes, each with its own config file and each set to listen on a specific interface:

dhcpd -cf /etc/dhcpd-network1 eth0
dhcpd -cf /etc/dhcpd-network2 eth1

That's pretty messy, though. The proper way to do this is to have a dhcp relay on your network. Most of the time, this happens on the router via a "ip helper" command. In this setup, the router intercepts the dhcp requests and forwards them onto the server specified in the "ip helper" command. Since the dhcp server knows the subnet from which the router fowarded the request, it is able to give out a lease from the proper pool.

If this isn't an option for you, though, I'm afraid you're stuck with the first option.

Edit:

There's a possibility that you may be able to use just a single dhcpd daemon with multiple pools. Theoretically, dhcpd should know what IP address each interface is on and give out leases accordingly. Unfortunately I don't have an easy way to test this currently, so it may not be correct at all.

share|improve this answer
1  
You shouldn't have to do anything special. By default the DHCP server should do the right thing. –  Zoredache Nov 21 '09 at 6:49
add comment

Your Answer

 
discard

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