Reputation: 8587
I been playing around with this for a few days and hit a brick wall
The problem has been documented on this readme:
https://github.com/vahidhedayati/grails-localdns/blob/master/README.md
Basically I am trying to override a dns entry for a given hostname... so eventually have a local db table that holds entry other than actual dns and to override the actual ip's to what is on DB (for testing purposes where cetain hostnames will work on an internal IP)
def index() {
System.setProperty("sun.net.spi.nameservice.provider.1", "dns,"+LocalManagedDnsDescriptor.DNS_PROVIDER_NAME)
System.setProperty("sun.net.spi.nameservice.provider.2", "dns,sun")
Security.setProperty("networkaddress.cache.ttl", "0")
def hostName = "google.com"
def ipAddress = "192.168.1.4"
NameStore.getInstance().put(hostName, ipAddress)
performLookup(hostName)
render "done lookup"
}
Basically no matter what I tried The LocalManagedDns is not being triggered...
Upvotes: 1
Views: 160
Reputation: 547
Try setting -Dsun.net.inetaddr.ttl=0
from the command line. I remember reading somewhere that the issue is that this property needs to be set before anything else in the JVM attempts to configure the network.
EDIT: I dug up the source I remembered reading: https://stackoverflow.com/a/17219327/1446892
Upvotes: 2