Parcourir la source

add ipv6 default route after enabling ipv6 forwarding

HgO il y a 1 an
Parent
commit
df56105c81
1 fichiers modifiés avec 9 ajouts et 0 suppressions
  1. 9 0
      conf/ynh-hotspot

+ 9 - 0
conf/ynh-hotspot

@@ -136,8 +136,17 @@ set_ipfirewall() {
 }
 
 set_forwarding() {
+    local ip6_gateway=$(ip -6 route | awk '/default via/ { print $3; }')
+    local wired_interface=$(ip -6 route | awk '/default via/ { print $5; }')
+
     sysctl -w net.ipv6.conf.all.forwarding=1 >/dev/null
     sysctl -w net.ipv4.conf.all.forwarding=1 >/dev/null
+
+    if [[ -n "${ip6_gateway}" ]]; then
+      # Enabling IPv6 forwarding removes the default route, so we need to add it back.
+      # See https://askubuntu.com/questions/463625/ipv6-forwarding-kills-ipv6-connection/463654#463654
+      ip route add default via "${ip6_gateway}" dev ${wired_interface}
+    fi
 }
 
 start_dhcpd() {