netif

A dynamic network interface.

Access Points

  • tcp: Stream Outbound. Initiate a TCP connection bound to the selected network interface. Domain names will be resolved using outbound_resolver or the resolver of this plugin.
  • udp: Datagram Outbound. Send a UDP packet bound to the selected network interface. Domain names will be resolved using outbound_resolver or the resolver of this plugin.
  • resolver: Resolver. Resolve domain names using configuration associated with this network interface.

Parameters

{
  "family_preference": "Ipv4Only",
  "type": "Auto"
}
  • family_preference: Specify the preferred address family. Can be one of the following (case sensitive):
    • Both
    • Ipv4Only
    • Ipv6Only
  • type: Determine how to pick a network interface. Can be one of the following (case insensitive):
    • Auto: Select a wired, physical interface if available, otherwise a wireless interface.
    • Manual: Select a network interface by name.
  • netif: Specify the name of the network interface. Only takes effect when type is Manual.
  • outbound_resolver (optional):

Examples

Select a network interface automatically:

{
  "family_preference": "Both",
  "type": "Auto"
}

Select the network interface called eth0:

{
  "family_preference": "Ipv4Only",
  "type": "Manual",
  "netif": "eth0"
}

Details

To keep track of usable network interfaces, the plugin keeps watching network changes regardless of type.

When family_preference is set to Auto and there is at least one IPv6 address and one IPv4 address assigned to the network interface, the plugin utilizes RFC 8305: Happy Eyeballs Version 2 strategy to establish a TCP connection to both IPv4 and IPv6 networks in a concurrent manner. For Datagram Sessions, there is no guarantee which address family will be used to send packets.

Platform-specific Implementation Details

PlatformSocket bindNetwork change monitoringHost name resolution
macOS/iOSIP_BOUND_IF / IPV6_BOUND_IFnw_path_monitor_tdnssd
Windowssocket bind to interface addressWindows.Networking.Connectivity.NetworkInformation.NetworkStatusChangedhost_resolver via DNS addresses of the interface
LinuxSO_BINDTODEVICEnetlinksystemd-resolved D-Bus API,
fallback to host-resolver via DNS addresses of the interface retrieved from NetworkManager D-Bus API

Revision History

  • 2023-04-29: Removed netif access point.
  • 2023-04-29: Refactored parameters; removed Virtual.
  • 2023-04-29: Happy Eyeballs Version 2.
  • 2024-04-05: Added outbound_resolver.