Skip to main content

The chg_hostname project is a command-line tool designed to manage your system's host file. It allows users to back up the host file, restore it from a backup, and append new host entries based on a provided JSON configuration file (hosts.json). The tool also includes functionality to replace loopback addresses in the provided configuration.

Project description

Project Overview

This project focuses on managing the system's host file, typically located at /etc/hosts on Unix-like systems. The primary goal is to provide a structured way to define and manipulate host-to-IP address mappings, often using a JSON configuration file (hosts.json). The project aims to simplify the process of adding, modifying, and backing up host file entries. It's important to note that the scope of this project is specifically the management of the host file, and it is designed to work with a particular JSON schema.

hosts.json Structure The hosts.json file is the core configuration file for this project. It uses a JSON format to define the host entries. Here's a breakdown of its structure:

{
  "loopback_ip": "10.0.0.0",
  "host_entries": [
    {
      "ip": "10.0.0.0",
      "hostname": "example.com"
    },
    {
      "ip": "10.0.0.0",
      "hostname": "example.com"
    },
    // ... more host entries
  ]
}

loopback_ip (Optional): This string field specifies the IP address of the current host on the network (e.g., "10.0.0.56"). It's important to understand that this is not necessarily the standard loopback address (127.0.0.1), but rather the actual network IP of the machine where this configuration is being used. This field is optional. The name it is due to this ip being replaced for the (127.0.0.1) where it does find a match in the host_entries

host_entries: This is an array of objects, where each object defines a single host entry.

ip: A string representing the IP address (e.g., "10.0.0.3"). The project uses the ipaddress module in Python to validate this IP.

hostname: A string representing the hostname (e.g., "example.lan").

Scope of the Project:

The chg_hostname project is specifically designed for managing the system's host file by appending new entries based on the provided hosts.json file format. It offers functionalities for backing up and restoring the entire host file. The project's scope is limited to these operations and does not include functionalities for dynamically managing DNS records, interacting with DNS servers, or modifying existing entries within the host file beyond the replacement of loopback addresses based on the loopback_ip in the configuration.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

chg_hostname-1.0.0.tar.gz (12.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

chg_hostname-1.0.0-py3-none-any.whl (16.4 kB view details)

Uploaded Python 3

File details

Details for the file chg_hostname-1.0.0.tar.gz.

File metadata

  • Download URL: chg_hostname-1.0.0.tar.gz
  • Upload date:
  • Size: 12.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.14

File hashes

Hashes for chg_hostname-1.0.0.tar.gz
Algorithm Hash digest
SHA256 e0897ea4177c821005a1285f2efa24e9d770b42b54bc428d9f2f5b9aba940f23
MD5 05aeaac7145e56b6475d63a4565ac22a
BLAKE2b-256 5fbb8dc41b5b6b30445f296195b168f4e89137ce2f506b65f152f3517a487bfa

See more details on using hashes here.

File details

Details for the file chg_hostname-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for chg_hostname-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f40b2c5fbc1583e34c23e08590fcdd8beae64b33ee282866b23b8b2b8cc8f846
MD5 21d5dde7de1fe237b785814f0e53c8af
BLAKE2b-256 4977343b82c529ee2c47f311ca2f18200574e0ac449459045b97426eb455276b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page