LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 09-08-2016, 12:10 PM   #1
mrodmac
LQ Newbie
 
Registered: Mar 2006
Location: Pennsylvania, USA
Distribution: Arch
Posts: 9

Rep: Reputation: 0
dhcpd.conf multiple entries for a single laptop based on subnet


I have a CentOS 7 machine that acts as our dhcp server. It provides addresses to 4 subnets and works great. I have a laptop that needs to travel to each of the 4 offices. I have an entry for the laptop in each of the 4 subnet sections in dhcpd.conf, altering only the hostname (restarting the service with duplicate hostname entries causes errors). The actual hostname of the laptop is 'laptop-1':

Code:
host laptop-1 {
hardware ethernet 00:0f:00:0f:00:b5;
fixed-address 192.168.1.230;
}
--
host laptop-1-B {
hardware ethernet 00:0f:00:0f:00:b5;
fixed-address 192.168.2.230;
}
--
host laptop-1-C {
hardware ethernet 00:0f:00:0f:00:b5;
fixed-address 192.168.3.230;
}
--
host laptop-1-D {
hardware ethernet 00:0f:00:0f:00:b5;
fixed-address 192.168.4.230;
}
My assistant took the laptop to our 'C' office this morning and the dhcp server doled out 192.168.1.230 (main office) as the ip address. Historically I just commented out the subnet entries pertaining to the offices that laptop was not in, but I'd like to find a solution that doesn't require constant editing of the conf file.
 
Old 09-08-2016, 02:38 PM   #2
IsaacKuo
Senior Member
 
Registered: Apr 2004
Location: Baton Rouge, Louisiana, USA
Distribution: Debian Stable
Posts: 2,546
Blog Entries: 8

Rep: Reputation: 465Reputation: 465Reputation: 465Reputation: 465Reputation: 465
I found an example that might be adapted to your situation:

http://serverfault.com/questions/582...dress-in-dhcpd

It's an example dhcpd.conf for isc-dhcp-server (as opposed to dhcp3-server), if that makes a difference for you. The mac address to ip address entries are nested within the subnet brackets, so I think you'll be able to have the same mac address nested in the various subnet sections.

Code:
#
# Sample configuration file for ISC dhcpd for Debian
#

# The ddns-updates-style parameter controls whether or not the server will
# attempt to do a DNS update when a lease is confirmed. We default to the
# behavior of the version 2 packages ('none', since DHCP v2 didn't
# have support for DDNS.)

ddns-update-style none;

# option definitions common to all supported networks...

option domain-name "mf.vu.---";
option domain-name-servers ---.219.80.11, ---.219.80.2, ---.171.22.22;

default-lease-time 2678400;
max-lease-time 2678400;

# If this DHCP server is the official DHCP server for the local
# network, the authoritative directive should be uncommented.

authoritative;

# Use this to send dhcp log messages to a different log file (you also
# have to hack syslog.conf to complete the redirection).

log-facility local7;


# The subnet that shares this physical network

shared-network TOTAL_MF {
 server-name "letta.mf.vu.--";

 subnet ---.219.43.128 netmask 255.255.255.192 {
  option routers ---.219.43.190;
  option broadcast-address ---.219.43.191;

  group {
    host wrt45gl-etika  { hardware ethernet 00:21:29:a1:c3:a1; fixed-address ---.219.43.135; } # MSIE routeris WRT54GL
    # ...
    host saulute        { hardware ethernet 00:21:28:10:f4:16; fixed-address ---.219.43.189;  } # Virtual Qemu PC NIC
  }
 }

 subnet 172.16.43.128 netmask 255.255.255.192 {
  option routers 172.16.43.129;
  option broadcast-address 172.16.43.191;

  group{
    host ligo           { hardware ethernet 08:00:20:7A:E2:70; fixed-address 172.16.43.179;   } #a225 ligo
    # ...
    host vumfsa2        { hardware ethernet 00:80:48:8d:12:f0; fixed-address 172.16.43.140;   } # 118
  }
 }
}
EDIT ADDED: Sorry, I just reread your post more carefully, and I assume this is what you're trying to do already.

Last edited by IsaacKuo; 09-08-2016 at 02:40 PM.
 
Old 09-08-2016, 03:13 PM   #3
mrodmac
LQ Newbie
 
Registered: Mar 2006
Location: Pennsylvania, USA
Distribution: Arch
Posts: 9

Original Poster
Rep: Reputation: 0
Isaac, sorry if my post was not clear. Yes, I already have 4 nested subnet sections in my dhcpd.conf, those excerpts were simply the pertinent info for the laptop in question. It seems, however, the dhcp server is doling out the first mac address match in the config file, which happens to be our main office subnet.
 
Old 09-08-2016, 03:46 PM   #4
IsaacKuo
Senior Member
 
Registered: Apr 2004
Location: Baton Rouge, Louisiana, USA
Distribution: Debian Stable
Posts: 2,546
Blog Entries: 8

Rep: Reputation: 465Reputation: 465Reputation: 465Reputation: 465Reputation: 465
I guess the cleanest solution is to have a different dhcp server for each subnet.
 
Old 09-12-2016, 12:45 PM   #5
mrodmac
LQ Newbie
 
Registered: Mar 2006
Location: Pennsylvania, USA
Distribution: Arch
Posts: 9

Original Poster
Rep: Reputation: 0
Isaac,
Thanks for the reply. Unfortunately I think you may be right, I was looking for an easier way out!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
vlan tagging dhcpd.conf for second subnet in centos rootaccess Linux - Networking 5 02-01-2014 05:48 AM
Delete leases from dhcpd.leases when remove a subnet from dhcpd.conf phongnh Linux - Server 2 10-12-2010 04:49 AM
dhcpd.conf configure for multiple domains quasi3 Linux - Networking 4 12-11-2009 01:06 PM
dhcpd.conf multiple subnet / single physical network configuration kovert Linux - Server 0 09-02-2006 01:14 AM
dhcpd subnet declaration problems in dhcpd.conf vcrispo Linux - Networking 6 07-15-2005 10:32 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 07:30 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration