Ping range ip linux

Ping range of IP addresses in parallel with fping

fping is a program which uses the Internet Control Message Protocol (ICMP) echo request to determine if a host is up. fping is different from ping in that you can specify any number of hosts on the command line, or specify a file containing the lists of hosts to ping. Instead of trying one host until it timeouts or replies, fping will send out a ping packet and move on to the next host in a round-robin fashion. If a host replies, it is noted and removed from the list of hosts to check. If a host does not respond within a certain time limit and/or retry limit it will be considered unreachable.

Basically fping is meant to be used in shell scripts and its output is easy to parse. This command can be very useful to when you have to scan whole network for alive or unreachable hosts. In case of usage regular ping command you’ll have to write shell script and parse each hosts icmp replies but fping can do the same in one line:

To scan range of IP addresses from 192.168.0.1 to 192.168.0.9 just run:
sudo fping -s -g 192.168.0.1 192.168.0.9 -r 1

192.168.0.1 is alive
192.168.0.7 is alive
192.168.0.2 is unreachable
192.168.0.3 is unreachable
192.168.0.4 is unreachable
192.168.0.5 is unreachable
192.168.0.6 is unreachable
192.168.0.8 is unreachable
192.168.0.9 is unreachable

9 targets
2 alive
7 unreachable
0 unknown addresses

14 timeouts (waiting for response)
16 ICMP Echos sent
2 ICMP Echo Replies received
0 other ICMP received

0.05 ms (min round trip time)
0.44 ms (avg round trip time)
0.84 ms (max round trip time)
2.183 sec (elapsed real time)

In order to scan /24 network (254 hosts) and show only alive hosts the following command can be used:

sudo fping -a -q -g 192.168.0.0/24

Источник

How to ping all the ip in LAN using Terminal?

I am trying to ping all the systems available in the local area network using terminal command. Can any one tell me how to do this?

4 Answers 4

You can install an application called nmap .

Then you can check your entire network for all connected IP addresses by typing in the following:

The above command will scan all IP addresses starting at 192.168.1.1 through 192.168.1.254 and show you all IPs that responded.

You can scan other IP address ranges like 192.168.0.1 — 192.168.1.254 by typing in the following:

A typical scan might return something like the following:

terrance@terrance-ubuntu:~$ nmap -sP 10.0.0.1/24 Starting Nmap 6.40 ( http://nmap.org ) at 2015-12-24 00:20 MST Nmap scan report for Linksys03773 (10.0.0.1) Host is up (0.00078s latency). Nmap scan report for terrance-ubuntu (10.0.0.100) Host is up (0.00020s latency). Nmap scan report for android (10.0.0.148) Host is up (0.099s latency). Nmap scan report for PC (10.0.0.149) Host is up (0.0014s latency). Nmap scan report for 10.0.0.150 Host is up (0.0016s latency). Nmap scan report for 10.0.0.165 Host is up (0.011s latency). Nmap scan report for 10.0.0.169 Host is up (0.010s latency). Nmap scan report for 10.0.0.179 Host is up (0.014s latency). Nmap scan report for android (10.0.0.181) Host is up (0.093s latency). Nmap scan report for android (10.0.0.188) Host is up (0.043s latency). Nmap scan report for android (10.0.0.196) Host is up (0.014s latency). Nmap scan report for 10.0.0.253 Host is up (0.0013s latency). Nmap done: 256 IP addresses (12 hosts up) scanned in 4.46 seconds 

Источник

Читайте также:  Установка zabbix linux debian

Ping Multiple IPs and Subnets With FPING

Recently we showed you how you could ping multiple IPs with a simple bash script. Now we are going to show you how you can achieve the same results with fping. Roland Schemers released the first version of fping back in 1992. From 2002 till 2011 there was no new official new release but the software was maintained by end-users. Now a new maintainer has taken over the software and released version 5 of fping.

fping allows you to ping either single IPs, multiple IPs, IP ranges or Subnets from the command line which then shows you if the IP is up or down. fping is a great tool for diagnostics and statistics.

How To Install FPING

At the time of writing this article V5 of fping was the latest release. If you install fping using yum, apt, dnf or other OS install method you will get v3 so to install fping v5 from source, follow the instruction below. Ensure you have gcc installed before running the install commands.

wget https://fping.org/dist/fping-5.0.tar.gz tar -xvf fping-5.0.tar.gz cd fping-5.0 ./configure make && make install

fping should now be installed to your server and it’s time to start using the software. Let’s look at pinging single IPs with fping.

fping Single IP

fping 51.68.247.104 51.68.247.104 is alive

Here I have sent ping requests to the IP 51.68.247.104 and fping has told me the IP is up and responding.

fping Multiple IPs

fping 51.68.247.104 51.68.247.105 51.68.247.106 51.68.247.107
fping 51.68.247.104 51.68.247.105 51.68.247.106 51.68.247.107 51.68.247.104 is alive 51.68.247.105 is alive 51.68.247.106 is alive 51.68.247.107 is alive

Here I have pinged multiple IPs and fping has reported they all respond. Entering all these IPs is time-consuming though. This is a subnet of 8 IPs, 51.68.247.104/29 so I could just ask fping to ping the whole subnet.

fping Subnet

fping -g 51.68.247.104/29 51.68.247.104 is alive 51.68.247.105 is alive 51.68.247.106 is alive 51.68.247.107 is alive 51.68.247.108 is alive 51.68.247.109 is alive 51.68.247.110 is alive 51.68.247.111 is alive

Here I can see the whole subnet is up and it’s taken seconds because I can just enter the subnet with no need to specify each IP. So what about a whole range of IPs? I could ping the subnet by entering the range too.

Читайте также:  What is init daemon in linux

fping IP Range

fping -s -g 51.68.247.104 51.68.247.111
fping -s -g 51.68.247.104 51.68.247.111 51.68.247.104 is alive 51.68.247.105 is alive 51.68.247.106 is alive 51.68.247.107 is alive 51.68.247.108 is alive 51.68.247.109 is alive 51.68.247.110 is alive 51.68.247.111 is alive 8 targets 8 alive 0 unreachable 0 unknown addresses 0 timeouts (waiting for response) 8 ICMP Echos sent 8 ICMP Echo Replies received 0 other ICMP received 0.013 ms (min round trip time) 0.018 ms (avg round trip time) 0.024 ms (max round trip time) 0.071 sec (elapsed real time)

Using the -s flag gives you a greater output showing more statistics like the time it takes to ping each IP. If you have IP listed in a text file you can also tell fping to cycle through the whole file and provide you with the results.

fping Multiple IPs In Text File

Here I placed all my IPs into a text file called ips.txt and asked fping to ping each IP. You could add the -s flag (fping -s < ips.txt) to the command for full statistics. Overall fping is much more flexible than pinging multiple IPs with bash and provides for more options and statistics.

Источник

Ping range ip linux

fping-phonendoscope

Иногда возникает необходимость пропинговать множество узлов. Стандартная утилита ping умеет пинговать только один хост. Для того, чтобы пинговать множество хостов, стоит воспользоваться возможностями утилиты fping.

Согласно информации из Википедии:

fping — Свободно распространяемая утилита для UNIX систем. Проверяет доступность узлов в сети путем посылки ICMP ECHO_REQUEST пакетов. В отличие от стандартной утилиты ping, можно указать сколько угодно узлов в командной строке или указать текстовый файл со списком узлов. Вместо того, чтобы послать запрос ожидать ответа от одного узла, fping посылает запрос и переходит к следующему узлу по round-robin.

По умолчанию, когда узел ответил он удаляется из списка узлов для проверки, если же в течение заданного времени и/или количества попыток ответ не пришёл то такой узел считается недоступным. fping может посылать указанное или бесконечное количество запросов, так же, как это делает ping.

В отличие от ping, fping подразумевает использование его в скриптах, поэтому он выводит данные в форме удобной для разбора скриптом (parse).

fping относится к утилитам использующим ping sweep технологию. Вы должны понимать что пингование (сканирование) узлов или сетей которые вам не принадлежат может трактоваться как противозаконное действие.

Исходя из этой информации, можно отметить такие недостатки использования утилиты fping:

  • мгновенный скачкообразный ICMP-флуд в ethernet-сегменте;
  • мгновенная нагрузка на систему;
  • в выводе утилиты fping имеют место быть не только IP-адреса ответивших хостов, т.е. его нужно еще дополнительно фильтровать;
  • неприемлемое для больших сетей (несколько тысяч хостов) быстродействие.
Читайте также:  Menu lst puppy linux

Но в определенных ситуациях использование утилиты может пригодиться.

Выполним установку fping из системы портов:

# cd /usr/ports/net/fping && make install clean && rehash

После установки можно некоторыми возможностями утилиты.

Воспользовавшсь ключем -v, можно просмотреть версию утилиты:

Чтобы ознакомиться с доступными для использования ключами, необходимо использовать ключ -h:

# fping -h Usage: fping [options] [targets. ] -a show targets that are alive -A show targets by address -b n amount of ping data to send, in bytes (default 68) -B f set exponential backoff factor to f -c n count of pings to send to each target (default 1) -C n same as -c, report results in verbose format -e show elapsed time on return packets -f file read list of targets from a file ( - means stdin) (only if no -g specified) -g generate target list (only if no -f specified) (specify the start and end IP in the target list, or supply a IP netmask) (ex. fping -g 192.168.1.0 192.168.1.255 or fping -g 192.168.1.0/24) -i n interval between sending ping packets (in millisec) (default 25) -l loop sending pings forever -m ping multiple interfaces on target host -n show targets by name (-d is equivalent) -p n interval between ping packets to one target (in millisec) (in looping and counting modes, default 1000) -q quiet (don't show per-target/per-ping results) -Q n same as -q, but show summary every n seconds -r n number of retries (default 3) -s print final stats -S addr set source address -t n individual target initial timeout (in millisec) (default 500) -u show targets that are unreachable -v show version targets list of targets to check (if no -f specified)

Пример пингования сети 172.20.0.0/28:

# fping -g 172.20.0.0/28 172.20.0.1 is alive 172.20.0.5 is alive 172.20.0.9 is alive 172.20.0.12 is alive 172.20.0.13 is alive 172.20.0.0 is unreachable 172.20.0.2 is unreachable 172.20.0.3 is unreachable 172.20.0.4 is unreachable 172.20.0.6 is unreachable 172.20.0.7 is unreachable 172.20.0.8 is unreachable 172.20.0.10 is unreachable 172.20.0.11 is unreachable 172.20.0.14 is unreachable 172.20.0.15 is unreachable

Если использовать ключ -a, то в выводе утитилы будут присутствовать только доступные хосты:

# fping -ag 172.20.0.0/28 172.20.0.1 172.20.0.5 172.20.0.9 172.20.0.12 172.20.0.13

Для отображения времени отклика необходимо использовать ключ -e:

# fping -aeg 172.20.0.0/28 172.20.0.1 (0.05 ms) 172.20.0.5 (1.15 ms) 172.20.0.9 (1.18 ms) 172.20.0.12 (1.21 ms) 172.20.0.13 (0.92 ms)

Для формирования отчета необходимо использовать ключ -s:

# fping -saeg 172.20.0.0/28 172.20.0.1 (0.04 ms) 172.20.0.5 (1.09 ms) 172.20.0.9 (1.06 ms) 172.20.0.12 (1.06 ms) 172.20.0.13 (0.98 ms) 16 targets 5 alive 11 unreachable 0 unknown addresses 44 timeouts (waiting for response) 49 ICMP Echos sent 5 ICMP Echo Replies received 0 other ICMP received 0.04 ms (min round trip time) 0.84 ms (avg round trip time) 1.09 ms (max round trip time) 6.352 sec (elapsed real time)

Краткий обзор утилиты сделан, и ее возможности более-менее понятны.

Источник

Оцените статью
Adblock
detector