hostsed -- A tiny hosts file command line edit tool
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
You may install hostsed via pip. Python3 is preferred:
sudo pip3 install hostsed
Or on system default pip command:
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
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:
sudo hostsed remove 192.168.1.1 gateway
hostsed --file hosts.exmaple rm ::1 localhost
Drop lines with specified ip or hostname
sudo hostsed drop <ip or hostname>
Example:
sudo hostsed drop 192.168.1.1
sudo hostsed drop www.example.com
hostsed --file hosts.exmaple drop ::1
Get the ip address of a docker container
sudo hostsed docker <docker-container-name>
Acknowledgement
Thanks for @noahfx provide some awesome improve for hostsed.
Metadata
Release files for hostsed 0.5.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| hostsed-0.5.1.tar.gz | 6.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| hostsed-0.5.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 12.4 kB
Release files / hostsed-0.5.1.tar.gz
| Download URL | hostsed-0.5.1.tar.gz |
|---|---|
| Size | 6.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a84923d5046422c5d923d772fddf4e3e2657be34fba20f391765df00c295db07
|
|
BLAKE2b-256 checksum How to use checksums |
88d6ce307511fa902a58b2201d9c0288bd7ba47b3a132d6a63c6a24bbd37c42b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.5.29
|
Release files / hostsed-0.5.1-py3-none-any.whl
| Download URL | hostsed-0.5.1-py3-none-any.whl |
|---|---|
| Size | 6.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3e0d7cc70dc562637f5e78dfcd4d64a5554d3e6d54759d6fbed61d2131fc1d8a
|
|
BLAKE2b-256 checksum How to use checksums |
be125a8db3542d605c601605cdce2414a9afc153cece697285ea8d20283deb6f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.5.29
|