cisco-vpn: Remove all VM references, use container IP
Some checks failed
Test / test (push) Has been cancelled
Some checks failed
Test / test (push) Has been cancelled
- Removed get_vm_bridge_ip() and get_container_gateway() - Added get_container_ip() for eth0 (172.31.0.x network) - Updated setup_forwarding() and show_network_status() - No more ens3/VM references
This commit is contained in:
@@ -196,16 +196,10 @@ get_vpn_interface() {
|
|||||||
echo "$iface"
|
echo "$iface"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to get VM's IP on the bridge network (for container routing)
|
# Function to get container's IP on the rego-tunnel network
|
||||||
get_vm_bridge_ip() {
|
get_container_ip() {
|
||||||
# Get IP from container network (172.31.0.x)
|
# eth0 is the rego-tunnel network (172.31.0.x)
|
||||||
ip addr show ens3 2>/dev/null | grep -oP 'inet \K[\d.]+' | head -1
|
ip addr show eth0 2>/dev/null | grep -oP 'inet \K[\d.]+' | head -1
|
||||||
}
|
|
||||||
|
|
||||||
# Function to get container gateway IP
|
|
||||||
get_container_gateway() {
|
|
||||||
# The container bridge gateway
|
|
||||||
echo "172.31.0.1"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to get VPN tunnel IP
|
# Function to get VPN tunnel IP
|
||||||
@@ -330,13 +324,11 @@ setup_forwarding() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
local vpn_ip=$(get_vpn_ip)
|
local vpn_ip=$(get_vpn_ip)
|
||||||
local vm_bridge_ip=$(get_vm_bridge_ip)
|
local container_ip=$(get_container_ip)
|
||||||
local container_gw=$(get_container_gateway)
|
|
||||||
|
|
||||||
log DEBUG "VPN interface: $vpn_iface"
|
log DEBUG "VPN interface: $vpn_iface"
|
||||||
log DEBUG "VPN IP: $vpn_ip"
|
log DEBUG "VPN IP: $vpn_ip"
|
||||||
log DEBUG "VM bridge IP: $vm_bridge_ip"
|
log DEBUG "Container IP: $container_ip"
|
||||||
log DEBUG "Container gateway: $container_gw"
|
|
||||||
|
|
||||||
# Enable IP forwarding
|
# Enable IP forwarding
|
||||||
run_cmd "Enabling IP forwarding" sysctl -w net.ipv4.ip_forward=1
|
run_cmd "Enabling IP forwarding" sysctl -w net.ipv4.ip_forward=1
|
||||||
@@ -410,7 +402,7 @@ setup_forwarding() {
|
|||||||
log WARN "Host watcher may not be running (trigger file still exists)"
|
log WARN "Host watcher may not be running (trigger file still exists)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
log INFO "Container should now be able to reach $TARGET_IP through this VM"
|
log INFO "Routing configured for $TARGET_IP through VPN tunnel"
|
||||||
echo ""
|
echo ""
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -454,9 +446,9 @@ show_totp() {
|
|||||||
show_network_status() {
|
show_network_status() {
|
||||||
log INFO "Current network status:"
|
log INFO "Current network status:"
|
||||||
|
|
||||||
# VM IPs
|
# Container IPs
|
||||||
echo ""
|
echo ""
|
||||||
log DEBUG "VM Network Interfaces:"
|
log DEBUG "Container Network Interfaces:"
|
||||||
ip -4 addr show | grep -E "inet |^[0-9]+:" | while IFS= read -r line; do
|
ip -4 addr show | grep -E "inet |^[0-9]+:" | while IFS= read -r line; do
|
||||||
echo -e " ${GRAY}│${NC} $line"
|
echo -e " ${GRAY}│${NC} $line"
|
||||||
done
|
done
|
||||||
@@ -473,16 +465,12 @@ show_network_status() {
|
|||||||
log WARN "VPN Status: ${RED}NOT CONNECTED${NC}"
|
log WARN "VPN Status: ${RED}NOT CONNECTED${NC}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Bridge IP (for container routing)
|
# Container IP on rego-tunnel network
|
||||||
local vm_bridge_ip=$(get_vm_bridge_ip)
|
local container_ip=$(get_container_ip)
|
||||||
if [ -n "$vm_bridge_ip" ]; then
|
if [ -n "$container_ip" ]; then
|
||||||
log DEBUG "VM IP on bridge: $vm_bridge_ip"
|
log DEBUG "Container IP: $container_ip"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Container gateway
|
|
||||||
local container_gw=$(get_container_gateway)
|
|
||||||
log DEBUG "Container gateway: $container_gw"
|
|
||||||
|
|
||||||
# Default gateway
|
# Default gateway
|
||||||
echo ""
|
echo ""
|
||||||
log DEBUG "Default gateway:"
|
log DEBUG "Default gateway:"
|
||||||
|
|||||||
Reference in New Issue
Block a user