Public address assigned by the InterNIC by class-based network ID or address blocks CIDR-based configuration (called CIDR blocks), and to ensure the uniqueness of the global Internet. When the public address is assigned, its route will be recorded to the Internet router, so you can access public address traffic smooth arrival. Traffic access to the target public address can be reached via the Internet. For example, when a CIDR blocks are allocated in the form of a network ID and subnet mask to an organization, the corresponding [network ID, subnet mask] will also be stored as a route in the Internet router. Goal is CIDR block IP address of the packet will be guided to the corresponding position.
In this article I will explain in a few check your public IP address in Linux terminal method. It makes no sense for the average user, but Linux server (no GUI or as a basic tool can only be used when the user logs on) would be useful. In any case, access to public IP is very significance in various aspects from the Linux terminal, we might be able to need it some day.
Here are two of our main command used, curl and wget. You can change the use.
Curl plain text output:
curl JSON output format:
curl www.trackip.net/ip?json (somewhat ugly)
curl XML output format:
curl get all IP details (excavator)
Use DYDNS (useful when you use 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 "[. [: digit:]] \ +"
Instead of using Wget Curl
wget http://ipecho.net/plain -O - -q; echo
wget http://observebox.com/ip -O - -q; echo
Host and dig using the command
If so, you can use the dig command and host.
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 daily record for my router, all IP changes and save it to a script file. I found a good use of these commands in the search process. I hope that one day it can help other people.