Rule



With Rule object you can access to count of Actions (Events) in Rule, Rule properties, methods.

 

Example:

 

'netcom.dll contains 'NetCom.Remote' object.

Set Remote = CreateObject("NetCom.Remote")

 

With Remote

       .Host = "192.168.0.1"

       .Port = 42566

       .UserName = "Administrator"

       .Password = "mypass"

       'Connect and query remote TrafficFilter object

       Set TrafficFilter = .CreateRoot

End With

 

Set Rules = TrafficFilter.Rules

With Rules

       'Add new rule as first in list

       .Insert 0, "NATRule"

 

       'Find new added rule

       Set Rule = .FindByName("NATRule")

       With Rule

               .Enabled = False

               'Allow packets

               .Action = 1

 

               'NAT source IP automatically

               .ActionsRoute.ChangeSourceIP = True

               .ActionRouteSourceIPAuto = True

 

               'NAT source port automatically

               .ActionsRoute.ChangeSourcePort = True

               .ActionRouteSourcePortAuto = True

 

               'Enable addition packet information to the NAT table

               .ActionRouteNAT = True

 

               'Specify conditions

               .ConditionPacketsDirection = 1 'Outgoing to network packets

               .ConditionIPSource.AsString = "192.168.0.5"

               .ConditionIPOperatorSource = 1 'Equal to ConditionIPSource

               .ConditionIPRangeDest.AddAsStringRange "192.168.0.0", "192.168.0.255"

               .ConditionIPOperatorDest = 4 'NOT in ConditionIPRangeDest range

 

               .Enabled = True

       End With

 

       'Force configuration saving (normally configuration saved every 3 minutes automatically)

       TrafficFilter.ForceSaveConfig

 

       WScript.Echo "Added new rule with name " & Rule.Name

End With

 

Set Rule = Nothing

Set Rules = Nothing

Set TrafficFilter = Nothing

Remote.Disconnect

Set Remote = Nothing

 

WScript.Echo vbCrLf & "Press any key..."

WScript.StdIn.Read(1)