@
Scott81 , als je ping gebruikt, kijk dan ofdat je de afmeting omlaag kunt schroeven:
$ man ping
[..]
-s packetsize
Specifies the number of data bytes to be sent. The default is 56, which
translates into 64 ICMP data bytes when combined with the 8 bytes of
ICMP header data.
$ ping -c 1 -s 0 127.0.0.1
PING 127.0.0.1 (127.0.0.1) 0(28) bytes of data.
8 bytes from 127.0.0.1: icmp_seq=1 ttl=64
--- 127.0.0.1 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
$ sudo tcpdump -nti any icmp
[..]
lo In IP 127.0.0.1 > 127.0.0.1: ICMP echo request, id 21, seq 1, length 8
lo In IP 127.0.0.1 > 127.0.0.1: ICMP echo reply, id 21, seq 1, length 8
Maar ik zou een andere heuristic gebruiken om bij benadering te bepalen ofdat een service up is.
Ik zou kijken ofdat bv met web poortje 80 TCP hieronder alleen een verbinding is te maken.
Alleen het TCP
FIN-->ACK-->FIN-->ACK gedeelte:
$ nc -vz 127.0.0.1 80
Connection to 127.0.0.1 80 port [tcp/http] succeeded!
$ sudo tcpdump -nti any tcp port 80
[..]
lo In IP 127.0.0.1.46324 > 127.0.0.1.80: Flags [S], seq 2584648338, win 65495, options [mss 65495,sackOK,TS val 3533265509 ecr 0,nop,wscale 6], length 0
lo In IP 127.0.0.1.80 > 127.0.0.1.46324: Flags [S.], seq 4198683657, ack 2584648339, win 65483, options [mss 65495,sackOK,TS val 3533265509 ecr 3533265509,nop,wscale 6], length 0
lo In IP 127.0.0.1.46324 > 127.0.0.1.80: Flags [.], ack 1, win 1024, options [nop,nop,TS val 3533265509 ecr 3533265509], length 0
lo In IP 127.0.0.1.46324 > 127.0.0.1.80: Flags [F.], seq 1, ack 1, win 1024, options [nop,nop,TS val 3533265514 ecr 3533265509], length 0
lo In IP 127.0.0.1.80 > 127.0.0.1.46324: Flags [F.], seq 1, ack 2, win 1024, options [nop,nop,TS val 3533265515 ecr 3533265514], length 0
lo In IP 127.0.0.1.46324 > 127.0.0.1.80: Flags [.], ack 2, win 1024, options [nop,nop,TS val 3533265515 ecr 3533265515], length 0
Vergelijk "length" maar in de respectievelijke
tcpdump outputs.
Nog mooier zou zijn als je al na de
FIN-->ACK kunt stoppen want je hebt toch al de
ACK ontvangen van de server.
Dat scheelt weer extra communicatie.
EDIT:
$ nc -z 127.0.0.1 80 && echo 'UP' || echo 'DOWN'
UP
$ nc -z 127.0.0.1 9999 && echo 'UP' || echo 'DOWN'
DOWN
[
Voor 3% gewijzigd door
deHakkelaar op 16-02-2023 20:28
]
There are only 10 types of people in the world: those who understand binary, and those who don't