DD-WRT is a software running on many routers, see also http://www.dd-wrt.com.
The shell script that is given below allows one to enable or disable the WAN interface of such a router, using curl from the command line. It further allows one to query the current router WAN interface state, i.e., to find out whether the latter interface is enabled or disabled. And, finally, the router can be rebooted.
To obtain usage information the present script should be invoked without arguments. The present script design is for the DD-WRT v24 firmware. It has successfully been tested under Debian Lenny with curl 7.18.2.
A special feature is that the script blocks until the router has reached the desired state, being useful for unattended operation in batch mode. When called with -a, for allow, or, with -q, for query, the latter in the case the WAN interface is enabled, the current WAN interface IPv4 address is returned.
To get some knowledge what happens inside the script below, one has to glance over the code, i.e., there is no further documentation available.
The current release is DdwrtControl. Security-relevant data is stored in a file which might look like /etc/SmallSystemsAccessData. The access to that file should be limited, perhaps in accordance with
$ ls -al /etc/SmallSystemsAccessData -rw-r----- 1 root iip 688 Sep 21 22:31 /etc/SmallSystemsAccessData $
such that only root and all the members of the group iip can read it.