Add Option 125 into dhclient.conf

Hi, experts:
I download the DHCP client source code from "http://www.isc.org/index.pl?/sw/dhcp/".
I want to use DHCP Option 125 to get vendor-specific information.  ( Device < = = > Gateway )
A DHCP request is sent from the Device that contains the Device Identity to the Gateway. So the Gateway can get the Device Identity.
A DHCP response is sent from the Gateway that contains the Gateway Identity to the Device. So the Device can get the Gateway Identity.
I want to get the &#28;Gateway Identity&#29; and save it into file. So I can read this information at other application. I have already asked this question in  DHCP Forum, but I still don't get the help.
What should I do?
Could anyone give me a sample configuration showing use of options 124/125?
Thank you.
TKDAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Artysystem administratorCommented:
man dhclient-script
man dhclient-options

OK. Let's say on _server_ site you are using ISC DHCPd and define some option like:

option space local;
option local.gw-id code 101 = string

subnet 172.16.1.0 netmask 255.255.255.0 {
  range 172.16.1.110 172.16.1.120;
  option routers 172.16.1.100;
  vendor-option-space local;
  option local.gw-id "FreeBSD";
}


1) On _client_ side create /etc/dhclient.conf:
[cut]
option space local;
option local.gw-id code 101 = string;
option local-encapsulation code 124 = encapsulate local;

request local.gw-id;
[cut]

2) /etc/dhclient-up-hooks:
[cut]
enc > /tmp/variables.txt
[cut]

3) chmod +x /etc/dhclient-up-hooks

4) Release IP (run from local console): dhclient -r
5) Obtain IP: dhclient eth0
6) View /tmp/variables.txt
Among other options you will see:

new_vendor_encapsulated_options=65:7:46:72:65:65:42:53:44
 
OK, that's format from RFC: http://www.networksorcery.com/enp/rfc/rfc3925.txt

65 = 101 - vendor Id
7 - data length
46:72:65:65:42:53:44 - ASCII HEX "FreeBSD"

Read the above manuals - everything is there.
Artysystem administratorCommented:
Oops, thing go even better when you define correct /etc/dhclient.conf
With the above server config and this dhclient.conf:

option space local;
option local.gw-id code 101 = string;
vendor option space local;
request local.gw-id;


I've got this variables:
old_subnet_mask=255.255.255.0
new_vendor_encapsulated_options=65:7:46:72:65:65:42:53:44
old_domain_name_servers=212.122.1.2 212.122.1.201
old_broadcast_address=172.16.1.255
old_expiry=1202829379
new_subnet_mask=255.255.255.0
new_ip_address=172.16.1.117
new_network_number=172.16.1.0
new_local_gw_id=FreeBSD
old_dhcp_rebinding_time=525
old_dhcp_message_type=5
new_expiry=1202829982
new_dhcp_lease_time=600
new_dhcp_server_identifier=172.16.1.100
new_dhcp_renewal_time=300
LANG=ru_RU.UTF-8
new_routers=172.16.1.100
new_domain_name_servers=212.122.1.2 212.122.1.201
old_dhcp_server_identifier=172.16.1.100
new_dhcp_message_type=5
old_ip_address=172.16.1.117
old_vendor_encapsulated_options=65:7:46:72:65:65:42:53:44
old_dhcp_renewal_time=300
old_dhcp_lease_time=600
new_dhcp_rebinding_time=525
new_broadcast_address=172.16.1.255
old_network_number=172.16.1.0
old_routers=172.16.1.100

The good news is:
new_local_gw_id=FreeBSD

Now vendor attribute is decapsulated and named with standard naming notation as described in 'man dhclient-script' section BOUND

TKDAuthor Commented:
Hi, Nopius:
In my ubuntu linux, it doesn't have 'dhclient-up-hooks'. It contains:
/etc/dhcp3/dhclient-enter-hooks.d
   debug ntpdate
/etc/dhcp3/dhclient-exit-hooks.d
   debug
What should I do?
SolarWinds® IP Control Bundle (IPCB)

Combines SolarWinds IP Address Manager and User Device Tracker to help detect IP conflicts, quickly identify affected systems, and help your team take near instantaneous action. Help improve visibility and enhance reliability with SolarWinds IP Control Bundle.

Artysystem administratorCommented:
create this file and make it executable
TKDAuthor Commented:
I only know that the Gateway supports DHCP option 125. I don't know how it defines options.
In the following statements:
-------------------------------------------------------------------
option space local;
option local.gw-id code 101 = string;
option local-encapsulation code 124 = encapsulate local;
request local.gw-id;
-------------------------------------------------------------------
You define a space named 'local' and define a option name local.gw-id and its code is 101.
So when execute 'request local.gw-id;', it means request dhcop option 101, right???
And this 'local' space contains the option name 'local-encapsulation' and its code is 124. Right???
Artysystem administratorCommented:
Oops, I've started Ubuntu Live CD and it has a different /etc/ layout.

On Ubuntu dhclient is compiled with different options (I've tested on Fedora), also hooks are different... I should try it on Ubuntu now.
TKDAuthor Commented:
I have a question what is meaning of 'enc' in 'enc > /tmp/variables.txt' statement.
TKDAuthor Commented:
I need to try :
option option-125 code 125 = string;
option option-125
7d:23:00:00:0d:e9:
1e:
01:0b:49:49:49:38:32:30:36:32:33:
02:6:38:32:30:36:32:33:03:
03:41:44:56;
request option-125;
Right???
Artysystem administratorCommented:
> So when execute 'request local.gw-id;', it means request dhcop option 101, right???

My above dhclient.conf is incorrect.

> You define a space named 'local' and define a option name local.gw-id and its code is 101.

Yes.

> And this 'local' space contains the option name 'local-encapsulation' and its code is 124. Right???

No. Option with code 124 encapsulates inside it all options defined in a space 'local'. In my case the only defined is the option with code 101...

What about using 'vendor' option space, I was not correct also. It uses option 43 for encapsulation, but you need 124 and 125.

Also I have no any hardware, that supports option 125 or 124. So I'm using ISC DHCPd and follow generic rfc3925 rules for encapsulating option 125.

That's my last config, it doesn't perform correct decapsulation for vendor sub-options, but you may do it yourself in your script. May be dhclient _can_ perform such decapsulation, but I have no much time to deal with it. Even raw values may be used.

Ubuntu site:

/etc/dhcp3/dhclient.conf (only added or modified lines):

option option-124 code 124 = string;
option option-125 code 125 = string;

# Here we encode option 124 with fake vendor id = ff:ff and sub-option number 2 with the value of "Ubuntu" string, read RFC3925 for more info

send option-124 ff:ff:08:02:06:55:62:75:6E:74:75;

request subnet-mask, broadcast-address, time-offset, routers,
        domain-name, domain-name-servers, host-name,
        netbios-name-servers, netbios-scope, option-125;

/etc/dhcp3/dhclient-enter-hooks.d/env file (create it):
--[cut]--
env  > /tmp/variables.txt
--[cut]--

now release your dhcp address and obtain it again and see in /tmp/variables.txt
Look for new_ prefixed vars. As for me, I have:

new_option_125=ff:ff:9:1:7:46:72:65:65:42:53:44

That's the way I have encapsulated vendor option with vendor if ff:ff suboption numer 1 stringvalue "FreeBSD".




Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Artysystem administratorCommented:
What about 'enc', Ive misspelled, should be 'env'...
All received options are received as shell variables.
TKDAuthor Commented:
Ok~ I will try it!
TKDAuthor Commented:
Hi,
----------------------
/etc/dhcp3/dhclient-enter-hooks.d/env file (create it):
env  > /tmp/variables.txt
----------------------
It means:
I need to create a file In /etc/dhcp3/dhclient-enter-hooks.d/ directory and write the content "env
> /tmp/variables.txt", what is the file name???
Another question is
How does the DHCP client know which file to execute???

Artysystem administratorCommented:
> I need to create a file In /etc/dhcp3/dhclient-enter-hooks.d/ directory and write the content "env
> /tmp/variables.txt", what is the file name???

Yes

> How does the DHCP client know which file to execute???

It's hard coded in dhclient-script to execute every file in that directory

TKDAuthor Commented:
So, the name of file is optional. Thank you.
Artysystem administratorCommented:
Yes, it can have any name, they are executed in alphabetical order.
TKDAuthor Commented:
Hi,
I add the following lines into /etc/dhcp3/dhclient.conf:
----------------------------------------------------------------------
option option-125 code 125 = string;
request subnet-mask, broadcast-address, ....., option-125;
----------------------------------------------------------------------
I also configure the /etc/network/interfaces
----------------------------------------------------------------------
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet dhcp
----------------------------------------------------------------------
After restarting the network (/etc/init.d/networking restart):
I view the /tmp/variables.txt, but I DON'T find any variables about option 125.
Can I say that the Gateway don't support DHCP option 125???
How can I know which DHCP options the Gateway support???
Thank you.
Artysystem administratorCommented:
> After restarting the network (/etc/init.d/networking restart)

You also may run 'dhclient -r' to release IP, then 'dhclient eth0' to get IP.

> I view the /tmp/variables.txt, but I DON'T find any variables about option 125.
Can I say that the Gateway don't support DHCP option 125???

Yes. This option wasn't  sent to you even when you requested it. According to RFC server MUST try to send you requested option (of course it it has it for you).

If you don't believe /tmp/variables.txt run 'tcpdump -s 2000  -w /tmp/dhcp.dump port bootps or bootpc', then release and obtain IP, then stop tcpdump and post the dhcp.dump file here or analyze it yourself with 'wireshark'.

> How can I know which DHCP options the Gateway support???

1) Read the gateway's manual.
2) Search vendor forums.
3) Ask vendor support.
4) You may try to use options 43 and 60 for vendor class identifier, read http://www.faqs.org/rfcs/rfc2132.html


TKDAuthor Commented:
Hi,
Thank you.
Could you tell me how you use ISC DHCPd and configure the configuration file???
I will let DHCPd support DHCP option 125 and use dhclient to send a option-125 request to DHCPd.
Artysystem administratorCommented:
> Could you tell me how you use ISC DHCPd and configure the configuration file???

Here is my working dhcpd.conf with option 125 enabled, just use at as template:

option domain-name-servers y.y.y.y, x.x.x.x;
option option-125 code 125 = string;
default-lease-time 600;
max-lease-time 7200;
authoritative;
ddns-update-style none;
log-facility local7;
subnet 172.16.1.0 netmask 255.255.255.0 {
  range 172.16.1.110 172.16.1.120;
  option routers 172.16.1.100;
  option option-125 FF:FF:09:01:07:46:72:65:65:42:53:44;
}
TKDAuthor Commented:
The vendor says that if I just send option-125 request without any data, the Gateway won't response any thing. So it supports DHCP option 125, but it don't response to the request without any data.
I have a problem to study the DHCP option 125 in RFC 3925.
-----------------------------------
option-code  : OPTION_V-I_VENDOR_OPTS (125)
option-len total length of all following option data in octets.
...
-----------------------------------
What's the meanning of "in octets"???
Is the number should be specified in octal???  or what?
Thank you.
Artysystem administratorCommented:
octets are bytes.
naveenahegdeCommented:
Can some one summarize whole steps of sending device identity as part of option 125 and reading the gateway identity received from gateway.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
DHCP

From novice to tech pro — start learning today.