Created
January 13, 2016 13:08
-
-
Save molayli/7efc7c2ec96eb8e1b352 to your computer and use it in GitHub Desktop.
simple ruby script to update OpenDNS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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