# dhcpcd and requesting option OPTION_6RD (212)

## kiddigital

Hello,

Running a Gentoo box as Router/FW (and other stuff), I use dhcpcd as the DHCP client for requesting my IP-address from my provider.

With dhcpcd as Gentoo's default DHCP client, everything works as excepted for IPv4.

My providers now also provides the ability to set-up an IPv6 6RD tunnel to allow IPv6 traffic. To find out the border routers for the 6RD tunnel, an optional field has to be requested from my providers DHCP server. This field, field 212 called OPTION_6RD, contains the data I need to complete the tunnel set-up.

So, my questions:

1) How do I configure dhcpcd to request this option field?

2) How do I dump the information of this field into either syslog or some other file?

Currently running dhcpcd version 5.2.12 (part of net-misc/dhcpcd-5.2.12)

Any suggestion and examples are welcome.

----------

## truc

I can't check right now, but according to the documentation, dhcpcd should use the file /etc/dhcpcd.conf to adjust the the configuration. and from dhcpcd.conf, it looks like you could use 

```
option <option>

             Requests the option from the server.  It can be a variable to be

             used in dhcpcd-run-hooks(8) or the numerical value.  You can

             specify more options seperated by commas, spaces or more option

             lines.
```

Report back if it that works as expected or not, I'd like to know:)

----------

## kiddigital

 *truc wrote:*   

> I can't check right now, but according to the documentation, dhcpcd should use the file /etc/dhcpcd.conf to adjust the the configuration. and from dhcpcd.conf, it looks like you could use 
> 
> ```
> option <option>
> 
> ...

 Thanks for the reply.

I am familiair with these options, but if you check which options are currently supported by dhcpcd, open OPTION_6RD (212) is not in the list:

```
~ # dhcpcd -V

 -  interface

 -  reason

 -  pid

 -  ifmetric

 -  ifwireless

 -  ifflags

 -  profile

 -  interface_order

    ip_address

    subnet_cidr

    network_number

    ssid

    filename

    server_name

001 subnet_mask

121 classless_static_routes

249 ms_classless_static_routes

033 static_routes

003 routers

002 time_offset

004 time_servers

005 ien116_name_servers

006 domain_name_servers

007 log_servers

008 cookie_servers

009 lpr_servers

010 impress_servers

011 resource_location_servers

012 host_name

013 boot_size

014 merit_dump

015 domain_name

016 swap_server

017 root_path

018 extensions_path

019 ip_forwarding

020 non_local_source_routing

021 policy_filter

022 max_dgram_reassembly

023 default_ip_ttl

024 path_mtu_aging_timeout

025 path_mtu_plateau_table

026 interface_mtu

027 all_subnets_local

028 broadcast_address

029 perform_mask_discovery

030 mask_supplier

031 router_discovery

032 router_solicitation_address

034 trailer_encapsulation

035 arp_cache_timeout

036 ieee802_3_encapsulation

037 default_tcp_ttl

038 tcp_keepalive_interval

039 tcp_keepalive_garbage

040 nis_domain

041 nis_servers

042 ntp_servers

043 vendor_encapsulated_options

044 netbios_name_servers

045 netbios_dd_server

046 netbios_node_type

047 netbios_scope

048 font_servers

049 x_display_manager

050 dhcp_requested_address

051 dhcp_lease_time

052 dhcp_option_overload

053 dhcp_message_type

054 dhcp_server_identifier

055 dhcp_parameter_request_list

056 dhcp_message

057 dhcp_max_message_size

058 dhcp_renewal_time

059 dhcp_rebinding_time

064 nisplus_domain

065 nisplus_servers

066 tftp_server_name

067 bootfile_name

068 mobile_ip_home_agent

069 smtp_server

070 pop_server

071 nntp_server

072 www_server

073 finger_server

074 irc_server

075 streettalk_server

076 streettalk_directory_assistance_server

077 user_class

081 fqdn_name

085 nds_servers

086 nds_tree_name

087 nds_context

088 bcms_controller_names

089 bcms_controller_address

091 client_last_transaction_time

092 associated_ip

098 uap_servers

112 netinfo_server_address

113 netinfo_server_tag

114 default_url

118 subnet_selection

119 domain_search

~ #

```

That brings me to the question if and how can I add an option? (or do I need to dive into the source code?)

----------

## truc

 *kiddigital wrote:*   

> I am familiair with these options, but if you check which options are currently supported by dhcpcd, open OPTION_6RD (212) is not in the list:
> 
> ```
> ~ # dhcpcd -V
> 
> ...

 

I quickly looked at it and it seems the function int make_option_mask(uint8_t *, const char *, int); won't let you ask for 'unsupported options'.

Extending the dhcp_opts array should not be hard though(in dhcp.c). Once it's done, it should be listed in dhcpcd -V and you can do (re)configure your IPv6 tunnel if necessary from within dhcpcd hook script (see DHCPCD-RUN-HOOKS( :Cool:  )

That said, I don't really see why every options should be listed in the source code? This doesn't really allow to easily do what you want . May be some other DHCP client doesn't have this restriction?

EDIT: it looks like it's possible with the ISC DHCP client:

```
option blah code 212 = ip-address ;

request blah;

```

 *Quote:*   

> tcpdump: listening on wlan0, link-type EN10MB (Ethernet), capture size 65535 bytes
> 
> 12:07:20.003686 IP (tos 0x10, ttl 128, id 0, offset 0, flags [none], proto UDP (17), length 328)
> 
>     0.0.0.0.68 > 255.255.255.255.67: [udp sum ok] BOOTP/DHCP, Request from f0:7b:cb:54:a7:f1, length 300, xid 0x8a5c4b0e, Flags [none] (0x0000)
> ...

 

----------

## kiddigital

(Partially) Solved my problem by switching from 'dhcpcd' to 'dhclient'.

Using the following 'dhclient.conf' (in /etc/dhcp):

```
option option_6rd code 212 = { integer 8, integer 8, integer 16, integer 16, integer 16, integer 16, integer 16, integer 16, integer 16, integer 16, array of ip-address };

interface "eth2" {

        send host-name "<somename>";

        hardware ethernet <some MAC address>;

        request subnet-mask, broadcast-address, time-offset, routers, domain-name, domain-name-servers, host-name,

                option_6rd;

}
```

You can see that option 212 is being defined and then requested by dhclient for eth2.

Don't forget to set:

```
modules_eth2="dhclient"
```

In /etc/conf.d/net to tell the system to use dhclient instead of the default dhcpcd  :Smile: 

(Now I have another issue with dhclient, see other thread)

----------

## salahx

You might be interested to know I wrote an openrc script for 6rd. It doesn't support the DHCP stuff, unfortunately,  but its not hard to use either.

----------

## UberLord

dhcpcd has had 6rd support since 5.5.0

Although the option is called sixrd as shell doesn't allow a variable to start with a number.

----------

