openwrt / odhcpd

This repository is a mirror of https://git.openwrt.org/?p=project/odhcpd.git. Pull requests will be accepted which will be merged in odhcpd.git
GNU General Public License v2.0
160 stars 96 forks source link

ra_useleasetime parameter running results are inconsistent #212

Closed ac169 closed 6 months ago

ac169 commented 6 months ago

Environment: The two routers have the same hardware model, the same system version (OpenWrt 21.02.2) and the same DHCP configuration. They both obtain IPv6-PD through pppoe dialing. The DHCP configuration is as follows: uci show dhcp.lan

dhcp.lan=dhcp dhcp.lan.interface='lan' dhcp.lan.dhcpv4='server' dhcp.lan.ra='server' dhcp.lan.ra_flags='none' dhcp.lan.leasetime='2h' dhcp.lan.ra_maxinterval='300' dhcp.lan.ra_mininterval='120' dhcp.lan.ra_lifetime='3600' dhcp.lan.ra_useleasetime='1'

Requirement: Modify the value of Valid Lifetime or Preferred Lifetime in the RA message

The LAN device under Router A captures ICMPv6(RA) Valid Lifetime: 7200 is the expected value

 ICMPv6 Option (Prefix information : 2000:3:5587:50::/64)
     Type: Prefix information (3)
     Length: 4 (32 bytes)
     Prefix length: 64
     Flag: 0xc0, On-link flag(L), Autonomous address-configuration flag(A)
     Valid Lifetime: 7200
     Preferred Lifetime: 43200
     Reserved
     Prefix: 2000:3:5587:50::

The LAN device under Router B captures ICMPv6(RA) Valid Lifetime: 2580, which is not the expected value.

 ICMPv6 Option (Prefix information : 2000:3:5122:200::/64)
     Type: Prefix information (3)
     Length: 4 (32 bytes)
     Prefix length: 64
     Flag: 0xc0, On-link flag(L), Autonomous address-configuration flag(A)
     Valid Lifetime: 2580
     Preferred Lifetime: 2580
     Reserved
     Prefix: 2000:3:5122:200::

Question:

  1. The two routers are almost the same. Why do they have different results? How to troubleshoot the problem?
  2. What configuration file does odhcpd get its parameters from when running, and what configurations will affect this result?
ac169 commented 6 months ago

Another discovery:

When the dhcp.lan.ra_lifetime parameter value is not set, the icmpv6.nd.ra.router_lifetime in the RA message is the default value 1800. When the dhcp.lan.ra_lifetime='3600' parameter value is set, the icmpv6.nd.ra.router_lifetime in the RA message is the default value of 3600, and there is no problem with the above. However, after deleting this parameter and value, icmpv6.nd.ra.router_lifetime in the RA message did not return to the default value of 1800 but changed to 900. Even if the system is restarted, it is not restored. So I very much suspect that odhcpd refers to unknown parameters or configuration files. Checking the odhcpd service script does not find that any parameters or configuration files are referenced.

Internet Control Message Protocol v6
    Type: Router Advertisement (134)
    Code: 0
    Checksum: 0xd5be [correct]
    [Checksum Status: Good]
    Cur hop limit: 64
    Flags: 0x40, Other configuration, Prf (Default Router Preference): Medium
    Router lifetime (s): 900
    Reachable time (ms): 0

So how are the odhcpd operation parameters obtained?

ac169 commented 6 months ago

The reason was found: Router B obtained the preferred_lft and valid_lft values of IPv6-PD, both of which were less than 2h, so odhcpd chose the minimum value.