Last active
September 5, 2023 02:22
-
-
Save polymorphm/8281531 to your computer and use it in GitHub Desktop.
some config files for IPv6 (DHCPv6-PD over PPPoE)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/bash | |
# | |
# it is file -- /etc/ppp/ipv6-down.d/99-custom-internet.sh | |
# | |
if [ -z "$IFNAME" ] || [ "$LINKNAME" != "domru" ] | |
then | |
true | |
exit | |
fi | |
lan_iface="br-lan" | |
ip6tables -w -F CUSTOM_INTERNET__FORWARD | |
ip6tables -w -t mangle -F CUSTOM_INTERNET__FORWARD | |
dhcpcd -x "$IFNAME" | |
rm /var/run/custom-internet-dhcpcd.conf | |
rm /var/run/custom-internet-dhcpcd-hooks | |
rm /var/lib/dhcpcd/dhcpcd-"$IFNAME".lease6 | |
true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/bash | |
# | |
# it is file -- /etc/ppp/ipv6-up.d/99-custom-internet.sh | |
# | |
if [ -z "$IFNAME" ] || [ "$LINKNAME" != "domru" ] | |
then | |
true | |
exit | |
fi | |
lan_iface="br-lan" | |
ip6tables -w -t mangle -F CUSTOM_INTERNET__FORWARD | |
ip6tables -w -t mangle -A CUSTOM_INTERNET__FORWARD -o "$IFNAME" -p tcp --tcp-flags SYN,RST SYN -j TCPMSS --clamp-mss-to-pmtu | |
ip6tables -w -F CUSTOM_INTERNET__FORWARD | |
ip6tables -w -A CUSTOM_INTERNET__FORWARD -i "$lan_iface" -o "$IFNAME" -j ACCEPT | |
ip6tables -w -A CUSTOM_INTERNET__FORWARD -i "$IFNAME" -o "$lan_iface" -j ACCEPT | |
cat >/var/run/custom-internet-dhcpcd.conf <<__END__ | |
ipv6only | |
noipv6rs | |
interface $IFNAME | |
ia_pd 1 | |
__END__ | |
cat >/var/run/custom-internet-dhcpcd-hooks <<__END__ | |
#!/usr/bin/bash | |
#echo "**********" >>/root/hooks.log | |
#date >>/root/hooks.log | |
#env >>/root/hooks.log | |
#echo "**********" >>/root/hooks.log | |
if [ "\$reason" == "REBIND6" ] && [ "\$new_dhcp6_ia_pd1_prefix1/\$new_dhcp6_ia_pd1_prefix1_length" == "\$old_dhcp6_ia_pd1_prefix1/\$old_dhcp6_ia_pd1_prefix1_length" ] | |
then | |
true | |
exit | |
fi | |
if [ "\$reason" == "BOUND6" ] || [ "\$reason" == "REBIND6" ] || [ "\$reason" == "STOP6" ] | |
then | |
if [ -f /var/run/custom-internet-radvd.conf ] | |
then | |
rm /var/run/custom-internet-radvd.conf | |
fi | |
if [ -f /var/run/custom-internet-radvd.pid ] | |
then | |
radvd_pid="\$(cat /var/run/custom-internet-radvd.pid)" | |
rm /var/run/custom-internet-radvd.pid | |
kill "\$radvd_pid" | |
fi | |
if [ -f /var/run/custom-internet-dhcpcd-addr.data ] | |
then | |
ip -6 addr del "\$(cat /var/run/custom-internet-dhcpcd-addr.data)" dev $lan_iface | |
rm /var/run/custom-internet-dhcpcd-addr.data | |
fi | |
fi | |
if [ "\$reason" == "BOUND6" ] || [ "\$reason" == "REBIND6" ] | |
then | |
if [ "\$new_dhcp6_ia_pd1_prefix1_length" == "64" ] | |
then | |
new_dhcp6_addr="\${new_dhcp6_ia_pd1_prefix1}1/\$new_dhcp6_ia_pd1_prefix1_length" | |
echo "\$new_dhcp6_addr" >/var/run/custom-internet-dhcpcd-addr.data | |
ip -6 addr add "\$new_dhcp6_addr" dev $lan_iface | |
cat >/var/run/custom-internet-radvd.conf <<__INNER_END__ | |
interface $lan_iface { | |
AdvSendAdvert on; | |
MaxRtrAdvInterval 10; # hack for broken mobile wifi-devices (normal default is 600) | |
AdvDefaultLifetime 1800; # hack for broken mobile wifi-devices (normal default is MaxRtrAdvInterval*3) | |
prefix \$new_dhcp6_ia_pd1_prefix1/\$new_dhcp6_ia_pd1_prefix1_length | |
{ | |
}; | |
RDNSS 2001:4860:4860::8888 2001:4860:4860::8844 | |
{ | |
}; | |
}; | |
__INNER_END__ | |
radvd -C /var/run/custom-internet-radvd.conf -p /var/run/custom-internet-radvd.pid | |
fi | |
fi | |
true | |
__END__ | |
chmod +x /var/run/custom-internet-dhcpcd-hooks | |
dhcpcd -B -f /var/run/custom-internet-dhcpcd.conf -c /var/run/custom-internet-dhcpcd-hooks "$IFNAME" & | |
true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment