#!/bin/sh # ===================================================================== # Projet : DARKWALL # Fichier : bin/ifdhcpexit.routeHelper # Auteur : Nicolas "DarkHack" Chapuis (c) 2026 # ================== DARKHACK ================== # [ darkweb.fr - system online ] # Powered by Perplexity, your AI assistant # https://www.perplexity.ai # ============================================== # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # ===================================================================== LOG=/tmp/dhcp-routeHelper.log log() { echo "$*" >> "$LOG" } run_ip() { log "+ $*" out="$("$@" 2>&1)" rc=$? log "rc=$rc out=$out" return "$rc" } log "===== $(date) =====" log "ip -6 addr" ip -6 addr >> "$LOG" log "ip -6 route" ip -6 route >> "$LOG" log "ip -6 route show table local" ip -6 route show table local >> "$LOG" ipSrc="${new_ip_address}" ipSrc="${ipSrc:-$( sh /etc/darksrv/firewall/bin/GetIpForIface ${interface} )}" if [ -n "$interface" ] && [ -n "$new_routers" ] && [ -n "$ipSrc" ]; then IFS_SAVE=$IFS IFS=',' set -- $new_routers IFS=$IFS_SAVE for new_router in "$@"; do if run_ip ip route get $new_router dev $interface;then if ! ip route show dev "$interface" | grep -q "default via $new_router"; then echo "try Add Route '$new_router' on '$interface' by '$ipSrc'" >> "$LOG" if run_ip ip route add default via "$new_router" dev "$interface" src ${ipSrc} scope global; then echo "route added $new_router by '$ipSrc'" >> "$LOG" elif run_ip ip route replace default via "$new_router" dev "$interface" src ${ipSrc} scope global; then echo "route replaced $new_router by $ipSrc" >> "$LOG" else if ! ip route show dev "$interface" | grep -q "^default "; then echo "!!!!!!! Fallback Route '$interface' (scope link)" >> "$LOG" run_ip ip route replace default dev "$interface" src ${ipSrc} scope link else echo "default already present, no fallback" >> "$LOG" fi fi fi else echo "Route not ready for '$new_router' on '$interface'" >> "$LOG" fi done else echo "one of follow is empty: ipSrc:$ipSrc new_routers:$new_routers interface:$interface" >> "$LOG" fi log "after:" ip -6 addr >> "$LOG" ip -6 route >> "$LOG" ip -6 route show table local >> "$LOG"