Linux Host status Detection mode

Source: Internet
Author: User

Before writing a simple script to detect the status of the host in the current network segment script, the following:

#! /bin/bash#ping Check Host status forIpinch' Seq1 255`; Do{Ping-C1 192.168.214. $ip >/dev/NULL 2>&1if[$?-eq0  ]; Then Echo192.168.214. $ip up >>/sh/Hostsup.txtElseEcho192.168.214. $ip Down >>/sh/Hostsdown.txtfi}doneecho'OK'Exit

The execution time is too long, the effect is very poor, because the ping instruction in the loop to execute hundreds of times, and the ping detection process itself is relatively slow, all the entire script execution will take a long time to complete.

A different tool can be used to detect host status. That's nmap, it's very efficient to execute.

Nmap, also known as Network Mapper, is the first web scan and sniffer toolkit under Linux, and Nmap is almost a must-have tool for hackers.

Nmap Basic ability has three, one is to detect whether a group of hosts online, followed by scanning the host port, sniffing the network services provided, you can also infer the operating system used by the host.

The simple way to use Nmap:

    • NMAP-SP: (ping Scan)

This option tells Nmap to just ping the scan (host discovery) and then print out those hosts that respond to the scan. No further tests (such as port scanning or operating system detection). system administrators often also like this option. It is easy to tell how many machines are running on the network or whether the server is running properly. It's often called a carpet ping, which is more reliable than a ping broadcast address because many hosts do not respond to broadcast requests

eg

[[Email protected]SH]# NMAP-SP192.168.214.0/ -starting Nmap5.51(http://nmap.org) at 2018-03-31 03:52 CSTNMAP Scan Report for 192.168.214.1Host is up (0. 00052s latency). MAC Address:xx: -: About: C0:xx: ,(VMware) Nmap Scan Report for 192.168.214.2Host is up (0. 00024s latency). MAC Address:xx: -: About: E8: -: 5C (VMware) Nmap Scan Report for 192.168.214.187Host is up. Nmap Scan Report for 192.168.214.190Host is up (0. 00051s latency). MAC Address:xx: 0C: in: 8A:DC: -(VMware) Nmap Scan Report for 192.168.214.254Host is up (0. 00060s latency). MAC Address:xx: -: About: ee:d2:Geneva(VMware) Nmap Done: theIP Addresses (5Hosts up) scannedinch 11.98Seconds

Nmap is a very powerful tool, it has a lot of functions: such as port scanning, operating system detection, service detection, etc., here only for the host detection function to do understanding, and other functions to be studied slowly later.

Linux Host status Detection mode

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.