Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- ## Set up alternate DNS server
- #python:
- ###os.system("netsh interface ip add dns %s %s index=2" % (name, dns2))
- #
- function mylog ($what)
- {
- $f="/cygdrive/c/autoipdeploy.log";
- $x=file_get_contents($f);
- file_put_contents ($f, $x.$what);
- }
- mylog ("---------------start run ".date(DATE_RFC2822));
- exec ("/cygdrive/c/Program\ Files/VMware/VMware\ Tools/vmtoolsd.exe --cmd 'info-get guestinfo.cloudinit.metadata'", $output);
- //print_r ($output);
- $conf=json_decode(base64_decode($output[0]));
- print_r ($conf);
- //$conf->ipaddress="192.168.106.105";
- mylog (print_r ($conf,true));
- // Get only first ethernet adapter name
- exec ('wmic nic where "netconnectionid like \'%\'" get netconnectionid',$wmic);
- //print_r ($wmic);
- $name=$wmic[1];
- mylog("got from wmic name of interface: $name\n");
- exec ("netsh interface ip set address $name static {$conf->ipaddress} {$conf->mask} {$conf->gateway} 0");
- mylog("done setting ip to {$conf->ipaddress}\n");
- exec ("netsh interface ip set dns $name static {$conf->dnsservers}");
- mylog("done setting dns to {$conf->dnsservers}\n");
- exit (0);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement