fix(script): fix eth route

This commit is contained in:
Lucky Bassi 2023-12-16 13:54:47 +01:00
parent 54f5b0a218
commit 3b49e8f1d6
1 changed files with 18 additions and 0 deletions

View File

@ -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}