How to find your public IP address in Linux

Source: Internet
Author: User
Tags curl curl api

Each site has a unique, public IP address that anyone can access from anywhere.

Internet Protocol Internet Protocol (IP) does not need to be introduced--we use it every day. Even if you don't use it directly, when you enter website-name.com on the browser, it looks for the IP address of the URL and then loads the site.

We divide IP addresses into two categories: private and public. A private IP address is a private IP address that is provided by (and the company intranet) for your non-line. They range from 10.xxx, 172.16.xx-172.31.xx, and 192.168.xx, where x=0 to 255. The public IP address, as the name implies, is "public" and you can access it anywhere in the world. Each site has a unique IP address that anyone can access at any point, which can be considered a public IP address.

In addition, there are two types of IP addresses: IPv4 and IPV6.

The IPV4 address format is x.x.x.x, where x=0 to 255. There are 232 (approximately 4 billion) possible IPv4 addresses.

The IPV6 address uses more complex hexadecimal. The total number of bits is 128, which means there are 2128 (340 followed by 36 0!). ) a possible IPv6 address. IPV6 has been introduced to resolve the foreseeable IPv4 address exhaustion problem.

As a network engineer, I recommend that you do not share your machine's public IP address with anyone. Your WiFi router has a public IP, or WAN (WAN) IP address, and any device connected to that WiFi is the same. All devices connected to the same WiFi have the private IP address described above. For example, my laptop's IP address is 192.168.0.5, and my phone number is 192.168.0.8. These are private IP addresses, but both have the same public IP address.

The following command lists the IP address list to find the public IP address of your computer:

    1. ifconfig.me
    2. curl -4/-6 icanhazip.com
    3. curl ipinfo.io/ip
    4. curl api.ipify.org
    5. curl checkip.dyndns.org
    6. dig +short myip.opendns.com @resolver1.opendns.com
    7. host myip.opendns.com resolver1.opendns.com
    8. curl ident.me
    9. curl bot.whatismyipaddress.com
    10. curl ipecho.net/plain

The following command will give you the private IP address of the interface:

    1. ifconfig -a
    2. ip addr (ip a)
    3. hostname -I | awk ‘{print $1}’
    4. ip route get 1.2.3.4 | awk ‘{print $7}‘
    5. (Fedora) Wifi-Settings→ click the setting icon next to the Wifi name that you are connected to → Ipv4 and Ipv6 both can be seen
    6. nmcli -p device show

Note: Some tools need to be installed on your system based on the Linux distribution you are using. In addition, some of the mentioned commands use third-party Web sites to obtain IP

Via:https://opensource.com/article/18/5/how-find-ip-address-linux

Archit Modi topic: lujun9972 Translator: GEEKPI proofreading: Wxy

How to find your public IP address in Linux

Related Article

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.