Skip to content

Instantly share code, notes, and snippets.

@korzhyk
Last active August 7, 2024 18:23
Show Gist options
  • Save korzhyk/4e734924483de96e370415625bde4fed to your computer and use it in GitHub Desktop.
Save korzhyk/4e734924483de96e370415625bde4fed to your computer and use it in GitHub Desktop.
NetAssist :: IPv6 Tunnel Broker auto update client IPv4 on OpenWRT
#!/bin/sh
update_tunnel_broker() {
local wan_ip
local username
local password
local proto
local tunnelid
config_get proto $1 proto
config_get tunnelid $1 tunnelid
# Check for corrent protocol and there are not HE.net tunnel
if [ "$proto" != "6in4" ] || [ "$tunnelid" != "" ]; then
return
fi
network_get_ipaddr wan_ip "$WAN_IFACE"
if [ -z "$wan_ip" ]; then
logger -p err -t 6in4 "'$WAN_IFACE' has no assigned IP address"
exit 0
fi
config_get username $1 username
config_get password $1 password
wget -qO- "https://tb.netassist.ua/autochangeip.php?l=$username&p=$password&ip=$wan_ip" | while read res; do logger -t 6in4 "broker response: $res"; done
exit 0
}
. /lib/functions/network.sh
network_find_wan WAN_IFACE
[ "$ACTION" = ifup ] && [ "$INTERFACE" = "$WAN_IFACE" ] && {
. /lib/functions.sh
config_load network
config_foreach update_tunnel_broker interface
}

Put 30-netassist into /etc/hotplug.d/iface

wget -qO /etc/hotplug.d/iface/30-netassist https://gist.githubusercontent.com/korzhyk/4e734924483de96e370415625bde4fed/raw/30-netassist
uci batch <<EOF
set network.wan6.proto='6in4'
set network.wan6.peeraddr='62.205.132.12' # Broker server ipv4
set network.wan6.ip6addr='::2/64' # Client ipv6 addr
set network.wan6.ip6prefix='::/48' # Your routred ipv6 net
set network.wan6.username='EMAIL' # Username (email)
set network.wan6.password='PASSWORD' # Password
EOF
uci commit network
@korzhyk
Copy link
Author

korzhyk commented Apr 8, 2023

@Yur0K в логах помилок не помічено? Я вже не памятаю, але можливо ще потрібно перезагрузити роутер оскільки там ще має підключатись модуль ядра для роботи цього інтерфейсу.

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