Tip: Never use IP addresses

By | 2010-03-12

Never use IP addresses

Use of IP addresses are never actually required. There are two fully valid alternatives:

  1. Using DNS name served by DNS server. Windows/Linux can have unlimited number of DNS servers in case one goes down, so there is no problem with stability. Just add more DNS-servers. (At least two)
  2. In case DNS is not possible at all: Using DNS name added manually to hosts-file. In Windows: C:\Windows\System32\Drivers\etc\hosts, on Linux/Unix: /etc/hosts

Reasons:

  • It does not take any extra time or effort for developer to use DNS name instead of IP.
  • IP reference could exist in many places, for example web.config, hardcoded in source (BAD CODER!), SQL-db, third-party config files, etc.
  • If IP reference is used and a server or service is moved the reference to it must be changed. Since the IP can exist in any number of places updating it everywhere can be problematic and lead to errors.
  • The unknown: If you are not sure if IP is in use and if you have changed all references then the solution must be fully tested, which can be very difficult and time consuming.

Leave a Reply