What's new

Creating Network Services Filter script -- Can this be done?

  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

Just getting back to this and doing some experimenting on my own... Not sure what kind of device you have, but my Android devices in particular stop responding to pings when the device hits 'sleep/doze mode'

You may want to test on your own if your device does the same...

Some limited testing but
Code:
arping -I br0 -c2 -w2 x.x.x.x

Seems to force the device to respond when asleep which will then update the arp cache as <incomplete> (disconnected) or the mac address when connected.
 
Last edited:
Just getting back to this and doing some experimenting on my own... Not sure what kind of device you have, but my Android devices in particular stop responding to pings when the device hits 'sleep/doze mode'

You may want to test on your own if your device does the same...

Some limited testing but
Code:
arping -I br0 -c2 -w2 x.x.x.x

Seems to force the device to respond when asleep which will then update the arp cache as <incomplete> (disconnected) or the mac address when connected.

Thanks. I'm pinging my phone. When I'm home, I ping it every 3 minutes (script runs every 3 minutes). If I ping phone, can it go into sleep/doze?

When I'm not home, and I come back home, I'm sure I've used phone so it is not in sleep/doze mode, anyhow.
Current script seems to be working fine.

Here is the beginning of my script, are you suggesting replacing the arp or ping lines with arping line above? Or would this be an additional line?

Code:
clear
ping -c3 -w2 192.168.1.200 # Pings phone to help update arp.
sleep 2

arp -n | grep "192.168.1.200" | grep -q "33:69:68" # End of MAC address of phone.
if [ $? -eq 0 ]; then #Phone appears to be connected.
 
Doh... forgot you were continually pinging... I havent tried that yet

I just noticed that when my Android devices are on wifi after an hour of inactivity they sleep and they stop responding to pings and the arp cache shows it disconnected, using the arping method forced it to reappear in the cache if it was actually still connected.

Ill run a cron with a ping to simulate your setup and will monitor if it disconnects

But yes using the arping line I just mentioned instead of the ping line in the original version might be more robust
 
But yes using the arping line I just mentioned instead of the ping line in the original version might be more robust

Hi, thanks. I tried looking up arping vs pinging and it was over my head.

So, you are suggesting replacing the line:

ping -c3 -w2 192.168.1.200 # Pings phone to help update arp.

with:

arping -I br0 -c2 -w2 192.168.1.200 # Arping phone to help update arp.

the rest of the script would be untouched?

Thanks
 
No worries, I think for the moment if its working well stick with it.

I may have jumped the gun a bit and should do more of my own testing before recommending changing it.... just the last 20 mins of testing has yielded varying results :(
 
No worries, I think for the moment if its working well stick with it.

I may have jumped the gun a bit and should do more of my own testing before recommending changing it.... just the last 20 mins of testing has yielded varying results :(

:)

I just sent line and get different results. Shouldn't it always return same (if phone connected)?

admin@RT-AC86U-07F8:/tmp/home/root# arping -I br0 -c2 -w2 192.168.1.200
ARPING to 192.168.1.200 from 192.168.1.1 via br0
Sent 2 probe(s) (2 broadcast(s))
Received 0 reply (0 request(s), 0 broadcast(s))


admin@RT-AC86U-07F8:/tmp/home/root# arping -I br0 -c2 -w2 192.168.1.200
ARPING to 192.168.1.200 from 192.168.1.1 via br0
Unicast reply from 192.168.1.200 [8c:45:00:33:69:68] 72.670ms
Unicast reply from 192.168.1.200 [8c:45:00:33:69:68] 291.922ms
Sent 2 probe(s) (1 broadcast(s))
Received 2 reply (0 request(s), 0 broadcast(s))
 
Well thats where the varying results come in... I did jump the gun as I got excited as on 2 tries earlier it worked great...

Now, tablet is asleep, wont respond to regular ping, and sending a 2 count of arping returns nothing.... if I change arping to -c10 -w10 I can at least get some replies.

Again I think the continual ping should work for you... just keep an eye on it is what I really should have said. Next time you've got time to waste... see if your device even has a sleep function first off I guess, and then just make sure if/when it does go to sleep it doesnt break your current setup
 

Similar threads

Latest threads

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Top