2015-02-05 05:18:29 +00:00
# hostess [![](https://travis-ci.org/cbednarski/hostess.svg)](https://travis-ci.org/cbednarski/hostess)
2015-01-17 09:25:28 +00:00
2015-02-03 08:14:07 +00:00
An idempotent command-line utility for managing your `/etc/hosts` file.
2015-01-17 09:25:28 +00:00
## Usage
hostess add domain ip # Add or change a hosts entry for this domain pointing to this IP
2015-02-03 08:14:07 +00:00
hostess add -off domain ip # Add in a disabled state (if it already exists, disable it)
2015-01-17 09:25:28 +00:00
hostess del domain # Remove a domain from your hosts file
2015-02-06 07:41:17 +00:00
hostess has domain # exit code 0 or 1 if the domain is in your hostfile
2015-01-17 09:25:28 +00:00
hostess off domain # Disable a domain (but don't remove it completely)
hostess on domain # Re-enable a domain that was disabled
hostess ls # List domains, target ips, and on/off status
2015-02-06 07:41:17 +00:00
hostess fix # Read your hosts file and show warnings if there are bumps
hostess dump # Dump your hostfile as json
2015-02-04 18:10:05 +00:00
hostess apply # Add entries from a json file
2015-02-03 08:06:20 +00:00
2015-02-06 07:41:17 +00:00
Flags
-n # Dry run. Show what will happen but don't do it; output to stdout
-f # Forcibly rewrite the hostfile, even if there are errors or conflicts
2015-02-25 09:53:41 +00:00
-4 # Limit operation to ipv4 entries
-6 # Limit operation to ipv6 entries
2015-02-06 07:41:17 +00:00
2015-01-17 09:25:28 +00:00
hostess may mangle your hosts file. In general it will probably look like this, with domains pointing at the same IP grouped together and disabled domains commented out.
127.0.0.1 localhost hostname2 hostname3
127.0.1.1 machine.name
# 10.10.20.30 some.host
2015-02-03 08:06:20 +00:00
2015-02-25 09:53:41 +00:00
## IPv4 and IPv6
2015-03-12 01:36:24 +00:00
Your hosts file *can* contain overlapping entries where the same hostname points to both an IPv4 and IPv6 IP. In this case, hostess commands will apply to both entries. Typically you won't have this kind of overlap and the default behavior is OK. However, if you need to be more granular you can use `-4` or `-6` to limit operations to entries associated with that type of IP.
2015-02-25 09:53:41 +00:00
2015-01-17 09:25:28 +00:00
## Installation
2015-02-06 07:41:17 +00:00
Grab a [release ](https://github.com/cbednarski/hostess/releases ) or download the code and run `make install` (building probably requires go 1.4).
2015-01-17 09:25:28 +00:00
## Configuration
2015-03-21 09:25:44 +00:00
By default, hostess will read / write to `/etc/hosts` . You can use the `HOSTESS_PATH` environment variable to provide an alternate path (for testing).
2015-01-17 09:25:28 +00:00
## Disclaimer
2015-02-03 08:06:20 +00:00
2015-02-06 07:41:17 +00:00
hostess uses readme-driven-development and may not actually do any of the things listed above. When in doubt, pass the `-n` flag to try hostess without changing your system.