View Source VintageNetDirect (vintage_net_direct v0.10.7)

Support for directly connected Ethernet configurations

Direct Ethernet connections are those where the network connects only two devices. Examples include a virtual Ethernet interface being run over a USB cable. This is a popular Nerves configuration for development where the USB cable provides power and networking to a Raspberry Pi, Beaglebone or other "USB Gadget"-capable board. Another example would be a direct Ethernet connection between a device and a development computer. Such a connection is handy when a router isn't readily available.

The VintageNet Technology works by assigning a static IP address to the Ethernet interface on this side of the connection and running a DHCP server to assign an IP address to the other side of the cable. IP addresses are computed based on the hostname and interface name. A /30 subnet is used for the two IP addresses for each side of the cable to try to avoid conflicts with IP subnets used on either computer. The DHCP server in use is very simple and assigns the same IP address every time.

Note that many decisions were made to make this use case work well. If you're thinking about use cases with more than just the one cable and two endpoints, you'll want to look elsewhere.

Configurations for this technology are maps with a :type field set to VintageNetDirect. VintageNetDirect-specific options are in a map under the :vintage_net_direct key (formerly the :gadget key). These include:

  • :hostname - if non-nil, this overrides the hostname used for computing a unique IP address for this interface. If unset, :inet.gethostname/0 is used.

Most users should specify the following configuration:

%{type: VintageNetDirect}