realmar / DHCPv6-Client-Android

Get an IPv6 address using DHCPv6. Be future-proof.
Other
44 stars 14 forks source link

Old process of 'dhcp6c' prevents getting a new IPv6 address` #1

Closed LGA1150 closed 7 years ago

LGA1150 commented 8 years ago

Sometimes the client is not working, even if I perform a 'manually invoke'. I tried executing dhcp6c manually in terminal with command dhcp6c -c /etc/wide-dhcpv6/dhcp6c.conf -dDf wlan0 , and I got this error

dhcp6_ctl_init: bind(control sock): Address already in use
client6_init: failed to initialize control channel

If I kill the old process with command busybox killall dhcp6c , it will work.

So the workaround may be killing dhcp6c process before executing a new one.

realmar commented 8 years ago

Thank you for your Issue!

To acquire an ipv6 address the app checks if the dhcp6c process is running, if that's the case it will use the "communicator binary" dhcp6ctl to signal the dhcp client that it should get a new ipv6 address.

Although this does not always work, therefore the app first deletes /data/misc/dhcp/dhcp6c_duid in order for the dhcp client to get a new address.

For reference see: GetIPv6Address.java and SUCalls.java The named methods are: start_dhpv6c_process, send_signal_to_client_process and check_process

Please try exactly that:

# if manually invoke does not work

# first become root
su

# verify that the dhcp6c process is running:
# also check if there are multiple dhcp6c processes running (if this is the case it wont work, there should only be one at a time)
ps | grep dhcp6c

# if yes then delete the duid file:
rm -rf /data/misc/dhcp/dhcp6c_duid

# and now invoke the communicator binary:
/system/bin/dhcp6ctl -C start interface wlan0

If nothing work you could also delete all leases (rm -rf /data/misc/dhcp) and try again (with dhcp6ctl).

bogdap commented 7 years ago

Generating a DUID so often is a bad ideea IMHO. It goes against every recommendation in rfc 3315. It makes this client almost unusable in any v6 environment. The DUID is the echivalente of MAC in a v4 environment. Imagine a v4 network where every host is changing its mac address after every renew.

realmar commented 7 years ago

I now have read the DUID definitions of the rfc3315 and think that your are right. I will adapt my app accordingly.

About the the initial issue: in the current version of the app, the dhcp client will be restarted every time you connect to a wifi. (not using the communicator binary)

realmar commented 7 years ago

@bogdap could you please elaborate further where I generate the DUID.

Here in GenerateClientConfig.java I generate an ia-na ID, but as far as I understand this has that nothing to do with the DUID. The DUID is automatically generated by the wide-dhcpv6 client.

Feel free to open again.

bogdap commented 7 years ago

Although this does not always work, therefore the app first deletes /data/misc/dhcp/dhcp6c_duid in order for the dhcp client to get a new address.

The DUID is automatically generated by the dhcp client. From my experience with the wide-dhcpv6 client included in pfsense (freebsd based), once generated the dhcp client uses the same DUID stored in dhcp6c_duid file. Deleting this file forces the client to generate a new one.

realmar commented 7 years ago

Ah I see. This happens every time the client requests a new IP. I will remove this.

realmar commented 7 years ago

Fixed in version 1.5.4 (28) see #5

LGA1150 commented 7 years ago

BTW, is it possible to make DHCPv6 part of LineageOS even though AOSP doesn't support?

realmar commented 7 years ago

@LGA1150 Well, you have to ask that the guys of LineageOS if they want/intend to include DHCPv6 in their ROM. (This is not for me to decide)