Public addresses are allocated by InterNIC and consist of class-based network IDs or CIDR-based address blocks (called CIDR blocks), and are guaranteed to be unique across the global Internet. When a public address is assigned, its route is recorded to a router in the Internet, so that traffic to the public address can be reached smoothly. Traffic to the target public address is reachable via the Internet. For example, when a CIDR block is assigned to an organization in the form of a network ID and a subnet mask, the corresponding [network ID, subnet mask] is also stored as a route in the router on the Internet. The destination is the IP packet of the address in the CIDR block that is directed to the corresponding location. In this article I will cover several ways to view your public IP address in a Linux terminal. This does not make sense for ordinary users, but it can be useful if a Linux server (without a GUI or as a user who can only use basic tools) is logged in. In any case, getting a public IP from a Linux terminal is meaningful in every way, and might be useful someday. Here are the two commands we use primarily, curl and wget. You can use it for a change. Curl Plain Text Format output:
Curl icanhazip.com
Curl Ifconfig.me
Curl curlmyip.com
Curl ip.appspot.com
Curl IPINFO.IO/IP
Curl Ipecho.net/plain
Curl www.trackip.net/i
Curl JSON format output:
Curl Ipinfo.io/json
Curl Ifconfig.me/all.json
Curl Www.trackip.net/ip?json (a little ugly)
Curl XML Format output:
Curl Ifconfig.me/all.xml
Curl gets all IP details (excavator)
Curl Ifconfig.me/all
Use Dydns (useful when you use the Dydns service)
Curl-s ' http://checkip.dyndns.org ' | Sed ' s/.*current IP address: \ ([0-9\.] *\). */\1/g '
Curl-s http://checkip.dyndns.org/| Grep-o "[[:d Igit:].] \+"
Use Wget instead of Curl
wget Http://ipecho.net/plain-O-Q; Echo
wget Http://observebox.com/ip-O-Q; Echo
Using the host and Dig commandsIf so, you can also use the host and dig commands directly.
Host-t a dartsclink.com | Sed ' S/.*has address//'
Dig +short myip.opendns.com @resolver1. opendns.com
Bash Script Example:
#!/bin/bash
Public_ip= ' wget Http://ipecho.net/plain-O-Q; Echo '
Echo $PUBLIC _ip
Easy to use. I'm actually writing a script to record all the IP changes in my router every day and save it to a file. I found these very useful commands in the search process. Hopefully someday it will help others. If you want to dive into the Linux system novice, you can also download a German Linux software center trial.
Free: Http://www.nfs-cloud.cn:81/appCenter/open/softcenter
|