On Windows, how do you refresh the hosts file without rebooting?
ipconfig /flushdns will flush the local dns cache.
nbtstat -R will flush netbios cache. <----- Should be with Capital "R"
You may want to ensure there are no current connections to the host for which the name resolution you added by using
netstat -a or something like
Unless you have dns suffixing setup to append the domain names to the end of the host, you can usually tell if it is netbios by the use of a single name for resolution. It is common for corporate networks to suffix domains and add search orders to ease local resolution of hosts on the network.
I have noticed some of the applications I use also cache some of these responses, and must ensure they are completely closed before the resolution works properly. Firefox and IE like to occasionally run in the background, despite not having any active windows, but that may be more my fault than the applications.
I use Windows Vista connect to an office via a VPN. I use the LMHOSTS file to define names for IP addresses the other side of the VPN.
Unlike the other comments, I find that pinging a name after updating the LMHOSTS file does not use the new IP immediately. It does happen eventually but to speed up the process I use:
"-R (Reload) Purges and reloads the remote cache name table"
I have tried ipconfig /flushdns but it did not work for me.
[You have to open the command as an Administrator. Or run it from a command prompt with administrator privileges]
Powershell cmdlets Set-HostsEntry and Remove-HostsEntry no reboot needed, can be scheduled, could probably be triggered upon connection to specific Wifi or Network names
Syntax: Set-HostsEntry -IPAddress 10.5.6.7 -HostName 'myserver' and Remove-HostsEntry -HostName 'myserver'
install as part of carbon package from http://get-carbon.org/
worked for me and my temporary internal email server.