How to restrict remote access with a digital input?

How would I enable or disable the WAN using a digital input?
Based off the connector pinout on page 34 of the manual, I’m currently wired into DI1.

Assuming your device is currently setup and configured, you will need to start by creating a tag (configuration / tag setup). The tag will be a boolean type that uses the server name EWON and the address will be the Input you are currently using.

Once this tag is created, we just need to create a script in the BASIC IDE (main menu / configuration / basic IDE)

In the Basic IDE, go to the Init section.

You will copy and paste the following code:

ONCHANGE "Switch","goto DoSwitch"

Add a new section called DoSwitch by clicking the add button

Copy and paste the following code into this new section:

DoSwitch:
    If (Switch@=1) Then
    rem Open Internet connection
    Setsys COM,"load"
    Setsys COM,"WANCnx","2"
    Setsys COM,"WANPermCnx","1"
    Setsys COM,"save"
    Print Time$;" Connection opened"
else
    rem Close Internet connection
    Setsys COM,"load"
    Setsys COM,"WANCnx","0"
    Setsys COM,"save"
    Print Time$;" Connection closed"
endif

For more detailed information on using a switch to enable WAN or VPN connection,
please see the following document: