You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
hostess/README.md

62 lines
2.4 KiB
Markdown

# hostess [![Linux Build Status](https://travis-ci.org/cbednarski/hostess.svg)](https://travis-ci.org/cbednarski/hostess) [![Windows Build Status](https://ci.appveyor.com/api/projects/status/wtxqb880b7v9dfgn/branch/master?svg=true)](https://ci.appveyor.com/project/cbednarski/hostess/branch/master) [![GoDoc](https://godoc.org/github.com/cbednarski/hostess?status.svg)](http://godoc.org/github.com/cbednarski/hostess)
9 years ago
An **idempotent** command-line utility for managing your `/etc/hosts`* file.
hostess add local.example.com 127.0.0.1
hostess add staging.example.com 10.0.2.16
Why? Because you edit `/etc/hosts` for development, testing, and debugging.
Because sometimes DNS doesn't work in production. And because editing
`/etc/hosts` by hand is a pain. Put hostess in your `Makefile` or deploy scripts
and call it a day.
9 years ago
\* And `C:\Windows\System32\drivers\etc\hosts` on Windows.
**Note: 0.5.0 has backwards incompatible changes in the API and CLI.** See
`CHANGELOG.md` for details.
9 years ago
## Installation
Download a [precompiled release](https://github.com/cbednarski/hostess/releases)
from GitHub, or build from source (with a [recent version of Go](https://golang.org/dl)):
go get -u github.com/cbednarski/hostess
## Usage
Run `hostess` or `hostess -h` to see a full list of commands.
9 years ago
## Format
On unixes, hostess follows the format specified by `man hosts`, with one line
per IP address:
9 years ago
127.0.0.1 localhost hostname2 hostname3
127.0.1.1 machine.name
# 10.10.20.30 some.host
9 years ago
On Windows, hostess writes each hostname on its own line.
127.0.0.1 localhost
127.0.0.1 hostname2
127.0.0.1 hostname3
9 years ago
## Configuration
9 years ago
hostess may be configured via environment variables.
- `HOSTESS_FMT` may be set to `windows` or `unix` to override platform detection
for the hosts file format. See Behavior, above, for details
9 years ago
- `HOSTESS_PATH` may be set to override platform detection for the location of
the hosts file. By default this is `C:\Windows\System32\drivers\etc\hosts` on
Windows and `/etc/hosts` everywhere else.
9 years ago
## IPv4 and IPv6
Your hosts file _may_ 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.