Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

returns localhost (127.0.0.1) as publicIpv4 #99

Open
Danny-awesome opened this issue Jun 27, 2019 · 2 comments
Open

returns localhost (127.0.0.1) as publicIpv4 #99

Danny-awesome opened this issue Jun 27, 2019 · 2 comments

Comments

@Danny-awesome
Copy link

No description provided.

@Danny-awesome
Copy link
Author

ip.address returns 127.0.0.1 which isn't my publicIpv4 address.. how do I get what I want

@kellertobias
Copy link

the issue title seems to imply a bug, however it is just the intended behaviour. see the documentation for that:

// ### function address (name, family)
// #### @name {string|'public'|'private'} **Optional** Name or security
//      of the network interface.
// #### @family {ipv4|ipv6} **Optional** IP family of the address (defaults
//      to ipv4).
//
// Returns the address for the network interface on the current system with
// the specified `name`:
//   * String: First `family` address of the interface.
//             If not found see `undefined`.
//   * 'public': the first public ip address of family.
//   * 'private': the first private ip address of family.
//   * undefined: First address with `ipv4` or loopback address `127.0.0.1`.

so you would have to call ip.address('public') however depending on where you will run that code it might not return an IP address at all. If you are behind a NAT router or in any other kind of network that works with private IP addresses (e.g. a server behind loadbalancers), your computer/ server does not have a public ip address, your network has, but that won't show up on your computers interfaces.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants