Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
windows-vm
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
pem
windows-vm
Commits
11270155
Commit
11270155
authored
Apr 23, 2025
by
César Galvis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: added traffic forwarding script
parent
ea44cfdd
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
56 additions
and
5 deletions
+56
-5
Vagrantfile
Vagrantfile
+2
-5
EnableTrafficForwarding.ps1
src/scripts/ps/EnableTrafficForwarding.ps1
+54
-0
No files found.
Vagrantfile
View file @
11270155
...
...
@@ -34,10 +34,7 @@ Vagrant.configure("2") do |config|
config
.
vm
.
provision
"shell"
,
path:
"src/scripts/ps/ChocolateyInstallPackages.ps1"
## Wireguard Install and setup
config
.
vm
.
provision
"shell"
,
path:
"src/scripts/ps/WireguardInstall.ps1"
## Reboot computer after provisioning
config
.
trigger
.
after
[
:provision
]
do
|
t
|
t
.
name
=
"Reboot after provisioning"
t
.
run
=
{
:inline
=>
"vagrant reload"
}
end
## Enable traffic forwarding
config
.
vm
.
provision
"shell"
,
path:
"src/scripts/ps/EnableTrafficForwarding.ps1"
end
src/scripts/ps/EnableTrafficForwarding.ps1
0 → 100644
View file @
11270155
# === CONFIGURATION ===
# Name of the VPN interface (Fortinet client) and the WireGuard interface
$vpnInterfaceName
=
"Fortinet"
# Change if different
$wgInterfaceName
=
"WireGuard"
# === HELPER FUNCTION ===
function
Enable-ICS
{
param
(
[
string
]
$SharedInterface
,
[
string
]
$TargetInterface
)
$networkListManager
=
New-Object
-ComObject HNetCfg.HNetShare
$connections
=
$networkListManager
.EnumEveryConnection
()
foreach
(
$conn
in
$connections
)
{
$props
=
$networkListManager
.NetConnectionProps
(
$conn
)
$config
=
$networkListManager
.INetSharingConfigurationForINetConnection
(
$conn
)
if
(
$props
.Name -eq
$SharedInterface
)
{
# Enable sharing on the VPN interface
if
(
-not
$config
.SharingEnabled
)
{
Write-Host
"→ Enabling ICS on '
$SharedInterface
'"
$config
.EnableSharing
(
0
)
# 0 = outbound
}
}
if
(
$props
.Name -eq
$TargetInterface
)
{
# Check if sharing is already enabled on the target interface
if
(
$config
.SharingEnabled
)
{
Write-Host
"ICS is already enabled on '
$TargetInterface
'"
}
else
{
Write-Host
"ICS does not need to be enabled on '
$TargetInterface
'"
}
}
}
}
# === VERIFY INTERFACES ===
$netAdapters
=
Get-NetAdapter
$vpnFound
=
$netAdapters
|
Where
-Object
{
$_
.InterfaceDescription -like
"*
$vpnInterfaceName
*"
}
$wgFound
=
$netAdapters
|
Where
-Object
{
$_
.InterfaceDescription -like
"*
$wgInterfaceName
*"
}
if
(
-not
$vpnFound
)
{
Write-Host
"Could not find VPN interface '
$vpnInterfaceName
'"
exit
1
}
if
(
-not
$wgFound
)
{
Write-Host
"Could not find WireGuard interface '
$wgInterfaceName
'"
exit
1
}
# === APPLY ICS ===
Enable-ICS -SharedInterface
$vpnFound
.Name -TargetInterface
$wgFound
.Name
Write-Host
"ICS enabled: '
$vpnInterfaceName
' + '
$wgInterfaceName
'"
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment