Skip to content

Commit

Permalink
elaborate the README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
socrateslee committed Jun 21, 2019
1 parent f53cefb commit 1a65442
Showing 1 changed file with 37 additions and 14 deletions.
51 changes: 37 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,52 @@
# hostsed -- A tiny hosts file command line edit tool

hostsed is a simple python tool for editing hosts file(/etc/hosts), you can add or delete a DNS entry via command line shell(e.x. bash).
hostsed is a simple python tool for editing hosts file(default /etc/hosts), you can add or delete a DNS entry via command line shell(e.x. bash). Editing hosts file with hostsed would be a more idemponent command line experience, i.e., add/del the same record won't result duplicated or missing entries in the hosts file. hostsed will check the validity ip address for both IPV4 and IPV6.

Install:
## Install
You may install hostsed via pip. Python3 is preferred:

```
sudo pip install hostsed
sudo pip3 install hostsed
```

Usage:
Or on system default pip command:

```
# Add an entry
sudo hostsed add <ip address> <hostname1> <hostname2> ...
sudo pip install hostsed
```

## Usage

### Display the hosts file content

sudo hostsed
# specify a location other than /etc/hosts
hostsed --file hosts.example

### Add an entry

sudo hostsed add <ip address> <hostname1> <hostname2> ...

Example:
sudo hostsed add 192.168.1.1 gateway
sudo hostsed add 172.17.0.5 mongo-store-1 mysql-02

# Delete an entry
sudo hostsed del <ip address> <hostname>
sudo hostsed add 192.168.1.1 gateway
sudo hostsed add 172.17.0.5 mongo-store-1 mysql-02
hostsed --file hosts.exmaple add 127.0.0.1 valarmorghulis.io

### Delete an entry
rm/delete/remove are all alias for del:

sudo hostsed del <ip address> <hostname>

Example:
hosted remove 192.168.1.1 gateway

# Get the ip address of a docker container
sudo hostsed docker <docker-container-name>
```
sudo hostsed remove 192.168.1.1 gateway
hostsed --file rm ::1 localhost

### Get the ip address of a docker container

sudo hostsed docker <docker-container-name>

## Acknowledgement

Thanks for @noahfx provide some awesome improve for hostsed.

0 comments on commit 1a65442

Please sign in to comment.