Permalink
Find file
Fetching contributors…
Cannot retrieve contributors at this time
executable file 31 lines (27 sloc) 706 Bytes
#!/usr/bin/env ruby
DNS_SERVERS = {
:google => %w[ 8.8.8.8 8.8.4.4 ],
:level3 => %w[ 4.2.2.1 4.2.2.2 4.2.2.3 4.2.2.4 4.2.2.5 4.2.2.6 ],
:opendns => %w[ 208.67.222.222 208.67.220.220 ],
:linenode => %w[ 109.74.193.20 109.74.194.20 109.74.192.20 ],
:gwi => %w[ 207.5.171.1 207.5.171.9 ],
}
if ARGV.length < 1
puts "Set a nameserver from a list"
puts
puts "list - to get a list of choices"
puts "name - to set nameserver from list"
exit 0
end
if ARGV.to_s =~ /list/
DNS_SERVERS.each do |key,value|
puts key
end
else
File.open('/etc/resolv.conf', 'w+') do |file|
DNS_SERVERS[ARGV[0].to_sym].each do |ip|
file.puts "nameserver #{ip}"
end
#file.flush
end
end