6.5 KiB
Set-OPNSenseFirewallRule
SYNOPSIS
Modifies an existing firewall rule on an OPNSense firewall.
SYNTAX
Set-OPNSenseFirewallRule -UUID <String> [-Action <String>] [-Interface <String>] [-Protocol <String>] [-Source <String>]
[-SourcePort <String>] [-Destination <String>] [-DestinationPort <String>] [-Description <String>]
[-Enabled <Boolean>] [-Direction <String>] [-IPProtocol <String>] [-Gateway <String>] [-Log <Boolean>]
[-Sequence <Int32>] [-Category <String>] [-WhatIf] [-Confirm]
DESCRIPTION
The Set-OPNSenseFirewallRule cmdlet modifies an existing firewall rule on an OPNSense firewall.
EXAMPLES
Example 1: Modify a firewall rule
Set-OPNSenseFirewallRule -UUID "a1b2c3d4-e5f6-7890-abcd-ef1234567890" -Description "Updated rule description" -Log $true
This example updates the description and enables logging for an existing firewall rule.
Example 2: Modify multiple properties of a firewall rule
Set-OPNSenseFirewallRule -UUID "a1b2c3d4-e5f6-7890-abcd-ef1234567890" -Action "block" -Protocol "tcp/udp" -DestinationPort "3389,5900" -Description "Block remote access"
This example updates multiple properties of an existing firewall rule to block remote access protocols.
PARAMETERS
-UUID
The UUID of the firewall rule to modify.
Type: String
Parameter Sets: (All)
Aliases:
Required: True
Position: Named
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False
-Action
The action to take for the rule (pass, block, reject).
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
-Interface
The interface to apply the rule to.
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
-Protocol
The protocol for the rule (tcp, udp, tcp/udp, icmp, etc.).
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
-Source
The source address or network for the rule.
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
-SourcePort
The source port for the rule.
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
-Destination
The destination address or network for the rule.
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
-DestinationPort
The destination port for the rule.
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
-Description
A description for the rule.
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
-Enabled
Whether the rule is enabled.
Type: Boolean
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
-Direction
The direction for the rule (in, out).
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
-IPProtocol
The IP protocol version for the rule (inet, inet6).
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
-Gateway
The gateway to use for the rule.
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
-Log
Whether to log matches for the rule.
Type: Boolean
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
-Sequence
The sequence number for the rule.
Type: Int32
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
-Category
The category for the rule.
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
-WhatIf
Shows what would happen if the cmdlet runs. The cmdlet is not run.
Type: SwitchParameter
Parameter Sets: (All)
Aliases: wi
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
-Confirm
Prompts you for confirmation before running the cmdlet.
Type: SwitchParameter
Parameter Sets: (All)
Aliases: cf
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.
INPUTS
System.String
You can pipe a string containing the UUID of a firewall rule to this cmdlet.
OUTPUTS
System.Object
Returns an object representing the modified firewall rule.
NOTES
This cmdlet requires a connection to an OPNSense firewall. Use Connect-OPNSense to establish a connection. After modifying firewall rules, you need to apply the changes using Apply-OPNSenseFirewallChanges.
RELATED LINKS
Get-OPNSenseFirewallRule New-OPNSenseFirewallRule Remove-OPNSenseFirewallRule Enable-OPNSenseFirewallRule Disable-OPNSenseFirewallRule Apply-OPNSenseFirewallChanges