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.

Sorry if this sounds a bit muddled; I am fairly new to networking. My goal is to have two or more subnets on one network. When I add a new server to the network (a virtual machine), I want to be able to have an external application run a command on the server that tells it which subnet to get on. To do do this, I believe that I must specify multiple subnets in my dhcpd.conf file on my router, each with its own private IP:

ddns-update-style none;
default-lease-time 600;
max-lease-time 7200;

subnet 192.168.0.0 netmask 255.255.255.0 {
use-host-decl-names on;
option routers 192.168.0.1;
option domain-name-servers 10.15.1.40;
range 192.168.0.2 192.168.0.250;
}
subnet 192.168.1.0 netmask 255.255.255.0 {
use-host-decl-names on;
option routers 192.168.1.1;
option domain-name-servers 10.15.1.40;
range 192.168.1.2 192.168.1.250;
}

My question is, how do I tell the new server which of the router's IPs it needs to contact to set up its networking? Is there a configuration file I can edit with a boot script to specify the router IP? As far as I know when there's only one router IP on a switch it gets the router's private IP automagically.

The servers are CentOS 5 and the router is Debian.

share|improve this question
add comment

2 Answers 2

up vote 1 down vote accepted

How would the dhcp server know which network is to the VMs taste, unless you restrict the ranges to only be offered each to certain MAC addresses, Hostnames...

Depending on your VM system, you might also be able to setup multiple virtual bridges/switches and bind a separate dhcp server, or separate interface of one dhcp server, to each...

share|improve this answer
    
solved this with a switch for each subnet and adding new NICs to the router, assigning one to each switch. –  smcg May 9 '12 at 21:23
add comment

You can do this with DHCP user classes. Configure your router to put computers in to subnets based on their user class:

class "firstNet" {  
    match if option dhcp-user-class = "networkOne";  
}

class "secondNet" {  
    match if option dhcp-user-class = "networkTwo";  
}

subnet 192.168.0.0 netmask 255.255.255.0 {
    pool { 
        ...
        allow members of "firstNet";  
    }
}

subnet 192.168.1.0 netmask 255.255.255.0 {    
    pool {
        ...  
        allow members of "secondNet";  
    }
}

...And then have the clients send the user class you want. This particular config will only work for clients that match into one of the two classes, so you may want to include another pool in one or both of the subnets for systems that you haven't configured to work within this schema.

It's not clear exactly how you're going to tell these servers where to look, but if you can get onto the machine, add a line to /etc/dhclient-ethX.conf: (change the X based on which interface you're using)
send user-class "networkOne";

share|improve this answer
    
a few problems with your syntax: "dhcp-user-class" should be "user-class", class names should be in quotes, the allow statement must be in the brackets of a pool{} statement with the ip range –  smcg May 8 '12 at 14:24
    
Indeed, you're correct. Hand-combining from various configs never really goes well. I'll update for posterity. –  NathanG May 8 '12 at 15:44
    
while your solution probably would have worked fine and I gave you +1, I decided not to go with it because it requires too much knowledge of the configurations of the specific images of the servers. –  smcg May 9 '12 at 21:24
add comment

Your Answer

 
discard

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.