mirror of
https://github.com/freedbygrace/PSOPNSenseAPI.git
synced 2026-07-26 11:58:18 +00:00
Add port forwarding support, improve XML documentation, and add unit tests
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
# Import the module
|
||||
Import-Module PSOPNSenseAPI
|
||||
|
||||
# Connect to the OPNSense firewall
|
||||
Connect-OPNSense -Server "https://firewall.example.com" -ApiKey "your_api_key" -ApiSecret "your_api_secret" -SkipCertificateCheck
|
||||
|
||||
# Get the current connection information
|
||||
Get-OPNSenseConnection
|
||||
|
||||
# Get all firewall rules
|
||||
$rules = Get-OPNSenseFirewallRule
|
||||
$rules | Format-Table -Property Uuid, Description, Protocol, SourceNet, DestinationPort, Action
|
||||
|
||||
# Create a new firewall rule to allow HTTP traffic
|
||||
$ruleId = New-OPNSenseFirewallRule -Description "Allow HTTP" -Protocol TCP -DestinationPort 80 -Action pass
|
||||
Write-Output "Created rule with ID: $ruleId"
|
||||
|
||||
# Apply the changes
|
||||
Apply-OPNSenseFirewallChanges -CancelRollback -Timeout 30
|
||||
|
||||
# Disconnect from the firewall
|
||||
Disconnect-OPNSense
|
||||
Reference in New Issue
Block a user