This commit is contained in:
Root THC
2025-12-01 10:05:51 +00:00
parent 648c71e536
commit 767848c678
2 changed files with 17 additions and 6 deletions

View File

@@ -37,6 +37,9 @@
# ======
# Ghost-route LAN & WAN traffic by default.
#
# GHOST_DEV=
# Optional. The network interface the Ghost IP will operate on.
#
# GHOST_IP=
# An unused IP address on the LAN. Used for hosts only (don't use on routers)
#
@@ -59,6 +62,7 @@
# =========================
# Example 1: Use an unused Ghost-IP from this host:
# $ source ./ghostip.sh
#. $ GHOST_DEV=wg0 source ./ghostip.sh # Ghost towards specific interface
# Identical to:
# $ GHOST_IP=192.168.0.222 source ./ghostip.sh
# $ GHOST_IP_LAN=192.168.0.222 source ./ghostip.sh
@@ -114,15 +118,21 @@ err() {
echo -e >&2 "${CDR}ERROR: ${CN}$*"
}
# Find the Internet facing GW
# Find the GW towards we like to ghost traffic
# For HOST-ghosting, the first parameter is the Ghost-IP (if known).
# Example: eth0 or wg0
ghost_find_gw() {
local ip="$1"
local arr
local IFS
local l
str=$(ip route show match 1.1.1.1)
str="${str##*dev }"
gw_dev="${str%% *}"
gw_dev="$GHOST_DEV"
[ -z "$gw_dev" ] && {
str=$(ip route show match "${ip:-1.1.1.1}")
str="${str##*dev }"
gw_dev="${str%% *}"
}
# Get the device IP:
l="$(ip addr show dev "$gw_dev" | grep -m1 'inet '))"
@@ -423,7 +433,7 @@ ghost_down() {
ghost_up2() {
local ghost_ip
ghost_find_gw || return
ghost_find_gw "${GHOST_IP}" || return
[ -n "$GHOST_IP" ] && ghost_ip="$GHOST_IP"
[ -z "$GHOST_IP" ] && [ -z "$GHOST_IP_LAN" ] && [ -z "$GHOST_IP_WAN" ] && {

View File

@@ -21,7 +21,8 @@
# Some ideas by slav and from virt-what
# Stop bash -c "$(curl .. ws)" to show up badly in process list
[ -t 0 ] && [ -z "$NOEVAL" ] && [ -n "$BASH_EXECUTION_STRING" ] && c="$BASH_EXECUTION_STRING" IFS="" NOEVAL=1 exec bash -c 'eval "$c"'
[ -z "$_EVAL_REEXEC" ] && [ "${#BASH_EXECUTION_STRING}" -gt 128 ] && _EVAL_REEXEC="$BASH_EXECUTION_STRING" IFS="" exec bash -c 'eval "$_EVAL_REEXEC"'
unset _EVAL_REEXEC
[[ -z "$NOCOLOR" ]] && {
CY="\e[1;33m" # yellow