Skip to content

Implement Adaptive DHCP Client/Server Network Configuration #5

@mihai-chiorean

Description

@mihai-chiorean

Description

Current implementation only acts as DHCP server. Need adaptive behavior to support macOS Internet Sharing where the host becomes the DHCP server.

Problem

When macOS Internet Sharing is enabled, macOS acts as DHCP server (typically 192.168.2.x range). The device needs to detect this and act as DHCP client instead of server.

Requirements

  1. Try DHCP client first (5 second timeout)
  2. If no DHCP server found, become DHCP server
  3. Support macOS Internet Sharing (192.168.2.x range)
  4. Maintain compatibility with direct connections

Proposed systemd-networkd Configuration

[Network]
DHCP=yes
LinkLocalAddressing=yes
Address=192.168.7.1/24
DHCPServer=yes
ConfigureWithoutCarrier=yes

[DHCP]
UseDNS=yes
UseRoutes=yes
RequestTimeout=5

[DHCPServer]
PoolOffset=100
PoolSize=20

Alternative Approach

Create a script that:

  1. Attempts DHCP client with timeout
  2. Checks if lease obtained
  3. If yes: Acts as client
  4. If no: Configures static IP and starts DHCP server

Use Cases

  • Direct connection: Device provides DHCP (192.168.7.x)
  • macOS Internet Sharing OFF: Device provides DHCP
  • macOS Internet Sharing ON: Device gets IP from macOS, has internet access

Acceptance Criteria

  • Device gets IP from macOS when Internet Sharing enabled
  • Device provides DHCP when directly connected
  • Seamless switching between modes
  • Internet connectivity works through macOS sharing
  • Link-local addresses always available as fallback

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions