Skip to content

Instantly share code, notes, and snippets.

@davividal
Created April 24, 2019 14:55
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save davividal/0518b75f9fb4fca86f29c6f33373f938 to your computer and use it in GitHub Desktop.
require "win32/registry"
interface_path = "SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters\\Interfaces"
Win32::Registry::HKEY_LOCAL_MACHINE.open(interface_path, Win32::Registry::KEY_READ) do |interfaces|
interfaces.each_key do |guid, _|
guid_path = "#{interface_path}\\#{guid}"
interface = Win32::Registry::HKEY_LOCAL_MACHINE.open(guid_path)
begin
puts "#{guid}:\n\tEnableDHCP => #{interface.read("EnableDHCP")[1]}"
puts "\tIPAddress => #{interface.read("IPAddress")[1]}"
puts "\tSubnetMask => #{interface.read("SubnetMask")[1]}"
rescue Win32::Registry::Error
begin
puts "\tDhcpIPAddress => #{interface.read("DhcpIPAddress")[1]}"
puts "\tDhcpSubnetMask => #{interface.read("DhcpSubnetMask")[1]}"
rescue
end
end
end
end
{1abb8efe-c0d5-4ddf-8e29-eae8499e92ba}:
EnableDHCP => 1
{34d34575-bc0d-4ca7-8571-97bccc35b437}:
EnableDHCP => 1
DhcpIPAddress => 172.29.5.30
DhcpSubnetMask => 255.255.254.0
{46666082-84ff-4888-8d75-31079e325934}:
EnableDHCP => 1
DhcpIPAddress => 172.29.5.24
DhcpSubnetMask => 255.255.254.0
{61e509a1-cffa-4b7f-8e7f-5a6991deba2b}:
EnableDHCP => 0
IPAddress => ["192.168.56.1"]
SubnetMask => ["255.255.255.0"]
{6c902ac7-4845-46d4-843e-2707e2270b0d}:
EnableDHCP => 0
IPAddress => ["0.0.0.0"]
SubnetMask => ["0.0.0.0"]
{6d2f3579-bc95-4a18-bed5-fb8b87b8673b}:
EnableDHCP => 0
{6e62da1a-5612-4ec5-9d2e-17cb9a4c65d0}:
EnableDHCP => 1
DhcpIPAddress => 10.242.0.49
DhcpSubnetMask => 255.255.254.0
{8a7759d6-ae7f-4c5f-8d01-072bce1e655c}:
EnableDHCP => 1
{93c36503-5fe8-47a1-bb94-d60825bbb432}:
EnableDHCP => 1
DhcpIPAddress => 172.29.5.51
DhcpSubnetMask => 255.255.254.0
{a4f02a00-fe11-4c77-8980-f8db46b00271}:
EnableDHCP => 1
{b22ae3e7-e077-410e-b631-3c47e9a230be}:
EnableDHCP => 0
IPAddress => ["172.28.128.1"]
SubnetMask => ["255.255.255.0"]
{ffed609c-8566-4abd-b4df-d4a044251ec0}:
EnableDHCP => 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment