This commit is contained in:
2026-01-17 16:33:22 +00:00
parent 1bd5a21a94
commit 84b1eb3f5d

View File

@@ -10,7 +10,7 @@ VPN_TOTP_SECRET="${VPN_TOTP_SECRET:-}"
VPN_HOST="${VPN_HOST:-}" VPN_HOST="${VPN_HOST:-}"
TARGET_IP="${TARGET_IP:-}" TARGET_IP="${TARGET_IP:-}"
VPN_INTERFACE="${VPN_INTERFACE:-tun0}" VPN_INTERFACE="${VPN_INTERFACE:-tun0}"
IBMI_HOST="10.3.1.201"
# Log directory # Log directory
LOG_DIR="/var/log/openconnect-vpn" LOG_DIR="/var/log/openconnect-vpn"
@@ -164,6 +164,7 @@ show_help() {
echo " VPN_HOST VPN server hostname" echo " VPN_HOST VPN server hostname"
echo " TARGET_IP Target IP for connectivity test" echo " TARGET_IP Target IP for connectivity test"
echo " VPN_INTERFACE TUN interface name (default: tun0)" echo " VPN_INTERFACE TUN interface name (default: tun0)"
echo " IBM_HOST IBM i Host"
} }
get_vpn_interface() { get_vpn_interface() {
@@ -402,9 +403,9 @@ connect_vpn() {
setup_forwarding setup_forwarding
# Test connection if TARGET_IP is set # Test connection if TARGET_IP is set
if [[ -n "$TARGET_IP" ]]; then if [[ -n "$IBMI_HOST" ]]; then
log INFO "Testing connection to $TARGET_IP..." log INFO "Testing connection to $IBMI_HOST..."
if ping -c 2 -W 3 "$TARGET_IP" &>/dev/null; then if ping -c 2 -W 3 "$IBMI_HOST" &>/dev/null; then
log INFO "Connection test: ${GREEN}SUCCESS${NC}" log INFO "Connection test: ${GREEN}SUCCESS${NC}"
else else
log WARN "Connection test: ${RED}FAILED${NC}" log WARN "Connection test: ${RED}FAILED${NC}"
@@ -513,11 +514,11 @@ while true; do
2) disconnect_vpn ;; 2) disconnect_vpn ;;
3) check_vpn_status ;; 3) check_vpn_status ;;
4) setup_forwarding ;; 4) setup_forwarding ;;
5) if [[ -n "$TARGET_IP" ]]; then 5) if [[ -n "$IBMI_HOST" ]]; then
log INFO "Testing connection to $TARGET_IP..." log INFO "Testing connection to $IBMI_HOST..."
ping -c 3 "$TARGET_IP" && log INFO "Connection test: ${GREEN}SUCCESS${NC}" || log ERROR "Connection test: ${RED}FAILED${NC}" ping -c 3 "$IBMI_HOST" && log INFO "Connection test: ${GREEN}SUCCESS${NC}" || log ERROR "Connection test: ${RED}FAILED${NC}"
else else
log WARN "TARGET_IP not set" log WARN "IBMI_HOST not set"
fi ;; fi ;;
6) show_network_status ;; 6) show_network_status ;;
7) show_routes ;; 7) show_routes ;;