first look at the General command to view the IP:
Ifconfig
Linux view command--ifconfig for IP address
The Ifconfig command is used to view and change the address and parameters of the network interface
$ifconfig-A
lo0:flags=849 MTU 8232
inet 127.0.0.1 netmask ff000000
hme0:flags=863 MTU 1500
inet 211.101.149.11 netmask ffffff00 broadcast 211.101.149.255
Ether 8:0:20:a7:4d:21
The system displays the name of the network interface, the status of the interface (up or down),
Interface IP address and mask information
Remove the native IP address:
Ifconfig|grep bcast|awk-f: ' {print $ {} ' |awk-f ' "' {print '} '
Remove the number of native IP addresses:
Ifconfig|grep bcast|awk-f: ' {print $ {} ' |awk-f ' "' {print '} ' |wc-l
How to know your public IP public address in a Linux terminal is assigned by InterNIC and consists of a class-based network ID or a CIDR-based address block (called a CIDR block), and guarantees uniqueness in 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 commands
If 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.
How to view public IP in Linux terminal