As I understand it, you want to be able to go to a particular web page on your computer, and that will make the computer run a script that will manipulate your dhcp setting. As SaveTheRbtz said, this is not the secure way to go about it.
When you're running a web server, you want to be sure that any scripts run by the web server have a very limited access to do things on your server. Otherwise, any small mistake in your scripts may lead to some script kiddie getting root on your server and abusing it.
So, if you have a script that needs root access, that script should not be run by the webserver user. I would instead use a somewhat more complex setup:
- Create a CGI script that will only write an entry to a file. This requires minimal rights, and done properly (i.e. by overwriting the previous entry instead of adding to it) it will not even risk filling up your disk if someone were to hit it multiple times.
- Create a cron job that regularly checks that file to see if it's been changed. If so, run the script. The cron job can be owned and run by root, thus requiring no extra sudo setup.
This way, the web server user is completely isolated from what the script does that needs root access.