Advertisement
Guest User

Untitled

a guest
Jul 24th, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. <?php
  2. ## Set up alternate DNS server
  3. #python:
  4. ###os.system("netsh interface ip add dns %s %s index=2" % (name, dns2))
  5. #
  6. function mylog ($what)
  7. {
  8. $f="/cygdrive/c/autoipdeploy.log";
  9. $x=file_get_contents($f);
  10. file_put_contents ($f, $x.$what);
  11. }
  12. mylog ("---------------start run ".date(DATE_RFC2822));
  13. exec ("/cygdrive/c/Program\ Files/VMware/VMware\ Tools/vmtoolsd.exe --cmd 'info-get guestinfo.cloudinit.metadata'", $output);
  14. //print_r ($output);
  15. $conf=json_decode(base64_decode($output[0]));
  16. print_r ($conf);
  17. //$conf->ipaddress="192.168.106.105";
  18. mylog (print_r ($conf,true));
  19.  
  20. // Get only first ethernet adapter name
  21. exec ('wmic nic where "netconnectionid like \'%\'" get netconnectionid',$wmic);
  22. //print_r ($wmic);
  23. $name=$wmic[1];
  24. mylog("got from wmic name of interface: $name\n");
  25. exec ("netsh interface ip set address $name static {$conf->ipaddress} {$conf->mask} {$conf->gateway} 0");
  26. mylog("done setting ip to {$conf->ipaddress}\n");
  27. exec ("netsh interface ip set dns $name static {$conf->dnsservers}");
  28. mylog("done setting dns to {$conf->dnsservers}\n");
  29. exit (0);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement