1

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...

V H
  • 8,382
  • 2
  • 28
  • 48

1 Answers1

2

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

Community
  • 1
  • 1
Synergist
  • 517
  • 4
  • 20
  • Thanks synergist, I been trying the additional setting in tomcat and still not got anywhere with it. I have updated the github link with findings and a simpler override method which is still not being triggered – V H Feb 17 '15 at 09:58
  • Wish I had given you the bounty. Still not got it working not had the time. I found a new angle from that link the jre java.security tried it which didn't work but wanna try a few variations be giving up. When I get some time – V H Feb 20 '15 at 20:00