What to Include in Host Files
The key to effective host file usage is selective inclusion of truly critical resources. Host files should not attempt to replace DNS entirely, but rather provide a safety net for essential infrastructure.
Essential Entries for All Servers:
-
DNS Servers (Highest Priority):
- Without these, you cannot fix DNS when it fails
- Include both IPv4 and IPv6 addresses
- List all DNS servers in your infrastructure
10.1.1.53 dns1.example.com dns1 10.1.1.54 dns2.example.com dns2 2001:db8:1::53 dns1.example.com 2001:db8:1::54 dns2.example.com -
Default Gateway/Router:
- Essential for network troubleshooting
- Required for routing configuration access
10.0.0.1 gateway.example.com gw router 2001:db8::1 gateway.example.com -
Authentication Infrastructure:
- LDAP servers, Active Directory domain controllers
- Critical for user authentication and authorization
10.3.0.5 ldap.example.com 10.3.0.6 dc1.example.com ad1 2001:db8:3::5 ldap.example.com
Application-Specific Entries:
-
Database Servers (for application servers):
10.2.0.10 db-master.example.com 10.2.0.11 db-replica.example.com fd00:db::10 db-master.example.com -
Monitoring and Management Systems:
10.4.0.20 nagios.example.com monitoring 10.4.0.21 grafana.example.com metrics 10.4.0.25 syslog.example.com -
Time Servers (NTP):
- Critical for accurate logging and certificate validation
10.5.0.1 ntp1.example.com 10.5.0.2 ntp2.example.com
IT Workstation Additions:
IT administrator workstations should include comprehensive entries for:
- All network equipment management interfaces (switches, routers, firewalls)
- Server management interfaces (iDRAC, iLO, IPMI)
- Virtualization infrastructure (vCenter, ESXi hosts)
- Backup systems
- Security appliances
Host File Best Practices
Organization and Maintenance:
-
Group Entries Logically:
- Separate sections for different infrastructure types
- Use clear, descriptive comments
- Maintain consistent formatting
# DNS Infrastructure - Critical 10.1.1.53 dns1.example.com dns1 10.1.1.54 dns2.example.com dns2 # Database Tier 10.2.0.10 db-master.example.com db-master 10.2.0.11 db-replica.example.com db-replica -
Document Changes:
- Add dates and reasons for modifications
- Track who made changes and why
- Consider using configuration management tools (Ansible, Puppet)
-
Version Control:
- Keep backups of host files
- Consider storing in Git for change tracking
- Document the canonical version source
-
Include Both IPv4 and IPv6:
- Modern networks increasingly use IPv6
- Maintain both address families for resilience
- Ensure consistency between IPv4 and IPv6 entries
Distribution and Automation:
-
Automate Deployment:
- Use configuration management for consistent distribution
- Avoid manual edits across multiple servers
- Implement validation before deployment
-
Regular Audits:
- Verify entries are current and accurate
- Remove obsolete entries
- Check for conflicts or duplicates
-
Test Changes:
- Validate syntax before deployment
- Verify entries resolve correctly
- Flush DNS cache after updates
When Host Files Are Not Appropriate
While host files provide critical failsafe capabilities, they have limitations:
Don’t Use Host Files For:
- Dynamic Content: Services with frequently changing IP addresses
- Load Balancing: Host files cannot distribute traffic across multiple servers
- Large-Scale Management: Networks with thousands of hosts should use DNS
- Wildcard Entries: Host files don’t support *.example.com patterns
- Mobile/Roaming Clients: Devices that move between networks need DNS
Host Files vs. DNS:
Host files complement DNS; they don’t replace it. Use DNS for:
- Dynamic service discovery
- Load balancing and failover
- Large numbers of hosts (500+)
- Frequently changing infrastructure
- Geographic distribution and optimization
Use host files for:
- Critical infrastructure failsafe
- Emergency access during DNS outages
- Static, high-priority resources
- Bootstrap operations before DNS is available
Integration with Configuration Management
Modern infrastructure automation makes host file management straightforward:
Ansible Example:
- name: Deploy critical hosts file entries
blockinfile:
path: /etc/hosts
block: |
# Critical Infrastructure - Managed by Ansible
10.1.1.53 dns1.example.com dns1
10.1.1.54 dns2.example.com dns2
10.0.0.1 gateway.example.com gw
marker: "# {mark} ANSIBLE MANAGED INFRASTRUCTURE BLOCK"
Puppet Example:
host { 'dns1.example.com':
ensure => present,
ip => '10.1.1.53',
host_aliases => ['dns1'],
}
This approach ensures:
- Consistent host files across infrastructure
- Centralized management
- Version-controlled changes
- Rapid updates when infrastructure changes
Practical Workflow Examples:
Example 1: Infrastructure Server Host File
- User tags critical infrastructure in ResorsIT (DNS servers, gateways, databases)
- Select “Generate Host File” → “Infrastructure Servers Template”
- ResorsIT exports all tagged hosts with current IP addresses and aliases
- Output includes both IPv4 and IPv6 entries automatically
- Deploy via Ansible/Puppet to all production servers
- When IP changes, regenerate and redeploy in minutes
Example 2: IT Workstation Host File
- Select subnets containing management interfaces (IPMI, iDRAC, iLO)
- Add all DNS servers from the DNS infrastructure
- Include network equipment management IPs
- ResorsIT generates comprehensive host file with 200+ entries
- Deploy to all IT administrator workstations
- Update quarterly or when major infrastructure changes occur
Example 3: Emergency Access Host File
- Tag “emergency access only” hosts: DNS servers, critical gateways, authentication
- Generate minimal host file (20-30 entries)
- Deploy to ALL servers as absolute minimum failsafe
- These entries ensure basic infrastructure access during total DNS failure
Infrastructure Visibility for Smart Selection:
- Visual subnet management shows IP allocations and utilization
- Cross-reference DNS records with subnet assignments to find discrepancies
- Identify critical infrastructure through subnet categorization (management, production, infrastructure)
- Tag-based selection: Mark hosts as critical, infrastructure, monitoring, etc.
- Dependency mapping: Identify which services depend on which infrastructure
Change Tracking and Audit Trail:
- Audit logs (SaaS) or Git-backed history (Platform) of all DNS and IP changes
- Audit trail shows who changed what infrastructure and when
- Rollback capabilities: Revert to previous configurations when needed (Platform)
- Host file versioning: Track which host file version was deployed when
- Change notifications: Alert when critical infrastructure IPs change
Validation and Consistency:
- Detect conflicts between DNS records and subnet allocations
- Validate syntax before host file generation (no typos or malformed entries)
- Ensure consistency between IPv4 and IPv6 entries
- Check for duplicates: Prevent same hostname with different IPs
- Alias validation: Ensure aliases are unique and don’t conflict
Integration with Configuration Management:
Ansible Integration Example:
- name: Generate host file from ResorsIT
uri:
url: https://resorsit.example.com/api/hostfile/infrastructure
method: GET
return_content: yes
register: hostfile_content
- name: Deploy to servers
blockinfile:
path: /etc/hosts
block: "{{ hostfile_content.content }}"
marker: "# {mark} RESORSIT MANAGED INFRASTRUCTURE"
API-Driven Updates:
- ResorsIT provides REST API for host file generation
- Automated daily/weekly regeneration via cron or scheduled jobs
- Conditional updates: only deploy if infrastructure changed
- Notification when host file needs updating
Benefits Over Manual Management:
- Elimination of human error: No typos, formatting mistakes, or forgotten entries
- Always current: Generate from live data, not outdated spreadsheets
- Reduced maintenance time: Minutes instead of hours to update host files
- Consistent across fleet: All servers get identical infrastructure entries
- Documented decisions: Tags and categories explain why each host is included
- Easy auditing: Clear record of what’s in host files and why
Typical ResorsIT Host File Management Workflow:
- Initial Setup: Tag critical infrastructure in ResorsIT (one-time effort)
- Template Creation: Define role-based templates (servers, workstations, network gear)
- Automated Generation: Schedule or trigger host file exports
- Deployment: Use configuration management to distribute
- Maintenance: When infrastructure changes, regenerate and redeploy
- Audit: Quarterly review of which hosts are tagged as critical
By maintaining DNS and IP data as a single source of truth, ResorsIT eliminates the tedious, error-prone work of manually maintaining host files across your infrastructure. Users retain full control over which hosts are included (based on criticality assessment), while ResorsIT handles the mechanics of generation, formatting, validation, and keeping everything synchronized with your actual infrastructure.