Interface

net_ip

Get the local IP address of the host. Supports IPv4 (default) and IPv6 via flags. Falls back through 'ip', 'ifconfig', and 'nslookup'. Optionally scope to a specific interface. For the public/external IP address, use net_query_ip instead.

Example

net_ip           # => local IPv4 addresses
net_ip -6        # => local IPv6 addresses
net_ip -4 eth0   # => IPv4 addresses on eth0

Arguments

  • $1 (string): Optional: '-4' for IPv4 (default); '-6' for IPv6
  • $2 (string): Optional: interface name to scope the query

Exit codes

  • 0: Success
  • 1: Could not determine address

Output on stdout

  • The IP address(es), one per line

net_gateway

Get the default _gateway address. Optionally scoped to a specific interface. Tries 'ip route', then 'netstat', then 'route' in order. Handles Linux and Solaris differences via OSSTR.

Arguments

  • $1 (string): Optional: interface name for per-interface _gateway lookup

Exit codes

  • 0: On success or 'none' sentinel
  • 1: When interface specified but 'ip' is unavailable

Output on stdout

  • The _gateway IP, 'none' if no route exists, or 'unknown' if indeterminate