Hack and / - Right Command, Wrong Server

 in
It's easy to lose track of what your servers do when they number in the tens or hundreds. Here are a few simple techniques I've found that make it easier to manage them all.
DNS TXT Records

One of the problems with the previous two methods is that you must log in to a machine to get information on it. That leads me to one of my favorite ways to organize my servers, DNS TXT records. Most people probably are familiar with a DNS A record (it maps a hostname to an IP address) and probably CNAME and PTR records (it maps one hostname to another hostname and an IP address to a hostname, respectively), but many admins aren't aware of (or don't use) TXT records. A TXT record essentially allows you to assign text to a particular hostname. If you have an internal DNS infrastructure for your machines, you probably already have A records for all your servers. If you add a TXT record as well, that gives you a nice centralized place to document what each server does in a way that can be queried from any machine on the network.

To demonstrate how to use TXT records, let's assume I'm using a standard BIND server for DNS, and this is a short section of the file that defines A records for three hosts—napoleon, snowball and major:

napoleon    IN   A   192.168.1.6
snowball    IN   A   192.168.1.7
major       IN   A   192.168.1.8

All I would do is add a new TXT record below any A records I have that lists what those servers do:

napoleon    IN   A   192.168.1.6
napoleon    IN   TXT "DNS, DHCP, Internal wiki"
snowball    IN   A   192.168.1.7
snowball    IN   TXT "Primary Internal File Server" 
major       IN   A   192.168.1.8
major       IN   TXT "Failover Internal File Server" 

Once I save my changes and reload BIND, the TXT records are ready to go. The next time I'm scratching my head trying to figure out what snowball does, I just have to issue a dig query:

$ dig snowball.example.net TXT +short
"Primary Internal File Server"

Note that I used the +short option with dig. That way, I get back only the contents of the TXT record instead of the volume of data dig normally gives me. Not only does this make it easy to narrow in on the information I want, it also makes it a handy little one-liner to add to other programs. I even could see some savvy administrators tweaking their shell prompt or motd so that it contained this value.

Again, the beauty of using TXT records to document this is that it puts the information in a central place that you control and that you typically have to modify whenever you add a host anyway. Just be careful if you use this for externally facing DNS hosts—you might not necessarily want to broadcast all of your server info to everyone on the Internet.

Kyle Rankin is a Senior Systems Administrator in the San Francisco Bay Area and the author of a number of books, including Knoppix Hacks and Ubuntu Hacks for O'Reilly Media. He is currently the president of the North Bay Linux Users' Group.

______________________

Kyle Rankin is a director of engineering operations in the San Francisco Bay Area, the author of a number of books including DevOps Troubleshooting and The Official Ubuntu Server Book, and is a columnist for Linux Journal.

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Meaningful names.

Anonymous's picture

Name your servers meaningful names that describe what they do, and what environment they're in.

www1prod
db1dev
smtp2prod
imap3corp
vpn1corp

Guess what those servers do, and which environment of the infrastructure they're in?

Also, stop running commands by hand to configure systems, and start using a configuration management tool.

White Paper
Linux Management with Red Hat Satellite: Measuring Business Impact and ROI

Linux has become a key foundation for supporting today's rapidly growing IT environments. Linux is being used to deploy business applications and databases, trading on its reputation as a low-cost operating environment. For many IT organizations, Linux is a mainstay for deploying Web servers and has evolved from handling basic file, print, and utility workloads to running mission-critical applications and databases, physically, virtually, and in the cloud. As Linux grows in importance in terms of value to the business, managing Linux environments to high standards of service quality — availability, security, and performance — becomes an essential requirement for business success.

Learn More

Sponsored by Red Hat

White Paper
Private PaaS for the Agile Enterprise

If you already use virtualized infrastructure, you are well on your way to leveraging the power of the cloud. Virtualization offers the promise of limitless resources, but how do you manage that scalability when your DevOps team doesn’t scale? In today’s hypercompetitive markets, fast results can make a difference between leading the pack vs. obsolescence. Organizations need more benefits from cloud computing than just raw resources. They need agility, flexibility, convenience, ROI, and control.

Stackato private Platform-as-a-Service technology from ActiveState extends your private cloud infrastructure by creating a private PaaS to provide on-demand availability, flexibility, control, and ultimately, faster time-to-market for your enterprise.

Learn More

Sponsored by ActiveState