public-ip - 快速获取你的公网IP地址

public-ip - 快速获取你的公网IP地址

Node.js 命令行应用

访问GitHub主页

共597Star

详细介绍

public-ip Build Status

Get your public IP address - very fast!

Queries the DNS records of OpenDNS which has an entry with your IP address.

Install

$ npm install --save public-ip

Usage

const publicIp = require('public-ip');

publicIp.v4().then(ip => {
    console.log(ip);
    //=> '46.5.21.123'
});

publicIp.v6().then(ip => {
    console.log(ip);
    //=> 'fe80::200:f8ff:fe21:67cf'
});

API

publicIp.v4()

Returns a Promise for your public IPv4 address.

publicIp.v6()

Returns a Promise for your public IPv6 address.

Related

License

MIT © Sindre Sorhus