- Start VPN gateways support implementation.

This commit is contained in:
2025-08-23 11:58:29 +02:00
parent 7a2bd651d7
commit 67f1ec7de8
7 changed files with 115 additions and 18 deletions

View File

@@ -1,5 +1,13 @@
------------------------------------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------------------------------------
Network Rools V 1.0.0 - A. GIBERT - 2025/08/12 Network Tools V 1.1.0 - A. GIBERT - 2025/09/??
------------------------------------------------------------------------------------------------------------------------------------
- Add VPN Gateway support.
------------------------------------------------------------------------------------------------------------------------------------
Network Tools V 1.0.0 - A. GIBERT - 2025/08/12
------------------------------------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------------------------------------
- Initial release, - Initial release,

View File

@@ -341,7 +341,7 @@ log_print()
file_lock "${lock_file}" WRITE 8 file_lock "${lock_file}" WRITE 8
fi fi
printf >> "${log_file}" "%s %9s %3s %8s %s\n" "$(date --rfc-3339=seconds -u)" "($BASHPID)" "${log_type}" "${log_prefix}:" "$*" printf >> "${log_file}" "%s %9s %3s %16s %s\n" "$(date --rfc-3339=seconds -u)" "($BASHPID)" "${log_type}" "${log_prefix}:" "$*"
if [[ "${lock_file}" != "" ]] if [[ "${lock_file}" != "" ]]
then then

View File

@@ -0,0 +1,42 @@
#!/bin/bash
#DEBUG=""
#DEBUG="echo"
#DEBUG=":"
#LOG=":"
#LOG="echo"
#LOG=""
# Includes
#-----------------------------------------------------------------------------------------------------------------------------------
. /usr/local/lib/network.bash
# Global Variables
#-----------------------------------------------------------------------------------------------------------------------------------
#LOG_FILE=/var/log/openvpn/up-down.log
# Main
#-----------------------------------------------------------------------------------------------------------------------------------
network_init
line="[${dev}]: Local_Int_Address: [${ifconfig_local}] Remote_Int_Address: [${ifconfig_pool_remote_ip}] Remote_Ext_Addres: [${untrusted_ip}] Common_Name: [${common_name}] Duration: [${time_duration}]"
log_info "VPN-Client-Down" "$line" " Status: [OK]"
touch /etc/openvpn/status/${common_name}.status
log_trace "VPN-Client-Down" "[${dev}]: Done!"

View File

@@ -0,0 +1,45 @@
#!/bin/bash
#DEBUG=""
#DEBUG="echo"
#DEBUG=":"
#LOG=":"
#LOG="echo"
#LOG=""
# Includes
#-----------------------------------------------------------------------------------------------------------------------------------
. /usr/local/lib/network.bash
# Global Variables
#-----------------------------------------------------------------------------------------------------------------------------------
#LOG_FILE=/var/log/openvpn/up-down.log
# Main
#-----------------------------------------------------------------------------------------------------------------------------------
Output_Param_File="$1"
network_init
line="[${dev}]: Local_Int_Address: [${ifconfig_local}] Remote_Int_Address: [${ifconfig_pool_remote_ip}] Remote_Ext_Addres: [${untrusted_ip}] Common_Name: [${common_name}] Output_Param_File: [${Output_Param_File}]"
log_info "VPN-Client-Up" "$line" " Status: [OK]"
touch /etc/openvpn/status/${common_name}.status
log_trace "VPN-Client-Up" "[${dev}]: Done!"

View File

@@ -28,12 +28,12 @@
# Main # Main
#----------------------------------------------------------------------------------------------------------------------------------- #-----------------------------------------------------------------------------------------------------------------------------------
Dev="$1" Dev="$1"
Local_MTU="$2" Local_MTU="$2"
Remote_MTU="$3" Remote_MTU="$3"
Local_Address="$4" Local_Address="$4"
Local_Netmask="$5" Local_Netmask="$5"
Phase="$6" Phase="$6"
network_init network_init
@@ -43,7 +43,7 @@ network_dst_tab_dev_lookup "${Dev}"
network_dst_tab_get "${dst_id}" network_dst_tab_get "${dst_id}"
line="[${Dev}]: Local_MTU: [${Local_MTU}] Remote_MTU: [${Remote_MTU}] Local_Address: [${Local_Address}] Local_Netmask: [${Local_Netmask}] Dst_Table: ${dst_table} Phase: ${Phase}" line="[${Dev}]: Local_MTU: [${Local_MTU}] Remote_MTU: [${Remote_MTU}] Local_Address: [${Local_Address}] Local_Netmask: [${Local_Netmask}] Dst_Table: [${dst_table}] Phase: [${Phase}]"
if [[ "${dst_table}" != "" ]] if [[ "${dst_table}" != "" ]]
then then

View File

@@ -29,12 +29,12 @@
# Main # Main
#----------------------------------------------------------------------------------------------------------------------------------- #-----------------------------------------------------------------------------------------------------------------------------------
Dev="$1" Dev="$1"
Local_MTU="$2" Local_MTU="$2"
Remote_MTU="$3" Remote_MTU="$3"
Local_Address="$4" Local_Address="$4"
Local_Netmask="$5" Local_Netmask="$5"
Phase="$6" Phase="$6"
network_init network_init

View File

@@ -686,7 +686,9 @@ else
if [[ ( ${admin} == "true") || ( "${REMOTE_USER}" == "${src_owner}") ]] if [[ ( ${admin} == "true") || ( "${REMOTE_USER}" == "${src_owner}") ]]
then then
sudo /usr/local/sbin/rx3_net_adm table_set ${ip} $((${vpn} + 3)) 1>&2 network_dst_tab_get "${vpn}"
sudo /usr/local/sbin/rx3_net_adm table_set ${ip} ${dst_table} 1>&2
if [[ "$?" == 0 ]] if [[ "$?" == 0 ]]
then then