A number of us indulge in a little mayhem during lunchtime at work in the form of running around with guns shooting each other. Or at least, we play Raven Shield. To avoid network issues we “turn off” DNS and have to remember to turn it back on after we have beaten each other to a pulp, or worse. If we don’t PerlMonks doesn’t work any more :(
A workmate wrote the code below and I added to it slightly. It changes the DNS server address to the local machine, launches Raven Shield, then restores the DNS server when Raven Shield exits. Enjoy.
use strict; use warnings; # change these to work with your machine. my $interface_name = "Local Area Connection"; my $RSPath = 'C:\games~~\Red Storm Entertainment\RavenShield'; # Get current IP my $config = `ipconfig`; $config =~ /IP Address[. :]+([\d.]*)/; my $myIP = $1; munt(); show(); launch(); unmunt(); show(); sub launch { print `$RSPath/system/RavenShield.exe`; } sub munt { print `netsh interface ip set dns "$interface_name" static $myIP`; } sub unmunt { print `netsh interface ip set dns "$interface_name" dhcp`; } sub show { print `netsh interface ip show dns`; }
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |