Oct 19, '05 06:20:00AM • Contributed by: freemacware.com
- Open Terminal and type pico activatedmz to open a new document for editing.
- Paste in the following two lines of code. This code assumes the Linksys default IP address 192.168.1.1 and default password admin -- hopefully you've changed that! So make any changes if necessary. Remove the line wraps shown in each line, replacing them with a space to make two long lines of code:
Line #1: lastdigit=`ifconfig | grep netmask | grep -v 127.0.0.1 | awk {'print $2'} | sed 's/192.168.1.//'` Line #2: curl http://192.168.1.1/apply.cgi -d "submit_button=DMZ&change_action=&action=Apply &dmz_enable=1&dmz_ipaddr=$lastdigit" -u admin:admin -s > /dev/null - Hit Ctrl-X, then Y to save the document and close pico.
- Type chmod u+x activatedmz to make the script executable.
- Type ./activatedmz to run the script and expose your computer to the internet.
Line #1: curl http://192.168.1.1/apply.cgi
-d "submit_button=DMZ&change_action=&action=Apply&dmz_enable=0&dmz_ipaddr=0"
-u admin:admin -s > /dev/null
Again, type chmod u+x deactivatedmz to make it executable, then type ./deactivatedmz to run it. I found it helpful to use Platypus to turn these UNIX scripts into GUI apps. I now have an "Activate DMZ" and a "Deactivate DMZ" icon in my Dock -- easy as a light switch. If you want to know how this works, or do this with a different brand of router, keep reading for a behind-the-scenes look.Here's how I figured this out...
- Install the Web Developer Extension for Firefox.
- Open your router configuration page (at http://192.168.1.1 or whatever) in Firefox. Go to the DMZ page.
- On the Web Developer Extension toolbar, click Forms, then click Convert POSTs to GETs
- Fill out the DMZ page (to turn it on) and hit submit.
- You should see a long URL in the address bar -- copy it somewhere. Everything before the question mark (?) is the address of the form. Everything after the question mark is the list of variables to submit. For example, this was my URL (with line breaks for a narrower display):
You'll notice the variables dmz_enable=1 and dmz_ipaddr=3, which activate the DMZ for my IP address 192.168.1.3. To deactivate the DMZ, I have to change the variables to dmz_enable=0 and dmz_ipaddr=0.http://192.168.1.1/apply.cgi?submit_button=DMZ &change_action=&action=Apply&dmz_enable=1&dmz_ipaddr=3
- ifconfig | grep netmask | grep -v 127.0.0.1 | awk {'print $2'} - returns the local IP address 192.168.1.3
- sed 's/192.168.1.//' - strips out the first three numbers and returns just the 3
- lastdigit=`` - saves the 3 to a variable called $lastdigit
- curl http://192.168.1.1/apply.cgi - the address of the form (everything before the ? from above)
- -d "submit_button=DMZ&change_action=&action=Apply&dmz_enable=1&dmz_ipaddr=$lastdigit" - the variables (everything after the ?)
- -u admin:admin - the username and password of your router
- -s > /dev/null - silences the output
