PowerPanelC70/AR4.7 - Activate/Deactivate OPC Server programatically

Hello,

I’d like to activate/deactivate the opc-server depending on a setting.

So far I couldn’t find a function that allows me to toggle the server on/off.

I’m using a PPC70 with AR 4.7.

Maybe anyone has an idea?

Many thanks,

Torsten

Hi,

as I know there’s no possibility to switch OPC UA server on or off at runtime (at least without a reboot of the PLC).

But you could use the AR firewall to block or unblock the server port at runtime by using the correspondig library to change firewall rules.

Best regards!

1 Like

I’d like to try the firewall, but I fear creating the correct rules will be a difficult task.

Edit: would the rule to block the opc-server look like this?

block in quick proto tcp from any to me port = 4840

many thanks,

Torsten

Hi,

the firewall rules can be configured in configuration view, please see here:

When configuring a rule in the firewall in this interactive mode, the rule string of the configuration is also displayed and can help you defining the right one (unfortunately, the rule string cannot be copied directly).

If you want to block any request to OPCUA server, independent of the interface and the requesters IP range, your rule looks good. You could also use “from any to any”, which also ignores the destination IP address:
block in quick proto tcp from any to any port = 4840

Best regards!

1 Like

@Torsten_K, I forgot to mention that changes done by ArFirewall are stored permanently in the firewall configuration on the PLC as if it happens when using the Automation Studio configuration file + transfer.
So if you set a rule at runtime, the rule will stay active forever even after warm-/coldstart (which is good, but maybe not obvious), until you delete the rule set.

As you can’t delete single rules but only the whole rule set at runtime with ArFirewallDeleteAllRules(), your software has to set other wanted rules using ArFirewallAddRule() also after deletion of the complete rule set.

It’s not as tricky as it sounds, but worth to mention :wink:
So if you want to have more then one rule, you need to have all rules in your task and have to call ArFirewallAddRule() multiple times after deleting the rule set.

1 Like