Query the external network IP of the server and query the external network IP according to the domain name

    Linux often needs to query the external network IP of the server, or query the external network IP corresponding to the server through the domain name


1. Query the external network IP of the local server

curl ipinfo.io/ip


2. Query the external network IP through the domain name

by executing the command: nslookup www.baidu.com can get the following results

Non-authoritative answer:
www.baidu.com canonical name = www.a.shifen.com.
Name: www.a.shifen.com
Address: 14.215.177.37
Name: www.a. shifen.com
Address: 14.215.177.38



or execute: ping www.baidu.com to get the following IP


PING www.a.shifen.com (14.215.177.37) 56(84) bytes of data.
64 bytes from 14.215.177.37: icmp_seq=1 ttl=47 time=7.53 ms
64 bytes from 14.215.177.37: icmp_seq=2 ttl=47 time=7.52 ms
64 bytes from 14.215.177.37: icmp_seq=3 ttl=47 time=7.58 ms
64 bytes from 14.215.177.37 : icmp_seq=4 ttl=47 time=7.58 ms

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326359685&siteId=291194637
Recommended