I found a solution (but maybe exists some simpler).
Concept:
add a bash script to crontab and verify if router MAC-address match with specific router.
The bash script is (note: chmod +x):
#!/bin/bash
# SCRIPT DOES IF ROUTER MATCH EXPECTED MAC ADDRESS
# -- EDITABLE PART --
# function todo if TRUE
function_MATCH () {
echo "MAC adresses match!"
}
# function todo if FALSE
function_MISMATCH () {
echo "it's not as expected!"
}
# CHANGE VALUE WITH YOUR ROUTER MAC ADDRESS
EXPECTED="55:55:55:55:55:55"
# -- END EDITABLE PART --
# get "arp -a" string of router:
arp=$(arp -a 192.168.1.1)
# extract MAC adress
MAC=${arp##*at }
MAC=${MAC% [*}
if [ "$MAC" = "$EXPECTED" ];
then function_MATCH
else function_MISMATCH
fi
This is a generic function callback (function_MATCH or function_MISMATCH).
To use this script to activate no-ip service only if router match desired one, change function_MATCH() with following one:
function_MATCH () {
echo "MAC adresses match!"
sudo noip2
}
then, save script (where you prefer) and edit crontab by calling, in terminal:
$ crontab -e
finally, call script in crontab adding it at the end.
for example (be carefull to add right script-path):
@reboot sleep 60 && /home/user/scripts/router_verificator.sh
Note: no-ip service need a connection to update ip-redirect.
doing verification after 60secs from SO-start prevent no connection
available.
I know, its quite complicated.
If someone has a smarter solution.. tank you.