sudo apt update sudo apt-get install build-essential pkg-config cmake autoconf automake libtool wget git #编译libmnl cd /tmp git clone git://git.netfilter.org/libmnl cd /tmp/libmnl/ ./autogen.sh --disable-shared --host=mipsel-linux-uclibc ./configure make
编译wireguard-tools
1 2 3 4
cd ~ git clone https://github.com/WireGuard/wireguard-tools.git cd wireguard-tools/src/ env CFLAGS=-I/tmp/libmnl/include LDFLAGS=-L/tmp/libmnl/src/.libs make
#模式选择错误处理 if [ "$mode" != "router" -a "$mode" != "neigh" ]; then echo "please select router or neigh" exit fi #neigh模式处理下级设备IP if [ "$mode" = "neigh" ]; then if [ -z $mac ]; then echo "mac is empty" exit fi mac=$( echo $mac | tr '[A-Z]' '[a-z]' ) file=$HOME/.dynv6.neigh.$name [ -e $file ] && old=`cat $file` #获得下级设备的ip macinf=$(echo $mac | tr '[A-Z]' '[a-z]' | awk -F ':' '{print $5$6}' ) ipaddress=$(ip -6 neighbor | grep $mac | grep -v $macinf | grep -v 'fe80' | awk '{print $1}')
#router模式处理路由器IP else file=$HOME/.dynv6.router [ -e $file ] && old=`cat $file` #获取ip地址 ipaddress=$(ip -6 addr list scope global $device | grep "global" | sed -n 's/.*inet6 \([0-9a-f:]\+\).*/\1/p') fi
#判断ip地址是否存在 if [ -z "$ipaddress" ]; then echo "no IPv6 address found" exit 1 fi #检查地址是否改变 if [ "$old" = "$ipaddress" ]; then echo "IPv6 address unchanged" exit fi
#模式选择错误处理 if [ "$mode" != "router" -a "$mode" != "neigh" ]; then echo "please select router or neigh mode" exit fi #neigh模式处理下级设备IP if [ "$mode" = "neigh" ]; then if [ -z $mac ]; then echo "mac is empty" exit fi mac=$( echo $mac | tr '[A-Z]' '[a-z]' ) file=$HOME/.mailuip.neigh.$name [ -e $file ] && old=`cat $file` #获得下级设备的ip macinf=$(echo $mac | tr '[A-Z]' '[a-z]' | awk -F ':' '{print $5$6}' ) ipaddress=$(ip -6 neighbor | grep $mac | grep -v $macinf | grep -v 'fe80' | awk '{print $1}')
#router模式处理路由器IP else file=$HOME/.mailuip.router [ -e $file ] && old=`cat $file` #获取ip地址 ipaddress=$(ip -6 addr list scope global $device | grep "global" | sed -n 's/.*inet6 \([0-9a-f:]\+\).*/\1/p') fi
#判断ip地址是否存在 if [ -z "$ipaddress" ]; then echo "no IPv6 address found" exit 1 fi #检查地址是否改变 if [ "$old" = "$ipaddress" ]; then echo "IPv6 address unchanged" exit fi