Skip to content

Instantly share code, notes, and snippets.

@molayli
Created January 13, 2016 13:08
Show Gist options
  • Save molayli/7efc7c2ec96eb8e1b352 to your computer and use it in GitHub Desktop.
Save molayli/7efc7c2ec96eb8e1b352 to your computer and use it in GitHub Desktop.
simple ruby script to update OpenDNS
require 'net/http'
require 'openssl'
hostname = 'HOSTNAME_TO_UPDATE'
username = 'USERNAME_HERE'
password = 'PASSWORD_HERE'
puts "=================================="
puts "Authenticating ...."
puts "=================================="
uri = URI("https://updates.opendns.com/nic/update?hostname=#{hostname}")
Net::HTTP.start(uri.host, uri.port,
:use_ssl => uri.scheme == 'https',
:verify_mode => OpenSSL::SSL::VERIFY_NONE) do |http|
request = Net::HTTP::Get.new uri.request_uri
request.basic_auth username, password
response = http.request request
puts response.body
end
puts "=================================="
puts "Done!"
puts "=================================="
gets
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment