NetworkConfiguration / dhcpcd

DHCP / IPv4LL / IPv6RA / DHCPv6 client.
https://roy.marples.name/projects/dhcpcd
BSD 2-Clause "Simplified" License
337 stars 109 forks source link

Multicast Solicit messages to relaying neighbors #122

Closed mahboobkarimian closed 2 years ago

mahboobkarimian commented 2 years ago

AFAIK dhcpcd wants to unicast solicit messages directly to a server whose address previously was obtained by waiting for a RA message from a router in response to an RS message of dhcpcd. But, imagine a scenario like ... INTERNET_ROUTER <---> RELAY_NODE <---> CLIENT, in which the client is connected to a relay node, and

Then the client should multicast the message for All_DHCP_Relay_Agents_and_Servers, because it can't receive any RA messages from INTERNET_ROUTER. This is a common case in mesh networks. When a relay agent receives a Solicit message, it acts as a relay and forwards the requests to the server, and also it forwards the reply to the client.

But I couldn't find any combination of configuration options for this in dhcpcd. In fact, except for the INFORM message by including the inform6 option in the configuration file, dhcpcd is always using and waiting for RS/RA messages. And, as you know with INFORM message is just for information, and not IP address assignment.

According to RFC 3315 section 13:

Unless otherwise specified in this document, or in a document that describes how IPv6 is carried over a specific type of link (for link types that do not support multicast), a client sends DHCP messages to the All_DHCP_Relay_Agents_and_Servers.

Is there any option to enable multicasting to FF02::1:2?

rsmarples commented 2 years ago

DHCPv6 in dhcpcd is always multicast to FF02::1:2 unless overriden by the DHCPv6 server to unicast replies to a specific address. It used the term "broadcast" when it's really "multicast" - the above commit addresses that.

Why do you think it's unicasting solicit messages?

mahboobkarimian commented 2 years ago

There is no information about the server prior to my request.

Unless I specify a ia_pd, if I just asking for a ia_na dhcpcd stuck until it times out; and In Wireshark, I don't see any dhcpv6 packets.

dhcpcd-6.11.5 starting
enp0s3: executing `/lib/dhcpcd/dhcpcd-run-hooks' PREINIT
enp0s3: executing `/lib/dhcpcd/dhcpcd-run-hooks' CARRIER
DUID 00:01:00:01:2a:96:32:81:08:00:27:85:09:20
enp0s3: IAID 27:85:09:20
timed out
dhcpcd exited

conf:

# A sample configuration for dhcpcd.
# See dhcpcd.conf(5) for details.

allowinterfaces enp0s3

# Allow users of this group to interact with dhcpcd via the control socket.
#controlgroup wheel

# Inform the DHCP server of our hostname for DDNS.
hostname

# Use the hardware address of the interface for the Client ID.
#clientid
# or
# Use the same DUID + IAID as set in DHCPv6 for DHCPv4 ClientID as per RFC4361.
# Some non-RFC compliant DHCP servers do not reply with this set.
# In this case, comment out duid and enable clientid above.
duid

# Persist interface configuration when dhcpcd exits.
persistent

# Rapid commit support.
# Safe to enable by default because it requires the equivalent option set
# on the server to actually work.
option rapid_commit
# A list of options to request from the DHCP server.
option domain_name_servers, domain_name, domain_search, host_name
option classless_static_routes
# Most distributions have NTP support.
option ntp_servers
# Respect the network MTU. This is applied to DHCP routes.
option interface_mtu

# A ServerID is required by RFC2131.
#require dhcp_server_identifier
require dhcp_client_identifier

# Generate Stable Private IPv6 Addresses instead of hardware based ones
#slaac private

ipv6only
noipv6rs
interface enp0s3
    #ia_pd 2 enp0s8/1

When I uncomment ia_pd, it starts to multicast and the dhcpcd output is (note that here there is no answer from my dhcpv6 server):

dhcpcd-6.11.5 starting
enp0s3: executing `/lib/dhcpcd/dhcpcd-run-hooks' PREINIT
enp0s3: executing `/lib/dhcpcd/dhcpcd-run-hooks' CARRIER
DUID 00:01:00:01:2a:96:32:81:08:00:27:85:09:20
enp0s3: IAID 27:85:09:20
enp0s3: IAID 00:00:00:02
enp0s3: reading lease `/var/lib/dhcpcd5/dhcpcd-enp0s3.lease6'
enp0s3: soliciting a DHCPv6 lease
enp0s3: delaying SOLICIT6 (xid 0xda51c6), next in 0.0 seconds
enp0s8: activating for delegation
enp0s8: executing `/lib/dhcpcd/dhcpcd-run-hooks' PREINIT
enp0s8: executing `/lib/dhcpcd/dhcpcd-run-hooks' NOCARRIER
enp0s3: broadcasting SOLICIT6 (xid 0xda51c6), next in 1.1 seconds
enp0s3: broadcasting SOLICIT6 (xid 0xda51c6), next in 2.2 seconds
enp0s3: broadcasting SOLICIT6 (xid 0xda51c6), next in 4.5 seconds
^Creceived SIGINT, stopping
enp0s8: removing interface
enp0s8: executing `/lib/dhcpcd/dhcpcd-run-hooks' STOPPED
enp0s3: removing interface
enp0s3: executing `/lib/dhcpcd/dhcpcd-run-hooks' STOPPED
dhcpcd exited
rsmarples commented 2 years ago

Firstly, dhcpcd-6 is a really old version and is no longer supported. Please use dhcpcd-9.

By default, DHCPv6 will not start unless instructed to by something. This is generally a RA with either the M or O option set for Managed address (IA) or Other (INFOREQ). It can also request explicity without a RA by requesting an address of some kind in dhc;cd.conf.

As you have disabled IPv6RS you won't see a RA so the behaviour you state is expected.

As to why your DHCPv6 server is not responding, will that's up to you to work out. dhcpcd sends RFC compliant messages.

mahboobkarimian commented 2 years ago

Thanks a lot for your help. I understand that this is normal behavior when I specify the options to suppress the neighbor discovery.

Actually, the procedure you described about RA with O and M flags is expected behavior when we have a router, and all the nodes are connected directly to that router (like a star network). But, what is the solution for the proposed network topology in my first post (when there is 1 hop or more distance between the client and server)? As said before, relay nodes can't advertise RA or even relay them. If dhcpcd waits until it receives an RA before transmission of SOLICIT message, then how and when can it multicast them?

About my DHCPV6 server: I am expecting a no response, so that's fine.

rsmarples commented 2 years ago

relay nodes can advertise RA. If it is not a router itself then it can set zero lifetime. It can also set M and O flags.

This tells the client that there is no default router, no prefixes to install but you can get something via DHCPv6.

mahboobkarimian commented 2 years ago

You are right; It seems that based on RFC 6775, 6LRs also can send RAs, but in turn "IEEE 2857-2021 IEEE Standard for Wireless Smart Utility Network Field Area Network (FAN), section 6.2.3.1.4 Neighbor Discovery" doesn't allow them to do it. So I think this is a special case that we need to handle either on the dhcpv6 client-side or on the second interface (eth) of the relay node to use RS/RA.