AndiSHFR / wake-on-lan.php

Send magic packet from php to wake up a host using "Wake on Lan"
MIT License
87 stars 26 forks source link

function ping #7

Open Abecker37 opened 2 years ago

Abecker37 commented 2 years ago

i want to use your script but the ping dont work. where is your function for the ping. im beginer in code i have error connection refused when the function send request. but my firewall is configured for dont block the ping. i can send ping via my bash command.

Thanks for your help ABecker

AndiSHFR commented 2 years ago

Hello, in the current version there is no such a thing as a ping by means of an icmp packet.

The host test (thumbs up/thumbs down) is done by trying to connect to several ports via tcp. The ports are 3389 (rdp), 22 (ssh), 80 (http) and 443 (https).

If at least one port successfully connects the host will be considered as up. If all connection requests fail the host will be considered as down.

See line 247 in wake-on-lan.php

On the computer hosting the wake-on-lan.php script the web server must be allowed to make outgoing tcp connections on the ports mentioned above.

Could you provide a screenshot showing the "connection refused" message?

regards Andi

Abecker37 commented 2 years ago

connection

AndiSHFR commented 2 years ago

I'm a bit confused. Where do you "see" this? This is the result of the backend call and usually not visible to the user in the web browser.

Anyway, the connectivity test is done by trying to connect to the ports mentioned above.

The backend does this by calling fsockopen() (See line 258).

If the function returns with error "connection refused" this usually means that the requested tcp port is firewalled. Please check if there are firewall rules in between the web server running wake-on-lan and the host to check.

As soon as the tcp connection could be established to any of the ports the loop will end and flag "isUp".

So if you finally see the message with property "isUp" set to false, then this means that none of the requested tcp ports could be connected.

Abecker37 commented 2 years ago

i see this in inspector. thanks for your help i send a pictures for explain where i see that suite-co

AndiSHFR commented 2 years ago

Ah, now it is clear. Thank you.

The only important information for the frontend is the property "isUp". Please check that at least one of the tcp ports (3389, 22, 80, 443) can be connected on the remote host.

I have chosen these ports because the vast majority of my computers have either rdp, ssh and/or a web server. If your hosts are different then you are welcome to extend the port list according to your needs.

i.e. i can imagine that a "database-only" host would have none of the above ports open. So the test would basically fail for such a host.

fbach3101 commented 1 year ago

For example, to check Windows Host joined to Active Directory, add following in line with port 3389 mentioned above: '135' => '135 (RPC)'