My Local Ip icon

My Local Ip

Get my local IP address

Overview

This node retrieves the local IP address(es) of the machine where n8n is running. It can fetch IPv4, IPv6, or both types of addresses from specified network interfaces. Additionally, it supports filtering to return only external (non-internal) IP addresses.

Common scenarios for this node include:

  • Automatically detecting the machine's IP address for logging or monitoring workflows.
  • Using the local IP information to configure network-related automation.
  • Gathering network interface details for diagnostics or reporting.

For example, a user might want to get their machine’s external IPv4 address to send it via email or store it in a database for reference.

Properties

Name Meaning
Network Interface Define the specific network interface to query (e.g., "eth0", "Wi-Fi"). Leave empty for all.
Version Choose which IP version(s) to retrieve: "IP V4", "IP V6", or "Both IP V4/V6".
Only External IP If true, returns only external (non-internal) IP addresses; otherwise includes internal ones.
Options → Put Result in Field The name of the output JSON field where the result will be stored (default: "local").

Output

The node outputs an array of items, each containing a JSON object with a field (default "local", configurable) holding the IP information. This field contains an object with an interfaces array. Each element in this array represents one network interface address matching the criteria and includes:

  • hostname: The hostname of the machine.
  • family: IP family, either "IPv4" or "IPv6".
  • interface: The name of the network interface.
  • address: The IP address.
  • mac: The MAC address of the interface.
  • internal: Boolean indicating if the address is internal (e.g., loopback).
  • subnet: The subnet calculated from the IP address and netmask.

Example output snippet:

{
  "local": {
    "interfaces": [
      {
        "hostname": "my-machine",
        "family": "IPv4",
        "interface": "eth0",
        "address": "192.168.1.10",
        "mac": "00:1A:2B:3C:4D:5E",
        "internal": false,
        "subnet": "192.168.1.0/24"
      }
    ]
  }
}

Dependencies

  • Uses Node.js built-in os module to access network interfaces and hostname.
  • Uses the external ip package to calculate subnet information.
  • No external API keys or services are required.

Troubleshooting

  • No IP addresses returned:
    Ensure the specified network interface exists on the machine. Leaving the interface field empty queries all interfaces.

  • Only internal IPs returned despite setting "Only External IP":
    Some environments may not have external IPs assigned or recognized as such. Verify network configuration.

  • Incorrect IP version returned:
    Confirm that the selected IP version matches the available addresses on the machine.

  • Subnet calculation errors:
    The node relies on the ip package for subnet calculation; unusual or misconfigured network settings might cause unexpected results.

Links and References

Discussion