In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-20 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces how to use Linux terminal to obtain public IP, the article is very detailed, has a certain reference value, interested friends must read it!
Public IP is used to communicate between computers through Internet. Computers running with public IP can use Internet to access all parts of the world. So we can say that it is the identity of a computer on the Internet.
The question now is, how do we know our public intellectual property rights? For computers with GUI, you can easily get IP using Web tools like this, but how to get the public IP of computers that only have terminal access.
Solution: you can use one of the following commands to find the public IP of the system using the Linux terminal. These are also useful in shell scripts.
Use the Linux command to find a public IP
Command 1:
Use the dig command to find the public IP address. The dig command is a DNS lookup utility for Linux systems to find public IP addresses by connecting to an OpenDNS server.
$dig + short myip.opendns.com @ resolver1.opendns.com
Command 2:
Use the wget command to obtain the public IP address, as shown in the following example.
$wget http://ipecho.net/plain-O-Q; echo
Commands 3pr 4 and 5:
Use the curl command to get the public address.
$curl ipecho.net/plain; echo$ curl icanhazip.com$ curl ifconfig.me
Get the public IP in the shell script
We can simply use the following command in the shell script to get the computer's public IP and store them in variables for use anywhere in the shell script.
#! / bin/bashPUBLIC_IP= `wget http://ipecho.net/plain-O-Q; echo`echo $PUBLIC_IP above how to use the Linux terminal to get all the content of the public IP, thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.