From 3b49e8f1d6e6e2b7d0339ef7f792f7aee859a582 Mon Sep 17 00:00:00 2001 From: Lucky Bassi Date: Sat, 16 Dec 2023 13:54:47 +0100 Subject: [PATCH] fix(script): fix eth route --- script/network_config.sh | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/script/network_config.sh b/script/network_config.sh index 02f5263..70f1751 100755 --- a/script/network_config.sh +++ b/script/network_config.sh @@ -74,6 +74,13 @@ fi IFS=',' read -ra ADDR <<<"$ADD_IP_ADDRESSES" IFS=',' read -ra MACS <<<"$MAC_ADDRESSES" +# Generate dynamic routing rules +additional_routes="" +for add_ip in "${ADDR[@]}"; do + additional_routes+=" up ip route add $add_ip dev ${NETWORK_INTERFACE} +" +done + # Initialize the interfaces file content interfaces_content=" ### Hetzner Online GmbH installimage @@ -84,6 +91,17 @@ auto lo iface lo inet loopback iface lo inet6 loopback +# Main network interface configuration +iface ${NETWORK_INTERFACE} inet manual + up ip route add -net ${GATEWAYADDRESS} netmask ${NETMASK} gw ${GATEWAYADDRESS} vmbr0 + up sysctl -w net.ipv4.ip_forward=1 + up sysctl -w net.ipv4.conf.${NETWORK_INTERFACE}.send_redirects=0 + up sysctl -w net.ipv6.conf.all.forwarding=1 +$additional_routes + up ip route add 192.168.0.0/16 via ${MAINSERVERIP} dev vmbr0 + up ip route add 172.16.0.0/12 via ${MAINSERVERIP} dev vmbr0 + up ip route add 10.0.0.0/8 via ${MAINSERVERIP} dev vmbr0 + auto vmbr0 iface vmbr0 inet static address ${MAINSERVERIP}