Steven Erat's Blog
 
 
Viewing By Entry
 
 

TalkingTree  Configuring the Caching of Hostname Resolution for ColdFusion MX

 

ColdFusion network protocol tags such as CFHTTP, CFFTP, or CFLDAP will cache hostname-to-IP address resolution because this behavior is built into the default security properties of the JVM.

For example, if your local intranet DNS server or hosts file returns the IP 172.24.0.1 for a lookup of hostname corp1.company.com, and a CFHTTP call was made for the page http://corp1.company.com/data.csv, then for every subsequent CFML network protocol tag that attempts to access corp1.company.com the IP 172.24.0.1 will be used, until ColdFusion is restarted.

But what happens when one of the Network SysAdmins changes the DNS A record so that corp1.company.com now points to a slightly different IP address of 172.24.1.1 ?

; Zone file for company.com
$TTL 86400
@ IN SOA ns1.company.com. root.company.com (
200605230001 ; serial number
3H ; refresh
1M ; retry
2W ; expiration
1D ; minimum ttl
)
@ IN NS ns1.company.com.
company.com. IN NS ns2.company.com.
ns1.company.com. IN A 172.24.254.1
ns2 IN A 172.24.254.2
corp1 IN A 172.24.1.1
danger1 IN A 172.24.0.1
...

Until the ColdFusion server is restarted, the JVM will continue to use the old IP address instead of the updated one, and remote network access will either fail as unreachable, or worse, it will be accessing a different machine that was assigned the old IP of 172.24.0.1.

This behavior is by design according the the documentation for java.net.InetAddress:

InetAddress Caching
The InetAddress class has a cache to store successful as well as unsuccessful host name resolutions. The positive caching is there to guard against DNS spoofing attacks; while the negative caching is used to improve performance.

By default, the result of positive host name resolutions are cached forever, because there is no general rule to decide when it is safe to remove cache entries. The result of unsuccessful host name resolution is cached for a very short period of time (10 seconds) to improve performance.

Under certain circumstances where it can be determined that DNS spoofing attacks are not possible, a Java security property can be set to a different Time-to-live (TTL) value for positive caching. Likewise, a system admin can configure a different negative caching TTL value when needed.

Two Java security properties control the TTL values used for positive and negative host name resolution caching:

networkaddress.cache.ttl (default: -1) Indicates the caching policy for successful name lookups from the name service. The value is specified as as integer to indicate the number of seconds to cache the successful lookup.

A value of -1 indicates "cache forever".

networkaddress.cache.negative.ttl (default: 10) Indicates the caching policy for un-successful name lookups from the name service. The value is specified as as integer to indicate the number of seconds to cache the failure for un-successful lookups.

A value of 0 indicates "never cache". A value of -1 indicates "cache forever".

If you prefer to disable or reduce the TTL of the IP address caching and incur a small performance penalty for repeated hostname resolutions, then you can configure networkaddress.cache.ttl in the config file cf_root\runtime\jre\lib\security\java.security, or the equivalent if using another JVM. This property already exists in the file towards the bottom, although the default value is shown and is commented out. You can copy the line and paste the uncommented property below it with a custom value, then restart ColdFusion to make it take effect.

# The Java-level namelookup cache policy for successful lookups:
#
# any negative value: caching forever
# any positive value: the number of seconds to cache an address for
# zero: do not cache
#
# default value is forever (FOREVER). For security reasons, this
# caching is made forever when a security manager is set.
#
# NOTE: setting this to anything other than the default value can have
# serious security implications. Do not set it unless
# you are sure you are not exposed to DNS spoofing attack.
#
#networkaddress.cache.ttl=-1
#
# *** disable caching by setting this value to 0 ***
networkaddress.cache.ttl=0
#

 


Comments

Steve, someone asked me this once on my blog. Is cfinvoke with a web service controlled by this as well?


Yes. CFINVOKE is another type of network protocol tag. In short, anything that requires a hostname lookup will cache the IP result unless ColdFusion is restarted or the caching TTL is changed.




Thanks for the tip. I never realized CFHTTP technote existed on this.

Since the long Kanisa search URL seemed to have gotten mangled, here's the shorter link for that article: http://www.adobe.com/go/13115e61


 

 

Calendar

 
Sun Mon Tue Wed Thu Fri Sat
    1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31    

Search This Site

 
This is an exact search only

About This Site

 
I live west of Boston and work for Adobe with ColdFusion and Flex, and specialize in Linux. I'm also interested in travel and science, and I'm studyng photography at CDIA. Curious about my banner image?

More about me

Recent Entries

 
Creative Economy Director - M..

Recent Comments

 
Posted By Ben McDarmont:
I have often wondered whether Smashing Magazine contact the owners of the images they use in their posts, I just assumed they would have. Thanks for s ...

Posted By Stephanie:
oops, missing testpostmessage.cfm

Posted By Stephanie:
Hi Steven, My development server is running cf mx 7. I followed the instructions to import the certificate to cacerts but still getting Connection ...

recently played

 
Rick Smolan - America at Home
by Dr. Moira Gunn
on IT Conversations
IT Conversations, Dr. Moira Gunn

now playing, a plug-in for itunes

Categories

 
RSS Adobe (29)
RSS Bicycling (9)
RSS Blogging (37)
RSS Books (13)
RSS Breeze (12)
RSS CFMX Podcasts (10)
RSS ColdFusion (417)
RSS Computer Technology (49)
RSS Events (25)
RSS Flash (3)
RSS Flex (17)
RSS Gadgets (10)
RSS HiTech Industry (15)
RSS Java (25)
RSS Learning (54)
RSS Linux (70)
RSS Mac OS X (21)
RSS Macromedia (28)
RSS Meetup (34)
RSS New England (59)
RSS Odds & Ends (25)
RSS Outdoors (32)
RSS Personal (26)
RSS Photography (104)
RSS Photoshop (28)
RSS Podcasts (18)
RSS Rants (18)
RSS Restaurants (8)
RSS Science (34)
RSS Spain (16)
RSS Travel (42)
RSS Video (20)
RSS Webcam (3)
RSS Writing (10)

Blogs I Read

 
Scrum Sucks
Ben Forta
Ray Camden
Kinky Solutions
Gary Gilbert
Red Hat Blogs
O'Reilly Digital Media
O'Reilly Radar
John Nack
The Strobist
Scott Kelby
Matt Kloskowski
Joe McNally
Digital Photography School
Engadget
Science Blog

RSS

 


Add to Google
Add to My Yahoo!

Aggregated By

 


Consumed By Feed-Squirrel.com
Aggregated by ColdFusionBlogger.org

Credits and Stuff

 
BlogCFC - Free ColdFusion Powered Blog Software
CJM Group - ColdFusion Website Hosting


 
 
blog | photos | flickr | referers | webcam | stats | about | contact
 
Copyright © 2008 Steven Erat. All rights reserved.
This is a personal weblog. The opinions expressed here represent my own and not those of my employer