Find the host IP for the live network connection in Linux
How to find all live host IP addresses for network connections in linux. The specific method is as follows!
You can use the 'netstat' command. The netstat command displays information about network connections, routing tables, and interface statistics. To find the list of IP addresses connected to the server over TCP and UDP, you can use the following command:
netstat -ntu
The above command lists all TCP and UDP network connections, and the fifth column is the external IP information. Use the 'grep' command to filter out TCP connections:
netstat -ntu | grep tcp
ss command (a modern alternative to netstat) :
ss -tnp | grep -E '(ESTAB|SYN-SENT|SYN-RECV)'
Use the 'Nmap' tool. 'Nmap' is an open source network scanning and security audit tool that discovers devices on a network. Install 'Nmap' :
sudo apt-get install nmap # on a Debian/Ubuntu based system
or
sudo yum install nmap # on RedHat based systems
'Nmap' scans a specific network to find all active host IP addresses:
nmap-sn Indicates the network address
If the network address is' 10.42.0.0/22 ', the command will be:
nmap-sn 10.42.0.0/22
The -sn parameter indicates that the ping scan is performed but the port scan is not performed.
Use 'curl' or 'wget' commands and external services:
Use the 'curl' or 'wget' command in conjunction with an external service to see the public IP address of the local unit. For example:
curl ifconfig.me
or
wget -qO- ifconfig.me
You can also get your public IP address from an external service.
The above method can help you find all the real-time host IP addresses of the network connection in the Linux system. Select an appropriate method according to the specific requirements.