LinuxQuestions.org
Visit the LQ Articles and Editorials section
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
 
LinkBack Search this Thread
Old 04-07-2010, 12:33 PM   #1
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,390
Blog Entries: 2

Rep: Reputation: 900Reputation: 900Reputation: 900Reputation: 900Reputation: 900Reputation: 900Reputation: 900Reputation: 900
How does client receive DHCP options


I am contemplating the use of DHCP options as a way of passing host-specific information to hosts that are booting disklessly from a network server. My intention is to have the DHCP client request certain options, and use the reply to configure the diskless hosts accordingly. The theory and rules behind all of this seem well documented on web sites such as die.net. However, the practical application of the protocol seems to be a lot less clear. What I am looking for is an explanation of what (existing, I hope) tool(s) are used, and how they are applied so that I can grab information from the DHCP server, and use it in userspace scripts or other programs. Specifically, my intention is to use a locally defined option that would give a host-specific directory name or filesystem to use by the diskless host to obtain host-specific applications and configuration data.
So far, all of the DHCP client documentation I've found relates to the usual function of assigning IPs, etc. I've looked at dhclient-script on a Redhat system and can't figure out the relationship between it and the dhclient program. Clearly, the script is invoked somehow by dhclient, but I don't understand where the transfer of data received from the server gets into the script. Does dhclient just create a list of exported environment variables the child script then gets access too? What are the rules for how variables are created and what variables are created?
Pointers to online docs explaining this stuff is most welcome.
Thanks.
--- rod.
 
Old 04-07-2010, 03:45 PM   #2
jefro
Guru
 
Registered: Mar 2008
Posts: 10,255

Rep: Reputation: 1256Reputation: 1256Reputation: 1256Reputation: 1256Reputation: 1256Reputation: 1256Reputation: 1256Reputation: 1256Reputation: 1256
Dhcp can do a lot but most of it's ability had never been used.

If you what to set file structure you would have to do that by some other means. Either use mac address or user to select image or set of scripts.

There are usually hand-shake images that show how the request offer works and at what point what gets passed off to what.

See how tftp servers supply files to clients too and see gpxe for some other ideas.

Might repost in a different question. I may not exactly understand what you are trying to do. I am sure you are off base on using dhcp for files. In all the web pages on how to boot net there are very few options that are used.
 
Old 04-07-2010, 04:50 PM   #3
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,390
Blog Entries: 2

Original Poster
Rep: Reputation: 900Reputation: 900Reputation: 900Reputation: 900Reputation: 900Reputation: 900Reputation: 900Reputation: 900
Thanks for your reply.

So far this is what I've discovered, after more digging into DHCP from the client end. The dhclient tool can be used to query the DHCP server. It runs a script 'dhclient-script', which in turn provides hooks to two other scripts which are intended for end-user customization. These are dhclient-enter-hooks and dhclient-exit-hooks. On my RHEL4 system, these did not exist, but when I created them, they were called immediately before and immediately after the dhclient calls for update from the DHCP server. In these scripts, I was able to echo all of the environment variables, and discovered that I saw all of the data that had been acquired from the DHCP server in the form of variables with names as passed from the server, and their attendant values. My exit-hooks script looks like this, so far:
Code:
echo "======================  dhclient exit-hooks =======================" 
echo "Looking for hostname"
for e in `env`; do
    param=`echo $e | cut -d '=' -f 1`
    if [ "$param" = "new_host_name" ] ; then
        hostName=`echo $e | cut -d '=' -f 2`  
        echo HostName = $hostName
    fi
done
echo "=================== done dhclient exit-hooks ======================="
and this is what it prints
Code:
======================  dhclient exit-hooks =======================
Looking for hostname
HostName = xyxyxyxyxyyx
=================== done dhclient exit-hooks =======================
So, this tells me that I can probably set up some custom/local options which will be returned by the DHCP server, and which are host-specific, like all of the other parameters, being keyed to the MAC of the client. Having an option name like 'home_dir' will allow my diskless clients to identify the subdirectory on the shared filesystem which they can access for host-specific applications and data. Now, I just have to figure out how to keep dhclient from going into daemon mode, and instead, simply terminate when the query is complete. Plus, figure out how to provide custom DHCP options from the server. Plus, have the exit-hooks script generate a file that can be sourced by a shell to get to the home directory.

Just to clarify why I'm doing this: I have a number of diskless hosts (VME CPUs) which all boot from a shared NFS root filesystem. They all use the same basic filesystem, with the exception that each must have it's own application and configuration data. Without any local configuration store, there is presently nothing for each CPU to distinguish itself from all of the others, until now that I've come up with this scheme.

--- rod.
 
Old 04-07-2010, 08:12 PM   #4
jefro
Guru
 
Registered: Mar 2008
Posts: 10,255

Rep: Reputation: 1256Reputation: 1256Reputation: 1256Reputation: 1256Reputation: 1256Reputation: 1256Reputation: 1256Reputation: 1256Reputation: 1256
I know what you are working on in part. We load our vme slots like that but each is the same load.

We also use stacked systems that have to be booted pxe like that. I guess I could look at that more closely. I think we send the majority of the OS and then change some folders and files based on the stack number.

Most deals like that have multiple images instead of trying to make the install unique on boot. How hard would it be to make the correct image for each slot and send it that way?

I have looked again at dhcp options. My guess is no one uses most of them for some good reason, but sometimes old things find new life for new uses. http://www.ietf.org/rfc/rfc2132.txt is all the original options that can be sent.

I have never seen any certification book that goes into much detail about more than 8 of those options.

Last edited by jefro; 04-07-2010 at 08:36 PM.
 
Old 04-07-2010, 08:44 PM   #5
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,390
Blog Entries: 2

Original Poster
Rep: Reputation: 900Reputation: 900Reputation: 900Reputation: 900Reputation: 900Reputation: 900Reputation: 900Reputation: 900
It is important to minimize the maintenance associated with upgrades and other changes. Changing one image is a lot easier than changing one hundred, and there is very little time available to make changes without costing time/money. Besides, I'm not crazy about repetitive work. That alone is a huge motivator. Also, I already have a lot of history with vxWorks which I am encouraged to model somewhat closely. There is quite a bit of infrastructure that goes into configuring each CPU, and keeping as much as possible of that is a Good Thing.

--- rod.
 
Old 04-08-2010, 04:18 PM   #6
jefro
Guru
 
Registered: Mar 2008
Posts: 10,255

Rep: Reputation: 1256Reputation: 1256Reputation: 1256Reputation: 1256Reputation: 1256Reputation: 1256Reputation: 1256Reputation: 1256Reputation: 1256
All I can say is dhcp is a very limited tool from my training schools and courses.

I know of no way to adjust file structure or select files or configure (other than network) based on dhcp.

Might repost this in a different question format. Explain that you need to load hundreds of vxworks to vme slots pxe and they need to be configured at boot time based on (my only guess) mac address. Explain what exactly you need to have edited.

On a different tack you could download a standard image that then runs a config script based on mac.

Last edited by jefro; 04-08-2010 at 04:23 PM.
 
Old 04-08-2010, 04:33 PM   #7
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,390
Blog Entries: 2

Original Poster
Rep: Reputation: 900Reputation: 900Reputation: 900Reputation: 900Reputation: 900Reputation: 900Reputation: 900Reputation: 900
I think you misunderstood my objective. All I need to do is pass a string back to the client. The string will be the name of directory in which the host can find the applications and data that are specific to its task. Most of the principles of this are now understood. As always, I'm sure the devil is in the details, but I'm confident that I can there there from here.
--- rod.
 
Old 06-10-2011, 11:38 AM   #8
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,390
Blog Entries: 2

Original Poster
Rep: Reputation: 900Reputation: 900Reputation: 900Reputation: 900Reputation: 900Reputation: 900Reputation: 900Reputation: 900
So, after shelving my problem for a while, I have finally resolved it. I found the dhcp 'site-local' options scheme. After digging through the sketchy manpages and doing a lot of Googling, I finally worked out the necessary incantations on the DHCP server and client ends. I present them here for the sake of completion, and for others who may follow:
On the DHCP server end, in dhcpd.conf:
Code:
#===================================================
#  Site-local options: 
#  Two variables that can be picked up by DHCP clients 
#  to load appropriate applications
#
option mysite-server code 224 = text;
option mysite-app code 225 = text;
#===================================================

host myhost02 {
        hardware ethernet 00:D0:69:41:89:03;    
        fixed-address 192.168.0.2;
        option host-name myhost02;
        option mysite-server "192.168.0.1:/nfsshare";
        option mysite-app "/some/dir/to/my/app";
}
and on the client, in dhclient.conf:
Code:
#===================================================
#  Site-local options: 
#  Two variables that are issued by the DHCP server 
#  to define host-specific applications
#
option mysite-server code 224 = text;
option mysite-app code 225 = text;
#===================================================
request subnet-mask, broadcast-address, time-offset, routers,
        domain-name, domain-name-servers, domain-search, host-name,
        netbios-name-servers, netbios-scope, interface-mtu,
        rfc3442-classless-static-routes, ntp-servers,
        mysite-server, mysite-app;
and in the client enter-hooks &/or exit-hooks script(s):
Code:
# Customize as appropriate. Note prefix 'new_' on option keywords.
# Use '$reason' to make appropriate choices for use of variables.
for i in reason new_mysite_server new_mysite_app ; do
    echo $i=\'${!i}\' >> /tmp/dhcp_options.mysite
done
See the related manpages for details:
dhclient(8), dhcp-options(5), dhcpd(8), dhcpd.conf(5), dhclient.conf(5)

Hope this eventually helps someone. Took me a pile of head-scratching to put it together.
--- rod.
 
1 members found this post helpful.
  


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
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Linux DHCP client unsuccessful on a windows DHCP served network tom1080 Linux - Newbie 1 12-16-2009 11:37 AM
How to receive DHCP broadcast messages? kornerr Programming 1 03-11-2009 02:31 AM
Wireless Nick doesn't receive IP from DHCP 3azz Fedora 2 09-27-2008 07:45 PM
Force DHCP To Refuse Clients A DHCP Lease Depending On Client MAC Address blackfish Linux - Server 3 08-17-2007 12:54 AM
XP Pro Build 2600/sp1 v.1105 DHCP Client to Redhat 8.0 DHCP Server - Problems atomant Linux - Networking 5 06-28-2003 11:24 AM


All times are GMT -5. The time now is 09:15 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration