vintage net logo

Hex versionAPI docsCircleCICoverage Status

VintageNetEthernet adds support to VintageNet for wired Ethernet connections. It can be used for virtual Ethernet or for other non-wired Ethernet scenarios, but support is minimal. You may also be interested in VintageNetDirect or VintageNetWiFi.

Assuming that your device has Ethernet ports, all you need to do is add :vintage_net_ethernet to your mix dependencies like this:

def deps do
[
{:vintage_net_ethernet, "~> 0.7.0", targets: @all_targets}
]
end

Using

Wired Ethernet interfaces typically have names like "eth0", "eth1", etc. when using Nerves.

An example configuration for enabling an Ethernet interface that dynamically gets an IP address is:

config :vintage_net,
config: [
{"eth0",
%{
type: VintageNetEthernet,
ipv4: %{
method: :dhcp
}
}}
]

You can also set the configuration at runtime:

iex> VintageNet.configure("eth0", %{type: VintageNetEthernet, ipv4: %{method: :dhcp}})
:ok

Here's a static IP configuration:

iex> VintageNet.configure("eth0", %{
type: VintageNetEthernet,
ipv4: %{
method: :static,
address: "192.168.9.232",
prefix_length: 24,
gateway: "192.168.9.1",
name_servers: ["1.1.1.1"]
}
})
:ok

In the above, IP addresses were passed as strings for convenience, but it's also possible to pass tuples like {192, 168, 9, 232} as is more typical in Elixir and Erlang. VintageNet internally works with tuples.

The following fields are supported:

Wired Ethernet connections are monitored for Internet connectivity if a default gateway is available. When internet-connected, they are preferred over all other network technologies even when the others provide default gateways.

Properties

There are no wired Ethernet-specific properties. See vintage_net for the default set of properties for all interface types.