1.1.1.1 test.example.com
2.2.2.2 test.example.com
我用下面的函数获取主机的ip地址,我想得到dns的ip地址,当有人修改我的主机错误ip,puppet facter得到正确的ip覆盖IOSocket.getaddress( 'test.example.com')
答案 0 :(得分:2)
示例:
require 'resolv'
dns = Resolv::DNS.new( :nameserver => ['8.8.8.8'] )
ip = dns.getaddress( 'test.example.com' )