From 4e24e7a6ce12b16953ccfc907c6a5b9551112cbc Mon Sep 17 00:00:00 2001
From: Jiri Kalvoda <jirikalvoda@kam.mff.cuni.cz>
Date: Wed, 14 Feb 2024 21:32:55 +0100
Subject: [PATCH] NET hopik blatto ipv6 + blatto route

---
 network/hopik/dhcpcd.conf       |  2 +-
 network/hopik/dhcpcd.enter-hook | 30 +++++++++++++++++++++++++++---
 network/hopik/scripts/con-sm    |  6 ++++--
 3 files changed, 32 insertions(+), 6 deletions(-)

diff --git a/network/hopik/dhcpcd.conf b/network/hopik/dhcpcd.conf
index c79a18a..30d5460 100644
--- a/network/hopik/dhcpcd.conf
+++ b/network/hopik/dhcpcd.conf
@@ -68,7 +68,7 @@ noipv6rs
 
 ssid blatto-jk-5g
 static ip_address=10.12.11.22/24
-static ip6_address=2a01:510:d504:7510::22/64
+static ip6_address=2a01:510:d504:751a::22/64
 static routers=10.12.11.1
 static domain_name_servers=10.12.11.1
 static domain_name=jk.blatto.eu
diff --git a/network/hopik/dhcpcd.enter-hook b/network/hopik/dhcpcd.enter-hook
index 1cb3982..34a1fb5 100644
--- a/network/hopik/dhcpcd.enter-hook
+++ b/network/hopik/dhcpcd.enter-hook
@@ -11,6 +11,30 @@ conntrack_hack(){
 		(echo R | socat unix:/run/conntrack_hack - ) &
 	fi
 }
+route6(){
+	if [ "$reason" == STATIC6 ]
+	then
+		echo $msg_prefix add ip route: $@
+		ip -6 route add $@
+	fi
+	if [ "$reason" == NOCARRIER ]
+	then
+		echo $msg_prefix del ip route: $@
+		ip -6 route del $@
+	fi
+}
+route(){
+	if [ "$reason" == STATIC ]
+	then
+		echo $msg_prefix add ip route: $@
+		ip -4 route add $@
+	fi
+	if [ "$reason" == NOCARRIER ]
+	then
+		echo $msg_prefix del ip route: $@
+		ip -4 route del $@
+	fi
+}
 
 if [[ "$interface" == w ]]
 then
@@ -21,7 +45,7 @@ then
 		if [ "$reason" == STATIC6 ]
 		then
 			echo $msg_prefix set ipv6 default route
-			ip -6 route add default via 2001:718:1e03:81a::1
+			route6 default via 2001:718:1e03:81a::1 dev w
 		fi
 	fi
 
@@ -30,8 +54,8 @@ then
 		conntrack_hack
 		if [ "$reason" == STATIC6 ]
 		then
-			echo $msg_prefix set ipv6 default route
-			ip -6 route add default via 2a01:510:d504:7510::1
+			route6 default via 2a01:510:d504:7510::1 dev w
+			route 10.12.0.0/16 via 10.12.11.1 dev wg-blatto
 		fi
 	fi
 
diff --git a/network/hopik/scripts/con-sm b/network/hopik/scripts/con-sm
index 8c1b8f9..c19100c 100755
--- a/network/hopik/scripts/con-sm
+++ b/network/hopik/scripts/con-sm
@@ -8,7 +8,9 @@ interface=sm
 echo R | socat unix:/run/conntrack_hack -
 ip link set $interface up
 ip addres add 10.12.11.22/24 dev $interface
-ip addres add 2a01:510:d504:7510::22/64 dev $interface
+ip addres add 2a01:510:d504:751a::22/64 dev $interface
+ip route add 10.12.0.0/16 via 10.12.11.1 dev $interface
+ip route add 2a01:510:d504:7500::0/56 via 2a01:510:d504:751a::1 dev wg-blatto metric 1000
 ip route add default via 10.12.11.1 dev $interface
-ip route add default via 2a01:510:d504:7510::1 dev $interface
+ip route add default via 2a01:510:d504:751a::1 dev $interface
 (echo domain jk.blatto.eu;  echo nameserver 10.12.11.1 ) | resolvconf -a $interface
-- 
GitLab