Host files in Windows CE

Windows has the ability to link hosts to specific IP addresses. Think of it as a DNS bypass system. In our warehouse setup, the wireless infrastructure is completely self contained - it does not have any access to our domain infrastructure except for TCP port 80 access to one web server. This means that our wireless infrastructure does not have access to DNS.

We get around this by configuring our devices to convert a host name to an IP address in the HOSTS entries that Windows supports. It's probably not the most practical way to do things but I'm sure other developers will find a better use for the information enclosed in this blog post.

The Windows CE 5 & 6 host entries are entered into the registry in the following location, and the IP octets are entered in HEX. To persist this on your device, create a registry file (EG: hosts.reg) in the "\Application" folder and place 1 entry in the reg file per host name you wish to redirect.

REGEDIT4

[HKEY_LOCAL_MACHINE\Comm\Tcpip\Hosts\SERVERNAME]
"ipaddr"=hex:0a,14,1e,01

After a cold boot, your registry file will be automatically merged into the registry.

Update: If you are looking to use IPv6, you will need to use the attribute "ipaddr6" rather than "ipaddr". The value will obviously need to be 20 bytes, rather than the 4 bytes used by IPv4.

Comments

  1. Hey guy,

    How to insert an IPV6 address hosts record into the wince registry? Does Wince support it?
    Appreciate for your kindly reply.

    ReplyDelete
  2. This comment has been removed by the author.

    ReplyDelete
  3. I've never had to configure IPv6 on these devices. The MS documentation about dual stack DNS resolution only mentions DNS and WINS servers, no mention of host entries.

    Have you tried putting the hex value for your IP address in the same registry value? The above is just the 32 bit hex value of an IPv4 address, maybe just putting the 64 bit address in will work? I If not, try using a CERegEditor to browse the registry and see if there is a V6 version of the entries above

    ReplyDelete
  4. I have updated the main post for IPv6 - all you need to do is use a slightly different registry value to utilise IPv6 in the CE hosts entries.

    ReplyDelete

Post a Comment