Skip to content

Instantly share code, notes, and snippets.

@cyyself
Created May 6, 2024 15:42
Show Gist options
  • Save cyyself/a0c965887928da85ef37b8af6f7d8e6c to your computer and use it in GitHub Desktop.
Save cyyself/a0c965887928da85ef37b8af6f7d8e6c to your computer and use it in GitHub Desktop.
Delivery IPv6 PD Prefix from Home Broadband to another site via VPN
#!/usr/bin/env sh
remote='root@10.12.10.1'
remote_if='wg_some_site'
prefix_digit=15 # prefix is /60
subnet_len=64
subnet_add=f # /60 + f = xxxf/64
lan_addr=$(ssh $remote cat /proc/net/if_inet6 | grep br-lan.1 | grep "40 00 00" | cut -f 1 -d ' ')
routed_prefix_raw=$(echo ${lan_addr:0:$prefix_digit}$subnet_add | sed 's/.\{4\}/&:/g')
routed_perfix=$routed_prefix_raw":/"$subnet_len
lan_addr=$routed_prefix_raw":1/"$subnet_len
echo $lan_addr
ssh $remote ip -6 route add $routed_perfix dev $remote_if
ip -6 addr add $lan_addr dev br-lan
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment