Thursday, December 2, 2010

How to Flush DNS


How to Flush DNS in Microsoft Windows

In Microsoft Windows, you can use the command ipconfig /flushdns to flush the DNS resolver cache. Open the command prompt and type the following:
C:>ipconfig /flushdns
Windows IP Configuration
Successfully flushed the DNS Resolver Cache.
 The above command will completely flush the DNS, deleting any incorrect entries too. You can also use the command ipconfig /displaydns to view the DNS resolver cache.

Turning Off DNS Caching under Microsoft Windows

If you experience frequent issues with DNS caching under Microsoft Windows, you can disable client-side DNS caching with either of these two commands:
net stop dnscache
sc servername stop dnscache
This will disable DNS caching until the next reboot. To make the change permanent, use the Service Controller tool or the Services tool to set the DNS Client service startup type to Disabled. You can permanently disable DNS Client by following the below steps:
  • Goto Start and click on Run.
  • Type Services.msc in the Run command box.
  • A window listing all the services will popup. Search for a service called DNS Client.
  • Double click on the listed DNS Client service and click Stop. Similarly, you can restart it by clicking Start.

Tuning DNS Caching under Microsoft Windows

You can modify the behavior of the Microsoft Windows DNS caching algorithm by setting two registry entries in the HKEY_LOCAL_MACHINESYSTEMCurrentControlSetServicesDnscacheParameters registry key.
The MaxCacheTtl represents the maximum time that the results of a DNS lookup will be cached. The default value is 86,400 seconds. If you set this value to 1, DNS entries will only be cashed for a single second.
MaxNegativeCacheTtl represents the maximim time that the results of a failed DNS lookup will be cached. The default value is 900 seconds. If you set this value to 0, failed DNS lookups will not be cached.

Flush DNS in Mac OSX

In Mac OSX Leopard, you can use the command dscacheutil -flushcache to flush the DNS resolver cache:
bash-2.05a$ dscacheutil -flushcache
In Mac OSX versions 10.5.1 and before, the command lookupd -flushcache performed the same task:
bash-2.05a$ lookupd -flushcache

Flush DNS in Linux

In Linux, the nscd daemon manages the DNS cache. To flush the DNS cache, restart the nscd daemon. To restart the nscd daemon, use the command `/etc/init.d/nscd restart`.

Linux and nf_conntrack.

When you have messages like this :


Dec  2 13:12:28 VivaLAN kernel: [8768983.190310] nf_conntrack: table full, dropping packet.
Dec  2 13:14:32 VivaLAN kernel: [8769110.070735] nf_conntrack: table full, dropping packet.
Dec  2 13:14:32 VivaLAN kernel: [8769110.082320] nf_conntrack: table full, dropping packet.
Dec  2 13:14:32 VivaLAN kernel: [8769110.082320] nf_conntrack: table full, dropping packet.
Dec  2 13:14:32 VivaLAN kernel: [8769110.086320] nf_conntrack: table full, dropping packet.
Dec  2 13:14:32 VivaLAN kernel: [8769110.089848] nf_conntrack: table full, dropping packet.
Dec  2 13:14:32 VivaLAN kernel: [8769110.094892] nf_conntrack: table full, dropping packet.
Dec  2 13:14:32 VivaLAN kernel: [8769110.099703] nf_conntrack: table full, dropping packet.
Dec  2 13:14:32 VivaLAN kernel: [8769110.119987] nf_conntrack: table full, dropping packet.
Dec  2 13:14:32 VivaLAN kernel: [8769110.127979] nf_conntrack: table full, dropping packet.
Dec  2 13:14:32 VivaLAN kernel: [8769110.138279] nf_conntrack: table full, dropping packet.












you can disable the conntrack : 




iptables -t raw -I OUTPUT -j NOTRACK
iptables -t raw -I PREROUTING -j NOTRACK

The other way when you do not want to disable full contrack you can increase the connections
#cat /proc/sys/net/ipv4/netfilter/ip_conntrack_max
65432
#
# echo "130864" > /proc/sys/net/ipv4/netfilter/ip_conntrack_max