Home > Fluid Dynamics Search Engine > Help > 1107

How to force or override DNS lookups

Forcing or overriding DNS responses is intended to work around the following problems:

FDSE caches all DNS lookups for the lifetime of the FDSE process. DNS queries are stored in the network client hash in the form:

$$p_nc_cache{"H:www.yahoo.com"} = pack('C4',split(m!\.!,''));
	# means www.yahoo.com ==

All DNS queries are isolated to the subroutine leansock which is defined in the library "common_admin.pl". Queries are done with gethostbyname if and only if there is not already an "H:host" entry in the cache. So, to override or force a DNS response, simply customize the first few lines of leansock from:

sub leansock {
	my ($host,$port,$p_socket,$p_nc_cache) = @_;
	my $err = '';


sub leansock {
	my ($host,$port,$p_socket,$p_nc_cache) = @_;
	$$p_nc_cache{"H:www.xav.com"} = pack('C4',split(m!\.!,''));
	$$p_nc_cache{"H:www.whitehouse.gov"} = pack('C4',split(m!\.!,''));
	my $err = '';

Enter as many overrides as needed, one per line, before the initialization of the $err string. All DNS lookups will now resolve to your custom IP addresses.

Obviously, this method is poor because if the DNS names ever start to resolve to a different IP address, you will have to customize your source code again, and in the meantime there may be some hard-to-debug errors. This solution is also not practical for FDSE instances where you plan to spider many different sites. Getting your system administrators to configure valid DNS entries and to run on normal architectures is a much better solution.

* In these cases you also may want to build your index files on a remote system where DNS works normally, and then simply FTP the completed index files up to your main search server. See Building index files remotely.

** In these cases, you might also be able to use "file system discovery" realms to bypass the network issues altogether. From the Admin Page, go to "Manage Realms" and then "Create New Realm". For web sites hosted on the same physical web server as FDSE, you can create a realm using File System Discovery by entering the folder that holds the web site files on the Create New Realm page.

History: the code sample above about subroutine leansock will work with FDSE versions back through All versions of FDSE have used a global hash to cache DNS lookups, but in earlier versions that caching code was located in different places. In those earlier versions, searching on "gethostbyname" should take you directly to the lookup code.

    "How to force or override DNS lookups"