How to know your public IP in Linux terminal

Source: Internet
Author: User
Tags bash script example curl

Guide 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.


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.

Here are the two commands we use primarily, curl and wget. You can use it for a change.

Curl Plain Text format output:
Curl JSON format output:
Curl XML format output:
Curl gets all IP details (excavator)
use Dydns (useful when you use the Dydns service)
use Wget instead of Curl
Bash Script Example:
#!/bin/bash public_ip= ' wget http://ipecho.net/plain-O-Q; Echo ' echo $PUBLIC _ip 

This article was reproduced from:http://www.linuxprobe.com/linux-public-ip.html

more Linux Dry Goods visit:http://www.linuxprobe.com/

How to know your public IP in Linux terminal

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.