Toolshed.Net (toolshed v0.2.19) View Source

Network related helpers

Link to this section Summary

Functions

Return the hostname

Print out the network interfaces and their addresses.

Lookup the specified hostname in the DNS and print out the addresses.

Ping an IP address using TCP

Check if a computer is up using TCP.

Link to this section Functions

Link to this macro

hostent(record, args)

View Source (macro)

Specs

hostname() :: String.t()

Return the hostname

Examples

iex> hostname
"nerves-1234"

Specs

ifconfig() :: :"do not show this result in output"

Print out the network interfaces and their addresses.

Specs

nslookup(String.t()) :: :"do not show this result in output"

Lookup the specified hostname in the DNS and print out the addresses.

Examples

iex> nslookup "google.com"
Name:     google.com
Address:  172.217.7.238
Address:  2607:f8b0:4004:804::200e
Link to this function

ping(address, options \\ [])

View Source

Specs

ping(String.t(), keyword()) :: :"do not show this result in output"

Ping an IP address using TCP

This tries to connect to the remote host using TCP instead of sending an ICMP echo request like normal ping. This made it possible to write in pure Elixir.

NOTE: Specifying an :ifname only sets the source IP address for the TCP connection. This is only a hint to use the specified interface and not a guarantee. For example, if you have two interfaces on the same LAN, the OS routing tables may send traffic out one interface in preference to the one that you want. On Linux, you can enable policy-based routing and add source routes to guarantee that packets go out the desired interface.

Options:

  • :ifname - Specify a network interface to use. (e.g., "eth0")

Examples

iex> ping "nerves-project.org"
Press enter to stop
Response from nerves-project.org (185.199.108.153): time=4.155ms
Response from nerves-project.org (185.199.108.153): time=10.385ms
Response from nerves-project.org (185.199.108.153): time=12.458ms

iex> ping "google.com", ifname: "wlp5s0"
Press enter to stop
Response from google.com (172.217.7.206): time=88.602ms
Link to this function

tping(address, options \\ [])

View Source

Check if a computer is up using TCP.

Options:

  • :ifname - Specify a network interface to use. (e.g., "eth0")

Examples

iex> tping "nerves-project.org"
Response from nerves-project.org (185.199.108.153): time=4.155ms

iex> tping "192.168.1.1"
Response from 192.168.1.1 (192.168.1.1): time=1.227ms