hostsctl is a command-line tool for managing your system's hosts file. It provides commands for:
- list entries
- exists of entry
- add, remove, enable, and disable entries
- backup and restore hosts file
With the ability to use a template file to save entries within your project.
With options you can specify:
- specify a custom input/output file
- use JSON output format
listlist the entries in the hosts filebackupbackups the hosts filerestorerestores the hosts file from a backupadd <hostname>adds entry to the hosts fileremove <hostname>removes entry from hosts fileenable <hostname>enables entry in hosts filedisable <hostname>disables entry in hosts fileexists <hostname>checks if entry exists in hosts fileopenopens hosts file (using shell execute) - Windows onlytemplatenewcreates a new template filelistlist the entries in the template fileadd <hostname>adds entry to the template fileremove <hostname>removes entry from template fileapplyapplies the template file to the hosts file
-i|--input <file>: path of input file, default value depends on operating system-o|--output <file>: path of output file, default value is same as input file-t|--template <template>: path of template file, default value is hosts.ht in working directory-j|--json: output as JSON<hostname>: host name, ex. app.mydomain.local[ip]: ip address, default is 127.0.0.1
You can install it using the dotnet tool install ppech.dotnet.hostsctl --global command.
To update dotnet.hostsctl to the latest version, use the dotnet tool update command.
This project is licensed under the MIT License.