Skip to content

Instantly share code, notes, and snippets.

@top4ek
Last active February 14, 2023 01:32
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save top4ek/0c3de14a73f0313221522430407e9d83 to your computer and use it in GitHub Desktop.
Save top4ek/0c3de14a73f0313221522430407e9d83 to your computer and use it in GitHub Desktop.
My Zyxel Keenetic scripts
#!/bin/sh
[ "$table" != "filter" ] && exit 0
/opt/sbin/iptables -A FORWARD -i tun0 -s 10.8.0.0/24 -j ACCEPT
/opt/sbin/iptables -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT
/opt/sbin/iptables -t nat -I POSTROUTING -o ppp0 -s 10.8.0.0/24 -j MASQUERADE
#!/bin/sh
# Reconnect WAN
interface_name=PPPoE0
interface_thru=ISP-Vlan
/opt/home/tg_send.sh "HW button pressed: " "Force reconnect."
ndmq -p "no interface ${interface_name} connect via ${interface_thru}"
sleep 5
ndmq -p "interface ${interface_name} connect via ${interface_thru}"
#!/bin/sh
# Send message to user via bot
token='11111111:11111111111111111111111111111111111'
id=11111111
curl "https://api.telegram.org/bot${token}/sendMessage?chat_id=${id}&parse_mode=markdown" --data-urlencode "text=*$1* $2" > /dev/null
#!/bin/sh
# Update NS at pdd.yandex.ru
token="11111111111111111111111111111111111111111111111111111111"
domain="domain.tld"
subdomain="subdomain"
record_id="11111111"
curl -k "https://pddimp.yandex.ru/nsapi/edit_a_record.xml?token=${token}&domain=${domain}&subdomain=${subdomain}&record_id=${record_id}&content=$1" > /dev/null
/opt/home/tg_send.sh "Updated pdd.yandex:" $1
#!/bin/sh
# Reconnect WAN until white IP received(hello Rostelecom)
interface_port=ppp0
interface_name=PPPoE0
interface_thru=ISP-Vlan
counter=/opt/tmp/wan_reconnect_counter.txt
max_tries=20
[ ! "$interface" == "${interface_port}" ] && exit 0
/opt/home/tg_send.sh "WAN is up: " $address
_ip=$(echo $address | grep -v -E "(^100\.6[4-9]\.|^100\.[7-9][0-9]\.|^100\.1[0-1][0-9]\.|^100\.12[0-7]\.)")
if [ -z ${_ip} ]; then
[ -f "$counter" ] || echo '0' > $counter
try_nr="$(cat $counter)"
try_nr=$((try_nr+1))
if [ $try_nr -gt $max_tries ]; then
echo '0' > $counter
/opt/home/tg_send.sh 'Giving up to get real IP.'
exit
fi
/opt/home/tg_send.sh "Force reconnect to get real IP:" "$try_nr/$max_tries"
echo "$try_nr" > $counter
/opt/home/fn_led.sh on
ndmq -p "no interface ${interface_name} connect via ${interface_thru}"
sleep 5
ndmq -p "interface ${interface_name} connect via ${interface_thru}"
/opt/home/fn_led.sh off
else
echo '0' > $counter
/opt/home/update_pdd.sh $address
fi
@noshimorimoshi
Copy link

update a_record. How it works? Thanks

@top4ek
Copy link
Author

top4ek commented Jan 4, 2018

It's pdd.yandex.ru. Domain must be delegated to them

@noshimorimoshi
Copy link

Thx. 🖖🏽
Looks good 👍🏾

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment