# How to get custom option on client from ISC DHCP server



## ruchir15 (Mar 11, 2021)

Over ISC-DHCP server I wanted to define a custom DHCP Option, for which I am using below config


```
option imagefile code 224 = ip-address;

subnet 192.168.29.0 netmask 255.255.255.0 {
 range 192.168.29.1 192.168.29.244;
 option imagefile 192.168.29.113;
}
```

I am able to restart DHCP server after above configuration.

However on client I am not able to grab this option. I am expecting to have this information in /var/db/dhclient.leases.em0

I am having a freebsd client.

I also tried to define below config in dhclinet (onclient side )


```
#option imagefile code 224 = ip-address ;
interface "em0" {
  option imagefile code 224 = ip-address;
  request imagefile;
}
```

However my service did not get start correctly .i.e.


```
Starting dhclient.
/etc/dhclient.conf line 12: expecting a statement.
  option
  ^
/etc/dhclient.conf line 13: semicolon expected.
  request
  ^
DHCPREQUEST on em0 to 255.255.255.255 port 67
DHCPACK from 192.168.29.113
bound to 192.168.29.234 -- renewal in 17669 seconds.
```

Kindly help with correct dhclient configuration or if I need to change something on isc-dhcp server to automatically get this custom option on client without defining any config on client


----------



## SirDice (Mar 11, 2021)

ruchir15 said:


> ```
> option imagefile code 224 = ip-address;
> ```


That doesn't look like it's valid. And probably causes the rest to fail too.


----------



## ruchir15 (Mar 11, 2021)

if I define it like


```
interface "em0" {
  request imagefile;
}
```


```
root@test:~ # service dhclient restart em0
Stopping dhclient.
Waiting for PIDS: 3678.
Starting dhclient.
/etc/dhclient.conf line 12: imagefile: unexpected option name.
  request imagefile;
DHCPREQUEST on em0 to 255.255.255.255 port 67
DHCPACK from 192.168.29.113
unknown dhcp option value 0xe0
bound to 192.168.29.234 -- renewal in 16594 seconds.
```


----------



## SirDice (Mar 11, 2021)

What's the purpose of the option? There may already be an option defined for it.


----------



## ruchir15 (Mar 11, 2021)

I need to make client aware of a particular server from where they need to go and grab stuff.
That is why, I was thinking of using a custom DHCP option


----------



## SirDice (Mar 11, 2021)

ruchir15 said:


> I need to make client aware of a particular server from where they need to go and grab stuff.


Maybe you can use this option?

```
option www-server ip-address [, ip-address ...];
             The www-server option specifies a list of WWW servers available
             to the client.  Servers should be listed in order of preference.
```
Taken from dhcp-options(5)


----------



## ruchir15 (Mar 11, 2021)

this works for me


```
lease {
  interface "em0";
  fixed-address 192.168.29.234;
  option subnet-mask 255.255.255.0;
  option dhcp-lease-time 42922;
  option dhcp-message-type 5;
  option dhcp-server-identifier 192.168.29.113;
  option www-server 192.168.29.113;
  renew 5 2021/3/12 03:12:04;
  rebind 5 2021/3/12 07:40:18;
  expire 5 2021/3/12 09:09:45;
}
```

here, dhclient config is required (not getting by just configuring on server)



```
interface "em0" {
  #option image code 224 = ip-address;
  request www-server;
}
```

But does this mean custom options are not supported ?


----------



## lostpacket (Mar 11, 2021)

For custom options both server and client need to know about them, so have to define in both dhclient.conf and dhcpd.conf.


----------



## ruchir15 (Mar 12, 2021)

lostpacket , Yes I have tried define in both files .ie.
dhcpd.conf


```
option imagefile code 224 = ip-address;

subnet 192.168.29.0 netmask 255.255.255.0 {
range 192.168.29.1 192.168.29.244;
option imagefile 192.168.29.113;
}
```

and dhclient.conf


```
#option imagefile code 224 = ip-address ;
interface "em0" {
  option imagefile code 224 = ip-address;
  request imagefile;
}
```

But on client when try to restart it fails with imagefile: unexpected option name


----------



## Jose (Mar 12, 2021)

ruchir15 said:


> ```
> #option imagefile code 224 = ip-address ;
> interface "em0" {
> option imagefile code 224 = ip-address;
> ...


You've commented out the option line by starting it with a hash "#". Remove the hash.

Never mind. I should've read the whole thread.


----------



## ruchir15 (Mar 15, 2021)

so in client if I try below in /etc/dhclient.conf



```
request option-224;
```

I get below value in lease file


```
lease {
  interface "em0";
  fixed-address 192.168.29.88;
  option subnet-mask 255.255.255.0;
  option dhcp-lease-time 42035;
  option dhcp-message-type 5;
  option dhcp-server-identifier 192.168.29.113;
  option option-224 "http://testing.com";
  renew 6 2021/3/13 03:35:22;
  rebind 6 2021/3/13 07:58:03;
  expire 6 2021/3/13 09:25:40;
}
```


However not able get custom-name, which I have configured on server  (.i.e. url): dhcpserver config is like



```
option url code 224 = string;

subnet 192.168.29.0 netmask 255.255.255.0 {
range 192.168.29.1 192.168.29.244;
#option www-server 192.168.29.113;
option url "http://testing.com";

}
```


----------

