Can I perform a DNS lookup (hostname to IP address) using client-side Javascript?

Edit: This question gave me an itch, so I put up a JSONP webservice on Google App Engine that returns the clients ip address. Usage: <script type=”application/javascript”> function getip(json){ alert(json.ip); // alerts the ip address } </script> <script type=”application/javascript” src=”http://jsonip.appspot.com/?callback=getip”> </script> Yay, no server proxies needed. Pure JS can’t. If you have a server script … Read more

How can I do DNS lookups in Python, including referring to /etc/hosts?

I’m not really sure if you want to do DNS lookups yourself or if you just want a host’s ip. In case you want the latter, /!\ socket.gethostbyname is deprecated, prefer socket.getaddrinfo from man gethostbyname: The gethostbyname*(), gethostbyaddr*(), […] functions are obsolete. Applications should use getaddrinfo(3), getnameinfo(3), import socket print(socket.gethostbyname(‘localhost’)) # result from hosts file … Read more

Set up Heroku and GoDaddy? [closed]

[Updated 31.10.2014] Allright! It works! Here is how I did it from scratch, so others with the same problem can fix it too. First I will explain how to setup Heroku and GoDaddy, then I will explain how to create a naked domain (www.example.com -> example.com). Setup Heroku and GoDaddy: In your project folder in … Read more

Get the subdomain from a URL

Anyone have any great ideas besides storing a list of all TLDs? No, because each TLD differs on what counts as a subdomain, second level domain, etc. Keep in mind that there are top level domains, second level domains, and subdomains. Technically speaking, everything except the TLD is a subdomain. In the domain.com.uk example, “domain” … Read more

Does hosts file exist on the iPhone? How to change it? [closed]

Another option here is to have your iPhone connect via a proxy. Here’s an example of how to do it with Fiddler (it’s very easy): http://conceptdev.blogspot.com/2009/01/monitoring-iphone-web-traffic-with.html In that case any dns lookups your iPhone does will use the hosts file of the machine Fiddler is running on. Note, though, that you must use a name … Read more

How to make Java honor the DNS Caching Timeout?

Per Byron’s answer, you can’t set networkaddress.cache.ttl or networkaddress.cache.negative.ttl as System Properties by using the -D flag or calling System.setProperty because these are not System properties – they are Security properties. If you want to use a System property to trigger this behavior (so you can use the -D flag or call System.setProperty), you will … Read more