LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   DHCP for 2 subnets (https://www.linuxquestions.org/questions/linux-networking-3/dhcp-for-2-subnets-512113/)

omlex 12-19-2006 09:00 PM

DHCP for 2 subnets
 
Hi All,

I would to know how can I setup a DHCP server that will hosts two IP subnets (10.13.x.x. and 192.168.x.x) Is it possible? I only have 1 nic card which has 10.13.1.1 IP address but also I want the 192.168.x.x block can access this DHCP server.

Thanks in advance!

omlex 12-19-2006 09:01 PM

BTW, kindly post the exact dhcpd.conf file if possible.

Thanks again.

coolb 12-20-2006 01:03 PM

dhcp relay agent

ninjaz 12-20-2006 01:27 PM

What kind of networking equipment do you use? In Cisco there is a command called "ip helper" where you can point the vlan to the dhcp/dns server. Or you could dual home it.

abakali 12-20-2006 01:38 PM

Quote:

Originally Posted by omlex
Hi All,

I would to know how can I setup a DHCP server that will hosts two IP subnets (10.13.x.x. and 192.168.x.x) Is it possible? I only have 1 nic card which has 10.13.1.1 IP address but also I want the 192.168.x.x block can access this DHCP server.

Thanks in advance!

##########

Here is example

ddns-update-style interim;
dynamic-bootp-lease-length 86400;
max-lease-time 604800;
default-lease-time 604800;

subnet 10.0.0.0 netmask 255.255.254.0 {
option routers 10.0.0.1;
option subnet-mask 255.255.254.0;
option broadcast-address 10.0.1.255;
option nis-domain "xyz.net";
option domain-name "xyz.net";
option domain-name-servers 10.0.0.1;
option time-offset -18000;
authoritative;
option ntp-servers 10.0.0.1;
option netbios-name-servers 10.0.0.1;
option netbios-node-type 2;
range 10.0.0.80 10.0.0.100; }

subnet 192.168.5.0 netmask 255.255.255.0 {
option routers 192.168.5.1;
option subnet-mask 255.255.255.0;
option broadcast-address 192.168.5.255;
option nis-domain "xyz.net";
option domain-name "xyz.net";
option domain-name-servers 192.168.5.1;
option time-offset -18000;
authoritative;
option ntp-servers 192.168.5.1;
option netbios-name-servers 192.168.5.1;
option netbios-node-type 2;
range 192.168.5.50 192.168.5.220;
}

farslayer 12-20-2006 01:41 PM

The two responses citing dhcp-relay and Ciscos ip helper are spot on for this task. either putting a machine with dhcp-relay on the segment that needs addressing, or configuring your routing equipment to forward those requests will work. Other manufacturers have a similar command to the one Cisco provides so their routers should be able to forward those requests as well.

I had two DHCP servers handing out addressing for 15 different subnets on our network at my last job.. was nice to be able to handle all DHCP config from a single location.

xjlittle 12-20-2006 01:53 PM

Quote:

Originally Posted by farslayer
The two responses citing dhcp-relay and Ciscos ip helper are spot on for this task. either putting a machine with dhcp-relay on the segment that needs addressing, or configuring your routing equipment to forward those requests will work.

Neither one of those responses, I don't believe, is what the OP asked for. He asked for a DHCP configuration which is obviously for a Linux box.

Abakali answered him correctly. I would only add that since he has one nic he will need to multihome it. In case you don't know how omlex the command is this:

Code:

ifconfig eth0:0 192.168.5.x netmask 255.255.255.0 up
Note that 1)this is not a permanent way for the secondary ip and 2)the ip address that I used is based on abakali's dhcp configuration. Consult your distro's documentation to find out how to make it permanent.

hth

farslayer 12-20-2006 02:24 PM

Without the dhcp relay or the ip helper there's no way for a broadcasted dhcp request to cross subnets.. he would in fact need a combination of the config and the relay to make it work properly. So the OP got both parts needed to solve his query. the config was not there when I read the original responses.. so I did not reference it in my reply. Ahh overlapping postings

Since I was handing out addresses for 15 subnets from a machine with a single NIC that was not multi-homed the answer is not incorrect.. The network topology would dictate the method needed to make it work properly.

I'm not sure how a multi-homed NIC is going to hand out IP addresses to two separate subnets....

DHCPD------(subnet1_10.X.X.X)-------<ROUTER1>-------(subnet2_192.X.X.X)

for this topology, either ROUTER1 needs to forward the DHCP requests to the DHCP server or there needs to be a machine with a DHCP Relay agent on it in Subent2. Workstations in subnet1 are in the same network segment as the DHCP Server so their broadcasted requests will go directly to the server.

True this is all speculation without knowing the topology of the OPs' network, but this configuration is pretty standard.

omlex 12-20-2006 08:03 PM

Hi All,

Actually, my idea will be like this:

10.13.x.x------>|ROUTER ---DHCP server
192.168.x.x ----^

(shared-network 10.13.x.x and 192.168.x.x)

I'm thingking of using the mac address, however any other ideas are appreciated.

Windchaser 12-20-2006 08:24 PM

Wouldn't you need to use vlans to accomplish this. Your network switch would assign specific vlans to individual ports and then forward the DHCP request to the DHCP server with the specific vlan specified. The test network I manage has 21 vlans defines. In my case I am using a Windows 2003 server as my DHCP server (company is a Microsoft house) and that servers uses scopes which correspond to each vlan. The configuration for the DHCP server above looks correct with the exception of any information pertaining to the vlan assignments. Unfortunately I don't have enough experience using Linux base DHCP servers to be able to give you the specifics for adding the vlan specific information to the configuration.

farslayer 12-20-2006 08:57 PM

* You would need a switch that understands Vlans,
* You would have to preconfigure the Clients NIC for which vlan they would be on. Otherwise how could they specify which IP range they wanted ? (more complexity and yes this could be done.. but lets walk before we try to run.. )
* The router would need to be capable of a multihomed interface so it could talk to the clients in oth vlans
* The router would need to forward dhcp requests to the DHCP server using a function such as 'ip helper'

So once you accomplish all of that, of course it would work.. and no the DHCP server doesn't need to know squat about vlan assignments it will issue an IP address based on the IP address of the segment the request originated from. So a scope for each vlan as the previous poster said..

an easier configuration that wouldn't require vlans would be, ..

10.13.x.x----(router1)-----192.168.x.x------(router2)----172.16.x.x---<DHCP server>

Or if you had a router that contained multiple (more than 2) interfaces, you could setup three segments off the same router.

Code:


10.13.x.x----(router1)-----192.168.x.x
                |
            172.16.x.x
                |
            <DHCP Server>

All that being said the simplest network topology that would work was the one in my original post..
Two segments, the dhcp server lives on one of them requests from the second segment are forwarded to the first..

<DHCP Server>------(subnet1_10.X.X.X)-------<ROUTER1>-------(subnet2_192.X.X.X)



So hows it going to be ?

roreru 03-04-2007 06:41 PM

Quote:

Originally Posted by omlex
Hi All,

I would to know how can I setup a DHCP server that will hosts two IP subnets (10.13.x.x. and 192.168.x.x) Is it possible? I only have 1 nic card which has 10.13.1.1 IP address but also I want the 192.168.x.x block can access this DHCP server.

Thanks in advance!

I am not sure if you got the answer but enclosing the two subnet declarations in shared-network, open and close brackets will do the job


All times are GMT -5. The time now is 04:20 PM.