#!/usr/bin/ruby
puts "Enter the IP Address of the New DNS Servers - Note this will overwrite all current Entrys"
dns_ip1 = gets.chomp
puts "You entered #{dns_ip1}, would you like to add another ip? Answer Yes or No"
dns_answer = nil
loop do
dns_answer = gets.chomp
if %w(Yes Y yes YES y).include?(dns_answer)
puts "Please Enter the Second IP e.g 1.2.3.4"
dns_ip2 = nil
loop do
dns_ip2 = gets.chomp
if !%w(1 2 3 4 5 6 7 8 9).include?(dns_ip2) && !%w(.).include?(dns_ip2)
puts "You must Enter an IPv4 Address with Standard Dot Notation"
else
break
end
end
elsif
%W(No N no NO n).include?(dns_answer)
puts "OK, the DNS Entrys have been updated"
dns_change1 = `echo "nameserver #{dns_ip1}" > /etc/resolv.conf`
dns_table2 = `cat /etc/resolv.conf`
puts "#{dns_table2}"
else
"Puts You must Enter either Yes or No"
end
puts "The DNS Configuration Table has been updated to include the entrys #{dns_ip1} #{dns_ip2}"
puts
dns_change2 = `echo "nameserver #{dns_ip1}" > /etc/resolv.conf`
dns_change3 = `echo "nameserver #{dns_ip2}" >> /etc/resolv.conf`
puts
dns_table3 = `cat /etc/resolv.conf`
puts "#{dns_table3}"
break
end